Well, I just built your scenario, but I'm not sure you have stuff set up right:
- My led is on GPIO5, and it is active-low, not active-high as you seem to have (on high the GPIO doesn't deliver much current, though on low it can pull some current)
- My switches are set up as Normal Switch, with internal pull-up, and Inversed logic, shorting the GPIO to ground when closed. (IRL, you will need external pull-up resistors ~10k to avoid picking up spurious spikes)
My rules are now like this (I did remove the extra enter you had in one comment, I hope it is not in your actual code)
Code: Select all
On garage_close#Value=0 do
//blink
timerSet,1,1
endon
On garage_close#Value=1 do
// Light off
GPIO,13,1
//stop blinking
timerSet,1,0
endon
On garage_open#Value=0 do
//switch off light start blink
GPIO,13,1
timerSet,1,1
endon
On garage_open#Value=1 do
//switch off blink and light on
GPIO,13,0
timerSet,1,0
endon
//create an actual warning signal, every time timer 1 expires:
On Rules#Timer=1 do
//repeat after 1 seconds
timerSet,1,1
//pulse the led shortly, non-blocking
LongPulse_ms,13,0,400
endon
This works as follows:
Garage door closed: Light is off
Garage door is opening: Light blinks
Garage door is fully open: Light is on
Garage door is closing: Light blinks
An improvement could be to have 2 lights, orange for the current light, and green for a second light, that is turned on when the garage door is fully open, that would need these two events to be replaced by this code:
(Green light is on GPIO5, active low, orange light is on GPIO13, active low)
Code: Select all
On garage_open#Value=0 do
//switch off light start blink
GPIO,13,1
GPIO,5,1
timerSet,1,1
endon
On garage_open#Value=1 do
//switch off blink and light on
GPIO,13,1
GPIO,5,0
timerSet,1,0
endon
NB: Having 'Value' for the switches, instead of State, makes me wonder what version of ESPEasy you are using? I'd advise to take a current one form Github, like 20200410.
NB2: Having a switch on GPIO2 might get you in trouble, as that is used to put the ESP into one of its special modes during boot. Another GPIO should better be used like 3 or 5.
Edit: Updated to first turn on/off lights and then (re)set the timer.