help to create a rule for a toggle switch with espeasy

Everything about esp8266 and more.

Moderator: leecollings

Post Reply
reza
Posts: 112
Joined: Tuesday 13 September 2016 9:00
Target OS: Raspberry Pi / ODroid
Domoticz version: 2024.4
Contact:

help to create a rule for a toggle switch with espeasy

Post by reza »

hi friends.
please help me.
i want use a toggle switch (up-down) with relay. i use usual rules or usual setting but there is some problem.
i need 2 feature for relay control with espeasy. but i can not do it with rule , please help.
first , i want key work with relay locally , until when wifi is disconnect(for each reason) so we can on/off light handy.
second , i dont want relay on / off just with "key = 0" or "key = 1" . i want relay work with change state of toggle key.for example when light on with key (key up) then light off with domoticz app, so i want i can light on again with key but just one change state of toggle key (key down) .now if we light on/off with key and light off/on with app, so if we want again turn on with key , we must change 2 state (one up and one down) and this is bad. so i need help for a rule that we run this 2 feature in one rule .
thank you
Lebo2d9
Posts: 139
Joined: Tuesday 06 September 2016 20:39
Target OS: Raspberry Pi / ODroid
Domoticz version: L stab
Location: Belgium
Contact:

Re: help to create a rule for a toggle switch with espeasy

Post by Lebo2d9 »

You have to enable "rules" on your ESP and create a rule

maybe you can check also

https://www.letscontrolit.com/forum/vie ... php?t=1655

I don't have any experience with this
Domoicz on RPI3 (wifi) directly connected 3x ds18b20 for CV temp, Evohome (9 zone), 1 remote 220V switch based on ESP-12. RFXtrx433E, 16x AMST-606, 5 Somfy RTS motors
Domoticz on RPI3(wifi) as slave for terraruim control
More to come
User avatar
Herman-H
Posts: 35
Joined: Saturday 05 April 2014 22:10
Target OS: Linux
Domoticz version:
Contact:

Re: help to create a rule for a toggle switch with espeasy

Post by Herman-H »

In Domoticz:
http://192.168.0.120/control?cmd=event,toggle

In EspEasy:
On toggle do
if [Schemerlamp-1#Switch]=0
gpio,0,1 // Lamp on
else
gpio,0,0 // Lamp off
endif
EndOn

See this as an example, see of this works for your situation.
reza
Posts: 112
Joined: Tuesday 13 September 2016 9:00
Target OS: Raspberry Pi / ODroid
Domoticz version: 2024.4
Contact:

Re: help to create a rule for a toggle switch with espeasy

Post by reza »

Lebo2d9 wrote:You have to enable "rules" on your ESP and create a rule

maybe you can check also

https://www.letscontrolit.com/forum/vie ... php?t=1655

I don't have any experience with this
hi thank you for answer. i enable rules but i can not create this tule that i need. there is a problem in all of code in rules for toggling.

Code: Select all

if [key_1#Switch]=0
i dont have when key is 0 so do...
i want use a STATE and OLDSTATE for if . for example :

Code: Select all

if [key_1#Switch]=oldstate
so with a change state of key (up or down) relay will work. but when if key = 0 so just work with 0 so if key is 1 and is turn off with domoticz so we will 2 time up and down key for turn on. every time. so this is bad
reza
Posts: 112
Joined: Tuesday 13 September 2016 9:00
Target OS: Raspberry Pi / ODroid
Domoticz version: 2024.4
Contact:

Re: help to create a rule for a toggle switch with espeasy

Post by reza »

Lebo2d9 wrote:You have to enable "rules" on your ESP and create a rule

maybe you can check also

https://www.letscontrolit.com/forum/vie ... php?t=1655

I don't have any experience with this
hi thank you for answer. i enable rules but i can not create this tule that i need. there is a problem in all of code in rules for toggling.

Code: Select all

if [key_1#Switch]=0
i dont have when key is 0 so do...
i want use a STATE and OLDSTATE for if . for example :

Code: Select all

if [key_1#Switch]=oldstate
so with a change state of key (up or down) relay will work. but when if key = 0 so just work with 0 so if key is 1 and is turn off with domoticz so we will 2 time up and down key for turn on. every time. so this is bad
reza
Posts: 112
Joined: Tuesday 13 September 2016 9:00
Target OS: Raspberry Pi / ODroid
Domoticz version: 2024.4
Contact:

Re: help to create a rule for a toggle switch with espeasy

Post by reza »

Herman-H wrote:In Domoticz:
http://192.168.0.120/control?cmd=event,toggle

In EspEasy:
On toggle do
if [Schemerlamp-1#Switch]=0
gpio,0,1 // Lamp on
else
gpio,0,0 // Lamp off
endif
EndOn

See this as an example, see of this works for your situation.
i think this is not work for once push key (up or down) but i will test, just one question , in domoticz use this command for both on/off action?
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest