This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

detect double, single and long press from wall switch
#5
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
Reply


Messages In This Thread
RE: detect double, single and long press from wall switch - by admin - 13.07.2015, 07:54

Forum Jump: