ESP Easy rule to enable button

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
PizzaChip
Normal user
Posts: 11
Joined: 24 Apr 2017, 18:19

ESP Easy rule to enable button

#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:

Image

LightSwitch is configured as:
Image

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...

User avatar
grovkillen
Core team member
Posts: 3157
Joined: 19 Jan 2017, 12:56
Location: Hudiksvall, Sweden
Contact:

Re: ESP Easy rule to enable button

#2 Post by grovkillen » 06 Dec 2017, 19:11

You shouldn't use "normal switch" mode. Use one of the active high/low.
ESP Easy Flasher [flash tool and wifi setup at flash time]
ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you :idea: :idea: :idea:

PizzaChip
Normal user
Posts: 11
Joined: 24 Apr 2017, 18:19

Re: ESP Easy rule to enable button

#3 Post by PizzaChip » 06 Dec 2017, 20:32

I tried both and didn't make a difference

User avatar
vader
Normal user
Posts: 241
Joined: 21 Mar 2017, 17:35

Re: ESP Easy rule to enable button

#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

Re: ESP Easy rule to enable button

#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.. :cry:

User avatar
vader
Normal user
Posts: 241
Joined: 21 Mar 2017, 17:35

Re: ESP Easy rule to enable button

#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

Re: ESP Easy rule to enable button

#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

Re: ESP Easy rule to enable button

#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 :cry: :oops:

User avatar
vader
Normal user
Posts: 241
Joined: 21 Mar 2017, 17:35

Re: ESP Easy rule to enable button

#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

Re: ESP Easy rule to enable button

#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,

User avatar
vader
Normal user
Posts: 241
Joined: 21 Mar 2017, 17:35

Re: ESP Easy rule to enable button

#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

Re: ESP Easy rule to enable button

#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

Re: ESP Easy rule to enable button

#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
Image

LIGHTSWITCH
Image


RULE

Code: Select all

on lightSwitch#Switch do
if [lightSwitch#Switch]=0
gpio,12,1
else
gpio,12,0
endif
endon

Post Reply

Who is online

Users browsing this forum: No registered users and 3 guests