Rules same GPIO and Longpress event
Moderators: grovkillen, Stuntteam, TD-er
Rules same GPIO and Longpress event
Hello,
I'm Using on ESP_01 with a PIR on GPIO 2 and a Relay on GPIO 0.
In parallel on the pir, I have a push button.
By the action of the PIR or the push button the relay is activated for 5 seconds (this work).
By pressing the push button for more than 4 sec. I would like to switch on the relay with a delay of 25 seconds.
LongPress detection: GPIO= 2 State=1 Output value=11 is OK.
But the elseif [ESP_01-PIR#STATE]=11.00 is not executed !
I tested also with =11 but it's dosent work too.
Below ma Rule.
Many thanks in advance for your help
Otto
Rules set 1:
on System#Boot do
LongPulse,0,1,5
endon
on ESP_01-PIR#STATE do
if [ESP_01-PIR#STATE]=1 // PIR ou Button
LongPulse,0,0,5 // Relay ON 5s
elseif [ESP_01-PIR#STATE]=11.00 // Button pressé sur plus de 4 sec.
LongPulse,0,0,25 // Relay ON 25s
endif
endon
Log
966879: SW : GPIO=2 State=1 Output value=1
966882: EVENT: ESP_01-PIR#STATE=1.00
966893: ACT : LongPulse,0,0,5
966894: Command: LongPulse
966897: SW : GPIO 0 Pulse set for 5 sec
970879: SW : LongPress: GPIO= 2 State=1 Output value=11
970882: EVENT: ESP_01-PIR#STATE=11.00
970893: ACT : LongPulse,0,0,5
970894: Command: LongPulse
970897: SW : GPIO 0 Pulse set for 5 sec
972080: SW : GPIO=2 State=0 Output value=0
972082: EVENT: ESP_01-PIR#STATE=0.00
I'm Using on ESP_01 with a PIR on GPIO 2 and a Relay on GPIO 0.
In parallel on the pir, I have a push button.
By the action of the PIR or the push button the relay is activated for 5 seconds (this work).
By pressing the push button for more than 4 sec. I would like to switch on the relay with a delay of 25 seconds.
LongPress detection: GPIO= 2 State=1 Output value=11 is OK.
But the elseif [ESP_01-PIR#STATE]=11.00 is not executed !
I tested also with =11 but it's dosent work too.
Below ma Rule.
Many thanks in advance for your help
Otto
Rules set 1:
on System#Boot do
LongPulse,0,1,5
endon
on ESP_01-PIR#STATE do
if [ESP_01-PIR#STATE]=1 // PIR ou Button
LongPulse,0,0,5 // Relay ON 5s
elseif [ESP_01-PIR#STATE]=11.00 // Button pressé sur plus de 4 sec.
LongPulse,0,0,25 // Relay ON 25s
endif
endon
Log
966879: SW : GPIO=2 State=1 Output value=1
966882: EVENT: ESP_01-PIR#STATE=1.00
966893: ACT : LongPulse,0,0,5
966894: Command: LongPulse
966897: SW : GPIO 0 Pulse set for 5 sec
970879: SW : LongPress: GPIO= 2 State=1 Output value=11
970882: EVENT: ESP_01-PIR#STATE=11.00
970893: ACT : LongPulse,0,0,5
970894: Command: LongPulse
970897: SW : GPIO 0 Pulse set for 5 sec
972080: SW : GPIO=2 State=0 Output value=0
972082: EVENT: ESP_01-PIR#STATE=0.00
- Attachments
-
- LongpressEvent.jpg (39.54 KiB) Viewed 7932 times
Re: Rules same GPIO and Longpress event
What version of ESPEasy do you have installed?
The latest is always available from https://github.com/letscontrolit/ESPEasy/releases
The latest is always available from https://github.com/letscontrolit/ESPEasy/releases
/Ton (PayPal.me)
Re: Rules same GPIO and Longpress event
Try this rule set (untested):
- Thomas
Code: Select all
on System#Boot do
LongPulse,0,1,5
endon
if ESP_01-PIR#STATE=11 do // This was a 4 Sec Long press. Extend relay time.
LongPulse,0,0,21 // 4 Secs has already elapsed, add another 21 secs.
endon
on ESP_01-PIR#STATE=1 do // Button is pressed.
LongPulse,0,0,5
endon
Re: Rules same GPIO and Longpress event
Hello Thomas,
Many thanks for your help, but do not work.
Line 6: LongPulse,0,0,21 is not executed!
Regards
Otto
59189822: SW : GPIO=2 State=1 Output value=1
59189825: EVENT: ESP_01-PIR#STATE=1.00
59189836: ACT : LongPulse,0,0,5
59189838: Command: LongPulse
59189840: SW : GPIO 0 Pulse set for 5 sec
59192272: WD : Uptime 987 ConnectFailures 0 FreeMem 21384 WiFiStatus 3
59193822: SW : LongPress: GPIO= 2 State=1 Output value=11
59193825: EVENT: ESP_01-PIR#STATE=11.00
59195622: SW : GPIO=2 State=0 Output value=0
59195625: EVENT: ESP_01-PIR#STATE=0.00
Many thanks for your help, but do not work.
Line 6: LongPulse,0,0,21 is not executed!
Regards
Otto
59189822: SW : GPIO=2 State=1 Output value=1
59189825: EVENT: ESP_01-PIR#STATE=1.00
59189836: ACT : LongPulse,0,0,5
59189838: Command: LongPulse
59189840: SW : GPIO 0 Pulse set for 5 sec
59192272: WD : Uptime 987 ConnectFailures 0 FreeMem 21384 WiFiStatus 3
59193822: SW : LongPress: GPIO= 2 State=1 Output value=11
59193825: EVENT: ESP_01-PIR#STATE=11.00
59195622: SW : GPIO=2 State=0 Output value=0
59195625: EVENT: ESP_01-PIR#STATE=0.00
Re: Rules same GPIO and Longpress event
I'm using the following version : ESP_Easy_mega-20200426_normal_ESP8266_1M.bin
Re: Rules same GPIO and Longpress event
Just to be sure it isn't causing any issues, can you change the task name to not include a minus sign?
Re: Rules same GPIO and Longpress event
I think the if should be on:
And removing the minus from the name, as TD-er suggested, will also help (should be added as 'unsupported' to the name-check, IMHO).
Code: Select all
on ESP_01-PIR#STATE=11 do // This was a 4 Sec Long press. Extend relay time.
LongPulse,0,0,21 // 4 Secs has already elapsed, add another 21 secs.
endon
/Ton (PayPal.me)
Re: Rules same GPIO and Longpress event
I removed the minus and use the sample from Ath, now every thing work very well.
Thanks
Otto
Thanks
Otto
Re: Rules same GPIO and Longpress event
Oops. Thanks for catching my typo ("if" should be "on").I think the if should be on:
- Thomas
Re: Rules same GPIO and Longpress event
Hello Thomas,
Yes the if must be "on".
Now I have to complete my script. When I press 4 seconds, it puts a delay of 25 sec.
But if someone moves the PIR it puts the delay back to 5 sec.
Regards
Otto
Yes the if must be "on".
Now I have to complete my script. When I press 4 seconds, it puts a delay of 25 sec.
But if someone moves the PIR it puts the delay back to 5 sec.
Regards
Otto
Re: Rules same GPIO and Longpress event
You can solve that by raising a flag during the extended time:
Code: Select all
on System#Boot do
LongPulse,0,1,5
Let 1,0 // Reset flag
endon
on ESP_01PIR#STATE=11 do // This was a 4 Sec Long press. Extend relay time.
Let 1,1 // Raise flag
TimerSet 1,21
LongPulse,0,0,21 // 4 Secs has already elapsed, add another 21 secs.
endon
on ESP_01PIR#STATE=1 do // Button is pressed.
if %v1%=0 // Only if flag not raised
LongPulse,0,0,5
endif
endon
on Rules#Timer=1 do
Let 1,0 // Reset flag
endon
/Ton (PayPal.me)
Re: Rules same GPIO and Longpress event
Work well.
Many thanks for your help
Otto
Many thanks for your help
Otto
Who is online
Users browsing this forum: No registered users and 1 guest