Long press button delay

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
christopharris
New user
Posts: 1
Joined: 22 Nov 2021, 06:55

Long press button delay

#1 Post by christopharris » 22 Nov 2021, 06:56

Hello! I'm new to using EspEasy. I've been trying to figure it out for a few days, but I can not do anything. My task is simple. There is 1 switch. With this switch I want to operate 2 relays. By means of short and long pressing of the button. Switch is a simple press button. I can do it with the help of this rule:

on sw1#value1 do
if [sw1#value1] = 0
timerSet, 1, 1
endon

on rules#timer=1 do
if [sw1#value1] = 1
...
else
...
endif
endon

But there is a problem - too long delay with a short press. A whole second. And it's very inconvenient. I have read that for timerSet you can not use a value of less than 1 second. I read about the delay function. I'm trying to use it instead of timerSet, but nothing happens. Maybe someone can help me?

User avatar
Ath
Normal user
Posts: 3415
Joined: 10 Jun 2018, 12:06
Location: NL

Re: Long press button delay

#2 Post by Ath » 22 Nov 2021, 07:40

There is a mishap in your code, the endif is missing after timerSet,1,1
Documentation on rules is here: https://espeasy.readthedocs.io/en/lates ... Rules.html

Code: Select all

on sw1#value1 do
  if [sw1#value1] = 0
    timerSet, 1, 1
  endif
endon

on rules#timer=1 do
  if [sw1#value1] = 1
    ...
  else
    ...
  endif
endon
And besides the timerSet command there is also a timerSet_ms that has a milliseconds argument instead of a seconds argument, giving finer control.
The complete list of commands is here: https://espeasy.readthedocs.io/en/lates ... mmand.html

You could also react to the event value 10 or 11 when the longpress is activated, as documented in the comboboxes on the Switch settings.
/Ton (PayPal.me)

Post Reply

Who is online

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