13.07.2015, 07:54
Yes, you are right. Still, you should check the event value in order not run the script when counter is 0, like this:
Code:
value = tonumber(event.datahex, 16)
if value > 0 then
light1 = '1/2/1'
light2 = '1/2/2'
switcher_adress = '1/1/1'
os.sleep(1)
value = event.getvalue()
if value == 1 then
-- log('single press '.. switcher_adress)
grp.write(light1, not(grp.getvalue(light1)))
elseif value == 2 then
-- log('double ' .. switcher_adress)
grp.write(light2, not(grp.getvalue(light2)))
end
-- reset counter
if value > 0 then
grp.update(event.dst, 0)
end
end