Control relay with physical locally button
Moderators: grovkillen, Stuntteam, TD-er
Control relay with physical locally button
Hi Guys
I'use with success an relay with esp8266 + domoticz for controlling dry contact, I need to add a button locally like press physical button and relay change state without need network access, the best will be updated status in domoticz....
Not sure how to do that, if somebody as already experienced this kind of setup ?
Regard, Vic
I'use with success an relay with esp8266 + domoticz for controlling dry contact, I need to add a button locally like press physical button and relay change state without need network access, the best will be updated status in domoticz....
Not sure how to do that, if somebody as already experienced this kind of setup ?
Regard, Vic
- budman1758
- Normal user
- Posts: 303
- Joined: 15 Apr 2017, 05:13
- Location: Riverside CA USA
Re: Control relay with physical locally button
There are a few ways to make that happen. Mostly depends on your hardware. If you want a pushbutton switch you will need to set it up on another GPIO and set up a rule to toggle the relay. If using a on-off switch you can probably use it to control the relay and set up a task on the GPIO that controls the relay that monitors the high or low state of the pin.
The Wiki is your friend.....
https://www.letscontrolit.com/wiki/inde ... rial_Rules
https://www.letscontrolit.com/wiki/index.php/Switch
The Wiki is your friend.....
https://www.letscontrolit.com/wiki/inde ... rial_Rules
https://www.letscontrolit.com/wiki/index.php/Switch
"The glass is twice as big as it needs to be".
Re: Control relay with physical locally button
Ok I attached Momentary Button and expect toggle between on/off switch relay, any clue for rules ?
- grovkillen
- Core team member
- Posts: 3621
- Joined: 19 Jan 2017, 12:56
- Location: Hudiksvall, Sweden
- Contact:
Re: Control relay with physical locally button
Budman gave you the correct link.... But since you missed the info anyway, here you go - direct link : https://www.letscontrolit.com/wiki/inde ... long_press
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

ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you



Re: Control relay with physical locally button
I tried with this rules:
nothing work!
Here's my setup:
Device1
Device: Switch input
Name: Relay
Delay: 0
IDX/Var: 1
1st GPIO: GPIO-15
Pull UP: Yes
Inversed: No
Switch Type: Switch
Switch Button Type: Normal Switch
Send Boot State: Yes
Send Data: Yes
Value Name 1: Switch
Device2
Device: Switch input
Name: Button
Delay: 0
IDX/Var: 150
1st GPIO: GPIO-2
Pull UP: Yes
Inversed: No
Switch Type: Switch
Switch Button Type: Normal Switch
Send Boot State: No
Send Data: No
Value Name 1: Switch
Code: Select all
on Button#Status=1 do
if [Relay#Status]=0
gpio,15,0
else
gpio,15,1
endif
endon
Here's my setup:
Device1
Device: Switch input
Name: Relay
Delay: 0
IDX/Var: 1
1st GPIO: GPIO-15
Pull UP: Yes
Inversed: No
Switch Type: Switch
Switch Button Type: Normal Switch
Send Boot State: Yes
Send Data: Yes
Value Name 1: Switch
Device2
Device: Switch input
Name: Button
Delay: 0
IDX/Var: 150
1st GPIO: GPIO-2
Pull UP: Yes
Inversed: No
Switch Type: Switch
Switch Button Type: Normal Switch
Send Boot State: No
Send Data: No
Value Name 1: Switch
- grovkillen
- Core team member
- Posts: 3621
- Joined: 19 Jan 2017, 12:56
- Location: Hudiksvall, Sweden
- Contact:
Re: Control relay with physical locally button
Code: Select all
on Button#Status do
if [Button#Status]=1
gpio,15,0
else
gpio,15,1
endif
endon
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

ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you



Re: Control relay with physical locally button
tks Grovkillen for your help, rule doesn't work
I should see in the log rule started ?
I should see in the log rule started ?
Code: Select all
2180454 : WD : Uptime 36 ConnectFailures 0 FreeMem 22048
2185128 : SW : State 0
2185128 : EVENT: Button#Button=0.00
2186744 : SW : State 1
2186744 : EVENT: Button#Button=1.00
2198148 : SW : State 0
2198149 : EVENT: Button#Button=0.00
2199865 : SW : State 1
2199865 : EVENT: Button#Button=1.00
2210455 : WD : Uptime 37 ConnectFailures 0 FreeMem 22048
- grovkillen
- Core team member
- Posts: 3621
- Joined: 19 Jan 2017, 12:56
- Location: Hudiksvall, Sweden
- Contact:
Re: Control relay with physical locally button
You are naming the value "button" as well! Change value name to "status" as stated in the rule.
PS: GPIO 15 is not the best to use with relays (https://www.letscontrolit.com/wiki/inde ... figuration)
PS: GPIO 15 is not the best to use with relays (https://www.letscontrolit.com/wiki/inde ... figuration)
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

ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you



Re: Control relay with physical locally button
Awsome it's working, many tks Grovkillen.
So where I put the request for update the status in domoticz? something like that
So where I put the request for update the status in domoticz? something like that
Code: Select all
SendToHTTP 10.0.0.18:8080/json.htm?type=command¶m=udevice&idx=55&nvalue=1
- grovkillen
- Core team member
- Posts: 3621
- Joined: 19 Jan 2017, 12:56
- Location: Hudiksvall, Sweden
- Contact:
Re: Control relay with physical locally button
I'm not a Domoticz user but yes you may use a http command.
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

ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you



Re: Control relay with physical locally button
I have a strange character after "command" in the log and of course doesn't work
Code: Select all
15878769 : ACT : gpio,15,1
15878771 : SW : GPIO 15 Set to 1
15878776 : ACT : SendToHTTP 10.0.0.18:8080/json.htm?type=command¶m=udevice&idx=55&nvalue=0
- budman1758
- Normal user
- Posts: 303
- Joined: 15 Apr 2017, 05:13
- Location: Riverside CA USA
Re: Control relay with physical locally button
Try this as your sendto.....
SendToHTTP 10.0.0.18,8080,/json.htm?type=command¶m=udevice&idx=55&nvalue=0
SendToHTTP 10.0.0.18,8080,/json.htm?type=command¶m=udevice&idx=55&nvalue=0
"The glass is twice as big as it needs to be".
Re: Control relay with physical locally button
found in the wiki rules turnaround where is said to use this syntax I tried but nothing update in domoticz and
unfortunately I just want update the status not toggle the switch
Code: Select all
SendToHTTP 10.0.0.0,8080,/json.htm?type=param=switchlight&command&idx=55&switchcmd=On
unfortunately I just want update the status not toggle the switch
Re: Control relay with physical locally button
I do not think that you can update switch status without actually switching it...
Perhaps you can use Selector switch in domoticz, with different actions at different levels, or you can update a User variable, that you can manage in the Domoticz side in LUA.
In LUA then you can use "UpdateDevice".
Re: Control relay with physical locally button
yeah, got it working just use this syntax and all good
Code: Select all
SendToHTTP 10.0.0.18,8080,/json.htm?param=udevice&type=command&idx=55&nvalue=1
Re: Control relay with physical locally button
Put it next line after you change gpio status.
But I use different command:
You mus send command for report "off" status too
But I use different command:
Code: Select all
SendToHTTP 192.168.1.253,8080,/json.htm?type=command¶m=switchlight&idx=26&switchcmd=On
Code: Select all
SendToHTTP 192.168.1.253,8080,/json.htm?type=command¶m=switchlight&idx=26&switchcmd=Off
Who is online
Users browsing this forum: No registered users and 30 guests