Control relay with physical locally button

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
QcVictor
Normal user
Posts: 46
Joined: 23 Feb 2016, 00:47

Control relay with physical locally button

#1 Post by QcVictor » 16 Nov 2017, 23:22

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

User avatar
budman1758
Normal user
Posts: 301
Joined: 15 Apr 2017, 05:13
Location: Riverside CA USA

Re: Control relay with physical locally button

#2 Post by budman1758 » 17 Nov 2017, 04:31

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 glass is twice as big as it needs to be".

QcVictor
Normal user
Posts: 46
Joined: 23 Feb 2016, 00:47

Re: Control relay with physical locally button

#3 Post by QcVictor » 17 Nov 2017, 16:43

Ok I attached Momentary Button and expect toggle between on/off switch relay, any clue for rules ?

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

Re: Control relay with physical locally button

#4 Post by grovkillen » 17 Nov 2017, 16:54

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

QcVictor
Normal user
Posts: 46
Joined: 23 Feb 2016, 00:47

Re: Control relay with physical locally button

#5 Post by QcVictor » 17 Nov 2017, 18:06

I tried with this rules:

Code: Select all

on Button#Status=1 do
  if [Relay#Status]=0
    gpio,15,0
  else
    gpio,15,1
  endif
endon
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

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

Re: Control relay with physical locally button

#6 Post by grovkillen » 17 Nov 2017, 18:47

Code: Select all

on Button#Status do
  if [Button#Status]=1
    gpio,15,0
  else
    gpio,15,1
  endif
endon
The relay doesn't need to be a device. Please study the wiki.
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:

QcVictor
Normal user
Posts: 46
Joined: 23 Feb 2016, 00:47

Re: Control relay with physical locally button

#7 Post by QcVictor » 17 Nov 2017, 19:41

tks Grovkillen for your help, rule doesn't work
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

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

Re: Control relay with physical locally button

#8 Post by grovkillen » 17 Nov 2017, 20:09

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

QcVictor
Normal user
Posts: 46
Joined: 23 Feb 2016, 00:47

Re: Control relay with physical locally button

#9 Post by QcVictor » 17 Nov 2017, 22:26

Awsome it's working, many tks Grovkillen.
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&param=udevice&idx=55&nvalue=1

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

Re: Control relay with physical locally button

#10 Post by grovkillen » 17 Nov 2017, 22:48

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

QcVictor
Normal user
Posts: 46
Joined: 23 Feb 2016, 00:47

Re: Control relay with physical locally button

#11 Post by QcVictor » 17 Nov 2017, 23:38

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

User avatar
budman1758
Normal user
Posts: 301
Joined: 15 Apr 2017, 05:13
Location: Riverside CA USA

Re: Control relay with physical locally button

#12 Post by budman1758 » 18 Nov 2017, 01:14

Try this as your sendto.....

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

QcVictor
Normal user
Posts: 46
Joined: 23 Feb 2016, 00:47

Re: Control relay with physical locally button

#13 Post by QcVictor » 18 Nov 2017, 01:25

found in the wiki rules turnaround where is said to use this syntax

Code: Select all

 SendToHTTP 10.0.0.0,8080,/json.htm?type=param=switchlight&command&idx=55&switchcmd=On
I tried but nothing update in domoticz and
unfortunately I just want update the status not toggle the switch

User avatar
enesbcs
Normal user
Posts: 587
Joined: 18 Jun 2017, 11:02
Location: Békéscsaba, Hungary
Contact:

Re: Control relay with physical locally button

#14 Post by enesbcs » 18 Nov 2017, 07:28

QcVictor wrote: 18 Nov 2017, 01:25 unfortunately I just want update the status not toggle the switch
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".

QcVictor
Normal user
Posts: 46
Joined: 23 Feb 2016, 00:47

Re: Control relay with physical locally button

#15 Post by QcVictor » 18 Nov 2017, 14:35

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

kimot
Normal user
Posts: 190
Joined: 12 Oct 2017, 20:46

Re: Control relay with physical locally button

#16 Post by kimot » 21 Nov 2017, 23:44

Put it next line after you change gpio status.
But I use different command:

Code: Select all

SendToHTTP 192.168.1.253,8080,/json.htm?type=command&param=switchlight&idx=26&switchcmd=On
You mus send command for report "off" status too

Code: Select all

SendToHTTP 192.168.1.253,8080,/json.htm?type=command&param=switchlight&idx=26&switchcmd=Off

Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 117 guests