"push button active high" swith to 0 with Rules
Moderators: grovkillen, Stuntteam, TD-er
"push button active high" swith to 0 with Rules
Hello,
I have a switch of type "push button active high" named "DELAY" on the GPIO-14.
When I press this button, I change a "state" value from 0 to 1 or vice versa.
How can I also set this "state" value to 0 using a ruler?
I tried with:
1. DELAY#State=0
2. GPIO,14,0
but both don't work
I have a switch of type "push button active high" named "DELAY" on the GPIO-14.
When I press this button, I change a "state" value from 0 to 1 or vice versa.
How can I also set this "state" value to 0 using a ruler?
I tried with:
1. DELAY#State=0
2. GPIO,14,0
but both don't work
Re: "push button active high" swith to 0 with Rules
I am not sure what you want to archive but your code should be wrapped in a rules block "ON...DO...Endon"
Code: Select all
On Delay#State=0 Do
GPIO,14,0
Endon
Re: "push button active high" swith to 0 with Rules
You may try to check the checkbox on the tools->Advanced page to allow TaskValueSet on tasks other than "dummy" and then call from the rules:
Where X is the task index of your switch task. (task nr as shown on the "devices" tab, left column)
Code: Select all
taskvalueset,X,1,0
Re: "push button active high" swith to 0 with Rules
Many thanks for you help.
I checked the following box:
AllowTaskValueSet on all Plugins:
At the end of my rule I have now added the line :
With this command "taskvalueset,6,1,0" it works fine. The DOOR#State value on the device tab Task number 6 changes from 1 to zero.
The only strange problem when I press my "DELAY" button on the GPIO-14, it doesn't activate the first time so that the value changes back to 1.
I have to press it twice.
I checked the following box:
AllowTaskValueSet on all Plugins:
At the end of my rule I have now added the line :
Code: Select all
...
On DOOR#State=1 do // Door closed
lcdcmd,clear
LCD,2,1,"Die Tor ist zu"
TimerSet,1,0 // Stop Loops
TimerSet,2,0 // Stop Repeat
taskvalueset,6,1,0
Endon
The only strange problem when I press my "DELAY" button on the GPIO-14, it doesn't activate the first time so that the value changes back to 1.
I have to press it twice.
Re: "push button active high" swith to 0 with Rules
Is this only on the first attempt, when booted ESPEasy?
Or do you need to do this always?
Or do you need to do this always?
Re: "push button active high" swith to 0 with Rules
Yes, I would like it to work always.
I don't think the variant with "taskvalueset" is the best. I'm new to EspEasy, I have the impression that the "taskvalueset" function changes a memory value and not the value stored in the GPIO14.
I set the button connected to the GPIO14 to "Switch Button Type:" as follows: "Push Button Active High". This changes the value at each push. So far it works well.
But I would like that when I enter my final function that the value returns to zero.
I also have another strange problem with this "Delay#State" button.
With : If [Delay#State]=0 the if is not interpreted correctly:
But the following example with on and endon work well:
I don't think the variant with "taskvalueset" is the best. I'm new to EspEasy, I have the impression that the "taskvalueset" function changes a memory value and not the value stored in the GPIO14.
I set the button connected to the GPIO14 to "Switch Button Type:" as follows: "Push Button Active High". This changes the value at each push. So far it works well.
But I would like that when I enter my final function that the value returns to zero.
I also have another strange problem with this "Delay#State" button.
With : If [Delay#State]=0 the if is not interpreted correctly:
Code: Select all
on Door#State=0 do // Door is open
event,Progress
LCD,1,1,""
LCD,2,1, "Die Tor ist offen"
If [Delay#State]=0 // Button Delay
LCD,4,1, "Pause AUS"
let 2,5 // Long Time Bar 5s
else
LCD,4,1, "Pause EIN"
let 2,20 // Long Time Bar 20s
end
event,Progress
endon
This always displays: LCD,4,1, "Pause AUS"
Code: Select all
on Delay#State=1 do // Delay Button
LCD,4,1, "Pause EIN"
let 2,5 // Long Time Bar 20s
event,Progress
endon
Re: "push button active high" swith to 0 with Rules
Can you show your entire rules? As by showing only some changing parts of it it gets more and more confusing.
Also showing how your devices list is set up would be helpful, especially the Switch configuration
Also showing how your devices list is set up would be helpful, especially the Switch configuration
/Ton (PayPal.me)
Re: "push button active high" swith to 0 with Rules
Here the entire rules?
Code: Select all
on System#Boot do
AsyncEvent,PIR#State=[PIR#State] // Let the PIR eventhandler take care of the logic
endon
on Door#State=0 do // Door is open
event,Progress
LCD,1,1,""
LCD,2,1,"Die Tor ist offen"
If [Delay#State]=0 // Button Delay
LCD,4,1,"Pause AUS"
let 2,1 // Long Time Bar 20s
else
LCD,4,1,"Pause EIN"
let 2,5 // Long Time Bar 20s
end
event,Progress
endon
on Progress do
let 1,%eventvalue1|20% // Display with 20 characters
LoopTimerSet,1,%v2%,%v1% // Repeat timer 1 every x sec. for n times
endon
on Rules#Timer=1 do
LCD,1,1,{substring:0:%eventvalue2%:********************} // Timer Line 1
if %eventvalue2%=%v1% // Have we reached 100%?
lcdcmd,clear
LCD,1,1,"Die Tor geht zu!"
Pulse,27,1,400 // Pulse on GIPO 27 to close the Door
TimerSet,2,10 // Timer to check it door closed after 10s else repeat
endif
endon
On Rules#Timer=2 do // Door timer
if [Door#State]=0 // Door still open?
LCD,1,1,"Tor schliessung !.."
Pulse,27,1,400 // Pulse on GIPO 27 to close the Door
TimerSet,2,10 // Repeat timer 2 until door closed
else
TimerSet,2,0 // Stop timer 2
endif
endon
on PIR#state do // Will be triggered when PIR state changes
if [Door#State]=0 // Door open?
if %eventvalue1%=1
TimerSet,1,0 // Stop countdown
LCD,1,1,"ACHTUNG PIR Meldung!"
notify 1 //Send Email
TimerSet,2,0 // Stop Repeat
else // No movement on PIR
AsyncEvent,Progress // Using default
endif
endif
endon
On DOOR#State=1 do // Door closed
lcdcmd,clear
LCD,2,1,"Die Tor ist zu"
TimerSet,1,0 // Stop Loops
TimerSet,2,0 // Stop Repeat
// taskvalueset,6,1,0
Endon
Re: "push button active high" swith to 0 with Rules
Please have a look at this documentation page:
https://espeasy.readthedocs.io/en/lates ... e-on-esp32
It shows you the best pins to use on an ESP32 and remarks why some pins may not be the best option for some applications.
Do you have pull-up resistors present on the pins?
Pin 17 is a bit tricky as it may in some circumstances show "funky" behavior. See the special notes on that page I linked.
https://espeasy.readthedocs.io/en/lates ... e-on-esp32
It shows you the best pins to use on an ESP32 and remarks why some pins may not be the best option for some applications.
Do you have pull-up resistors present on the pins?
Pin 17 is a bit tricky as it may in some circumstances show "funky" behavior. See the special notes on that page I linked.
Re: "push button active high" swith to 0 with Rules
Thanks again for your patience with my problem.
Yes, I have a resitor with 4.6kOhm. But pull-down.
Like this : I changed the GPIO-17 to GPIO-25 and GPIO-14 to GPIO26. But I still have the above mentioned issues!
Yes, I have a resitor with 4.6kOhm. But pull-down.
Like this : I changed the GPIO-17 to GPIO-25 and GPIO-14 to GPIO26. But I still have the above mentioned issues!
Re: "push button active high" swith to 0 with Rules
Why are you using it as a pull down resistor?
Typically switches are configured with pull-up resistors and the switch then pulls it down.
Not sure if it really makes a difference here, with regards to picking up noise which may trigger false pulses.
Anyway, Since you're using a push button, pressing it may trigger several pulses.
So you should have the debounce filter enabled with something like 50 or 100 msec.
Do you have this debounce enabled?
Typically switches are configured with pull-up resistors and the switch then pulls it down.
Not sure if it really makes a difference here, with regards to picking up noise which may trigger false pulses.
Anyway, Since you're using a push button, pressing it may trigger several pulses.
So you should have the debounce filter enabled with something like 50 or 100 msec.
Do you have this debounce enabled?
Re: "push button active high" swith to 0 with Rules
OK, I'm going to change in the future to pull-up. I found this example somewhere on the web.
I also realized my logical error. In fact, with the on / endon command, this is only executed when there is a change, not all the time. This is the reason why my if "If [Delay#State]=0"
inside is not evaluated.
Now I just need to find a way to set the [Delay#State] to zero without having to press the button.
I also realized my logical error. In fact, with the on / endon command, this is only executed when there is a change, not all the time. This is the reason why my if "If [Delay#State]=0"
inside is not evaluated.
Now I just need to find a way to set the [Delay#State] to zero without having to press the button.
Re: "push button active high" swith to 0 with Rules
What's the intent of that Delay button?
NB: You can use a Dummy device to store 1..4 values, or use the Let command to set an internal variable that can be referenced via [VAR#n] or %Vn%, where n is the number you used in the Let command (1..MAXINT).
NB: You can use a Dummy device to store 1..4 values, or use the Let command to set an internal variable that can be referenced via [VAR#n] or %Vn%, where n is the number you used in the Let command (1..MAXINT).
/Ton (PayPal.me)
Re: "push button active high" swith to 0 with Rules
I have read your idea on the basis of Dummy variables. And this was the right solution for me. Thanks again.
The script has also become simpler with the Dummy variable.
Now everything works perfectly here is the explanation of the Script:
The purpose of the script is to manage the automatic closing of the garage door. The motorization is based on the system of the company Sommer. The script should react when the door is opened (GPIO-25 changes from 0 to 1). At this point Timer 1 starts with the display of a 20-digit progress bar (star display). If motion is detected by the PIR sensor. The progress bar is reset to zero. The space between each character is 10 seconds. This means that if no movement disturbs the progress bar, a relay closure over 400ms is activated (relay controlled by GPIO-27). At the same time Timer 2 is activated for 20 seconds. The closing signal is restarted periodically as long as the door is not closed. To extend the waiting time of the automatic closing, a button placed on GPIO-26 changes the value stored in the Dummy memory of Task 5. The time of the progress bar increases between each character to 40s. This is about 40sx20c =800 seconds / a little more than 6 minutes. Once the door is closed, the default value of Task 5 is reset and the timers are reset.
However, I still have many confusion about how the Rules work with ESPEasy!
The script has also become simpler with the Dummy variable.
Code: Select all
on System#Boot do
TaskValueSet 5,1,10
AsyncEvent,PIR#State=[PIR#State] // Let the PIR eventhandler take care of the logic
endon
on Door#State=0 do // Door is open
TimerSet,1,0 // Stop Loops
event,Progress
LCD,1,1,""
LCD,2,1,"Das Tor ist offen"
endon
on DelayButton#State=1 do // Set Delay ON
TaskValueSet 5,1,40 // Slow Prog.Bar 40s
event,Progress
LCD,4,1,"Pause ist EIN"
endon
on Progress do
let 1,%eventvalue1|20% // Display with 20 characters
LoopTimerSet,1,[Delay#Value],%v1% // Repeat timer 1 every x sec. for n times
endon
on Rules#Timer=1 do
LCD,1,1,{substring:0:%eventvalue2%:********************} // Timer Line 1
// LCD,4,1,%eventvalue2%[Delay#Value]
if %eventvalue2%=%v1% // Have we reached 100%?
lcdcmd,clear
LCD,1,1,"Die Tor geht zu!"
Pulse,27,1,400 // Pulse on GIPO 27 to close the Door
TimerSet,2,10 // Timer to check it door closed after 10s else repeat
endif
endon
On Rules#Timer=2 do // Door timer
if [Door#State]=0 // Door still open?
LCD,1,1,"Tor schliessung !.."
Pulse,27,1,400 // Pulse on GIPO 27 to close the Door
TimerSet,2,10 // Repeat timer 2 until door closed
else
TimerSet,2,0 // Stop timer 2
endif
endon
on PIR#state do // Will be triggered when PIR state changes
if [Door#State]=0 // Door open?
if %eventvalue1%=1
TimerSet,1,0 // Stop countdown
LCD,1,1,"ACHTUNG PIR Meldung!"
notify 1 //Send Email
AsyncEvent,Progress // Using default
endif
endif
endon
On DOOR#State=1 do // Door closed
lcdcmd,clear
LCD,2,1,"Das Tor ist zu"
TimerSet,1,0 // Stop Loops
TimerSet,2,0 // Stop Repeat
TaskValueSet 5,1,10
Endon
The purpose of the script is to manage the automatic closing of the garage door. The motorization is based on the system of the company Sommer. The script should react when the door is opened (GPIO-25 changes from 0 to 1). At this point Timer 1 starts with the display of a 20-digit progress bar (star display). If motion is detected by the PIR sensor. The progress bar is reset to zero. The space between each character is 10 seconds. This means that if no movement disturbs the progress bar, a relay closure over 400ms is activated (relay controlled by GPIO-27). At the same time Timer 2 is activated for 20 seconds. The closing signal is restarted periodically as long as the door is not closed. To extend the waiting time of the automatic closing, a button placed on GPIO-26 changes the value stored in the Dummy memory of Task 5. The time of the progress bar increases between each character to 40s. This is about 40sx20c =800 seconds / a little more than 6 minutes. Once the door is closed, the default value of Task 5 is reset and the timers are reset.
However, I still have many confusion about how the Rules work with ESPEasy!
Who is online
Users browsing this forum: Bing [Bot] and 12 guests