Timers and Delays, less then 1 second.

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
vandalon
New user
Posts: 6
Joined: 14 May 2018, 16:01

Timers and Delays, less then 1 second.

#1 Post by vandalon » 07 Jul 2018, 17:19

Hi,

I'm trying to configure a switch button (push button) to do 3 things:

1: short press (sends out "1" via mqtt)
2: long press (sends out "2" via mqtt)
3: double press (sends out "3" via mqtt)

now, this is all not to difficult to build with a timer. But timers are not configurable less then 1 second. And I don't want to wait a second before something happens. Also I'm not sending commands to local gpio ports but rather to mqtt, which makes the pulse option also unusable in my case. so I'm left with using delay. The thing with delay is that when I press a button shortly when the delay is running , espeasy is not noticing. So, Does anyone have a good hint on how to work around this?

For reference, this is how I do it with a 1 second timer (double click is instant, sw1#Switch, value 0 is pressed, 1 not pressed):

Code: Select all

On sw1#Switch=0 do
  timerSet,1,1
  if [swClick#1] = 1
    timerSet,1,0
    TaskValueSet,6,1,0
    Publish home/%sysname%/sw1,3
  else
    TaskValueSet,6,1,1
  endif
endon

On Rules#Timer=1 do
  TaskValueSet,6,1,0
  if [sw1#Switch]=0 and [swClick#1]=0
    Publish home/%sysname%/sw1,2
  else
    Publish home/%sysname%/sw1,1
  endif
endon
Cheers,
Joris

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot] and 27 guests