Moderators: grovkillen, Stuntteam, TD-er
-
PizzaChip
- Normal user
- Posts: 11
- Joined: 24 Apr 2017, 18:19
#1
Post
by PizzaChip » 06 Dec 2017, 17:47
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...
-
grovkillen
- Core team member
- Posts: 3621
- Joined: 19 Jan 2017, 12:56
- Location: Hudiksvall, Sweden
#2
Post
by grovkillen » 06 Dec 2017, 19:11
You shouldn't use "normal switch" mode. Use one of the active high/low.
-
PizzaChip
- Normal user
- Posts: 11
- Joined: 24 Apr 2017, 18:19
#3
Post
by PizzaChip » 06 Dec 2017, 20:32
I tried both and didn't make a difference
-
vader
- Normal user
- Posts: 241
- Joined: 21 Mar 2017, 17:35
#4
Post
by vader » 06 Dec 2017, 20:33
That can not work. Try this...
on lightSwitch#Switch do
if [lightSwitch#Switch]=0
gpio,12,0
else
gpio,12,1
endif
endon
-
PizzaChip
- Normal user
- Posts: 11
- Joined: 24 Apr 2017, 18:19
#5
Post
by PizzaChip » 06 Dec 2017, 21:42
I see what you did there and I get it, but still it doesn't work..

-
vader
- Normal user
- Posts: 241
- Joined: 21 Mar 2017, 17:35
#6
Post
by vader » 06 Dec 2017, 21:47
Can you post all rules and some screenshots of your config?
-
PizzaChip
- Normal user
- Posts: 11
- Joined: 24 Apr 2017, 18:19
#7
Post
by PizzaChip » 06 Dec 2017, 21:58
There is only one rule and is the one posted above, config screenshots are the ones above
-
PizzaChip
- Normal user
- Posts: 11
- Joined: 24 Apr 2017, 18:19
#8
Post
by PizzaChip » 06 Dec 2017, 22:07
The button works, it stays on for approx 5 seconds and then it automatically turns off

-
vader
- Normal user
- Posts: 241
- Joined: 21 Mar 2017, 17:35
#9
Post
by vader » 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?
-
danmero
- Normal user
- Posts: 64
- Joined: 11 May 2017, 01:19
#10
Post
by danmero » 07 Dec 2017, 12:55
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,
-
vader
- Normal user
- Posts: 241
- Joined: 21 Mar 2017, 17:35
#11
Post
by vader » 07 Dec 2017, 13:23
@danmero: Where is the point that helps him and that we not already posted/suggested above?
BTW: TaskValueSet needs 3 values, not 2!
-
PizzaChip
- Normal user
- Posts: 11
- Joined: 24 Apr 2017, 18:19
#12
Post
by PizzaChip » 07 Dec 2017, 15:21
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
-
PizzaChip
- Normal user
- Posts: 11
- Joined: 24 Apr 2017, 18:19
#13
Post
by PizzaChip » 07 Dec 2017, 15:24
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
Who is online
Users browsing this forum: Ahrefs [Bot], Anthropic Claude Bot [bot] and 17 guests