Page 1 of 1
ESP Easy rule to enable button
Posted: 06 Dec 2017, 17:47
by PizzaChip
In the past someone posted a rule to enable the switching ON/OFF by pressing the button on Sonoff 10A but for some reason the rule partially works meaning that it turns on the light but then it automatically turns it off after some seconds and I do not understand why....
in ESP EASY v 12 I have the following devices:
LightSwitch is configured as:
Rule is:
on lightSwitch#Switch do
if [lightState#Switch]=0
gpio,12,1
else
gpio,12,0
endif
endon
Why does it automatically turn off I really have no clue...
Re: ESP Easy rule to enable button
Posted: 06 Dec 2017, 19:11
by grovkillen
You shouldn't use "normal switch" mode. Use one of the active high/low.
Re: ESP Easy rule to enable button
Posted: 06 Dec 2017, 20:32
by PizzaChip
I tried both and didn't make a difference
Re: ESP Easy rule to enable button
Posted: 06 Dec 2017, 20:33
by vader
That can not work. Try this...
on lightSwitch#Switch do
if [lightSwitch#Switch]=0
gpio,12,0
else
gpio,12,1
endif
endon
Re: ESP Easy rule to enable button
Posted: 06 Dec 2017, 21:42
by PizzaChip
I see what you did there and I get it, but still it doesn't work..
Re: ESP Easy rule to enable button
Posted: 06 Dec 2017, 21:47
by vader
Can you post all rules and some screenshots of your config?
Re: ESP Easy rule to enable button
Posted: 06 Dec 2017, 21:58
by PizzaChip
There is only one rule and is the one posted above, config screenshots are the ones above
Re: ESP Easy rule to enable button
Posted: 06 Dec 2017, 22:07
by PizzaChip
The button works, it stays on for approx 5 seconds and then it automatically turns off
Re: ESP Easy rule to enable button
Posted: 07 Dec 2017, 08:58
by vader
Where do you see screenshots above? Have you checked the log, if there is something to see what the reason could be?
Re: ESP Easy rule to enable button
Posted: 07 Dec 2017, 12:55
by danmero
PizzaChip wrote: ↑06 Dec 2017, 17:47
Rule is:
on lightSwitch#Switch do
if [lightState#Switch]=0
gpio,12,1
else
gpio,12,0
endif
endon
Why does it automatically turn off I really have no clue...
You want to use a momentary switch to toggle a gpio
Try this
Code: Select all
on lightSwitch#Switch do
if [lightSwitch#Switch]=0
event myevent
endif
endon
on myevent do
if [lightState#Switch]=0
gpio,12,1
else
gpio,12,0
endif
endon
or
Code: Select all
on lightSwitch#Switch do
if [lightSwitch#Switch]=0
event myevent
endif
endon
on myevent do
if [lightState#Switch]=0
TaskValueSet 2,1
else
TaskValueSet 2,0
endif
endon
or
Code: Select all
On lightSwitch#Switch do
if [lightSwitch#Switch]=0
event MyEvent
Endif
Endon
On MyEvent do
if [lightState#Switch]=0
InputSwitchState 1,1
else
InputSwitchState 1,0
endif
Endon
Regards,
Re: ESP Easy rule to enable button
Posted: 07 Dec 2017, 13:23
by vader
@danmero: Where is the point that helps him and that we not already posted/suggested above?
BTW: TaskValueSet needs 3 values, not 2!
Re: ESP Easy rule to enable button
Posted: 07 Dec 2017, 15:21
by PizzaChip
I tried using the event and it behaves the same, it turns on and stays on for some 5/6 seconds and then turns off
Re: ESP Easy rule to enable button
Posted: 07 Dec 2017, 15:24
by PizzaChip
vader wrote: ↑07 Dec 2017, 08:58
Where do you see screenshots above? Have you checked the log, if there is something to see what the reason could be?
DEVICES
LIGHTSWITCH
RULE
Code: Select all
on lightSwitch#Switch do
if [lightSwitch#Switch]=0
gpio,12,1
else
gpio,12,0
endif
endon