Toggle a relais / relay for 1 second over MQTT?
Moderators: grovkillen, Stuntteam, TD-er
Toggle a relais / relay for 1 second over MQTT?
Hi guys:
I'm relatively new to espeasy, and must say it is really great.
I've gone through the forum in hopes of being able to control my garage door over MQTT, but can't seem to get a rule right to pulse / toggle a relay for 500ms, or even 1 second to simulate a button press. I am running espeasy v2.0.0-dev10, on a Wemos D1 Mini with a relay connected to GPIO 5. If I issue an http command as in:
http://192.168.0.xxx/control?cmd=Pulse,5,1,500
The relay pulses quickly to simulate a pulse / button press on the garage control, but I can't seem to get this going with any rules over MQTT. I also have a reed switch connected on GPIO 12 also to indicate status of the door, ( either opened or closed ), and have seen a few posts such as this one:
https://www.letscontrolit.com/forum/vie ... 9&start=20
and have tried the following rule, but it will not pulse the relay with the v2.0.0-dev10 code:
""
on button#state do
if [relay#state] = 0
GPIO,12,1
else
GPIO,12,0
endif
endon
on relay#state do
if [relay#state] = 1
gpio,13,0
else
gpio,13,1
endif
endon
on relay#state do
if [relay#state] = 1
Publish /sonoff2/gpio/12,1
else
Publish /sonoff2/gpio/12,0
endif
endon
""
can anyone please help with a rule to pulse a relay for 500ms or 1 second to simulate a button press?
Thanks very much!
I'm relatively new to espeasy, and must say it is really great.
I've gone through the forum in hopes of being able to control my garage door over MQTT, but can't seem to get a rule right to pulse / toggle a relay for 500ms, or even 1 second to simulate a button press. I am running espeasy v2.0.0-dev10, on a Wemos D1 Mini with a relay connected to GPIO 5. If I issue an http command as in:
http://192.168.0.xxx/control?cmd=Pulse,5,1,500
The relay pulses quickly to simulate a pulse / button press on the garage control, but I can't seem to get this going with any rules over MQTT. I also have a reed switch connected on GPIO 12 also to indicate status of the door, ( either opened or closed ), and have seen a few posts such as this one:
https://www.letscontrolit.com/forum/vie ... 9&start=20
and have tried the following rule, but it will not pulse the relay with the v2.0.0-dev10 code:
""
on button#state do
if [relay#state] = 0
GPIO,12,1
else
GPIO,12,0
endif
endon
on relay#state do
if [relay#state] = 1
gpio,13,0
else
gpio,13,1
endif
endon
on relay#state do
if [relay#state] = 1
Publish /sonoff2/gpio/12,1
else
Publish /sonoff2/gpio/12,0
endif
endon
""
can anyone please help with a rule to pulse a relay for 500ms or 1 second to simulate a button press?
Thanks very much!
Re: Toggle a relais / relay for 1 second over MQTT?
Also, here are my devices:
- grovkillen
- Core team member
- Posts: 3621
- Joined: 19 Jan 2017, 12:56
- Location: Hudiksvall, Sweden
- Contact:
Re: Toggle a relais / relay for 1 second over MQTT?
Code: Select all
on button#state do
if [relay#state]=0
Pulse,12,1,500
else
GPIO,12,0
endif
endon
on relay#state do
if [relay#state]=1
GPIO,13,0
Publish /sonoff2/gpio/12,1
else
GPIO,13,1
Publish /sonoff2/gpio/12,0
endif
endon
PS. I don't see a "button" as a device in the screenshot? It is somewhat hard to grip what you are trying to do here so please give as much information as possible. Some garage doors has the possibility to just add a switch which will just short two io. I don't think that need to be pulsed more than a reasonable time, this would do:
GPIO,12,1
Delay 1000
GPIO,12,0
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: Toggle a relais / relay for 1 second over MQTT?
Hi grovkillen. Thank you very much for your reply! Basically, what I am trying to do is connect a relay to my garage door button, inline with the existing two wires to simulate the press on the garage door opener, I have a relay on GPIO-5, and a reed switch on GPIO-12 that determines if the door is open or closed. Below is the screenshot of the devices, and how the relay is currently configured. I did try your code example without any luck. I am NOT using a sonoff device, but just a standard relay.
- grovkillen
- Core team member
- Posts: 3621
- Joined: 19 Jan 2017, 12:56
- Location: Hudiksvall, Sweden
- Contact:
Re: Toggle a relais / relay for 1 second over MQTT?
Code: Select all
on button#state do
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: Toggle a relais / relay for 1 second over MQTT?
Thanks grovkillen. appreciated. Any idea what the code might look like based on the devices attached to pulse the relay momentarily for 500ms over MQTT? The following http command works great: http://192.168.0.145/control?cmd=Pulse,5,1,500
Just need to find a way or rule to get it to pulse when a 1 is received over MQTT
Just need to find a way or rule to get it to pulse when a 1 is received over MQTT
- grovkillen
- Core team member
- Posts: 3621
- Joined: 19 Jan 2017, 12:56
- Location: Hudiksvall, Sweden
- Contact:
Re: Toggle a relais / relay for 1 second over MQTT?
You can send that command over MQTT as well.
Topic
Payload (message)
Topic
Code: Select all
<your_device_name>/cmd
Code: Select all
Pulse,5,1,500
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: Toggle a relais / relay for 1 second over MQTT?
What I learnt moving to V2.0.0 is that you need to add 'MQTT Input' as a device to set a topic. And of cource Controller subscripe/publish if you want to have a feedback of the Relay-status. I use this little rule
to get this feedback. Hope this helps.on mqtt_relay#state do
if [mqtt_relay#state]=0
gpio,5,0
else
gpio,5,1
endif
endon
- grovkillen
- Core team member
- Posts: 3621
- Joined: 19 Jan 2017, 12:56
- Location: Hudiksvall, Sweden
- Contact:
Re: Toggle a relais / relay for 1 second over MQTT?
https://www.letscontrolit.com/wiki/inde ... _2.0.2B.29werner_g wrote: ↑10 Jul 2017, 13:08 What I learnt moving to V2.0.0 is that you need to add 'MQTT Input' as a device to set a topic. And of cource Controller subscripe/publish if you want to have a feedback of the Relay-status. I use this little ruleto get this feedback. Hope this helps.on mqtt_relay#state do
if [mqtt_relay#state]=0
gpio,5,0
else
gpio,5,1
endif
endon
If your have set up the controller setting to subscribe to <unit name>/# you can send pretty much any command from this list:
https://www.letscontrolit.com/wiki/inde ... _Reference
Just use this topic: <unit name>/cmd
Work this payload/message: Pulse,5,1,500
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: Toggle a relais / relay for 1 second over MQTT?
I am wondering why this doesn't work here (PiDome MQTT):
the relay is not switching!
Code: Select all
Controller Subscribe: any/set/WM/Relay01/#
Controller Publish: any/state/WM/%sysname%
Topic: any/set/WM/Relay01/cmd
payload: GPIO,5,1
- grovkillen
- Core team member
- Posts: 3621
- Joined: 19 Jan 2017, 12:56
- Location: Hudiksvall, Sweden
- Contact:
Re: Toggle a relais / relay for 1 second over MQTT?
Does this work?werner_g wrote: ↑11 Jul 2017, 18:50 I am wondering why this doesn't work here (PiDome MQTT):the relay is not switching!Code: Select all
Controller Subscribe: any/set/WM/Relay01/# Controller Publish: any/state/WM/%sysname% Topic: any/set/WM/Relay01/cmd payload: GPIO,5,1
Code: Select all
Topic: any/set/WM/Relay01/cmd
payload: reboot
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



- grovkillen
- Core team member
- Posts: 3621
- Joined: 19 Jan 2017, 12:56
- Location: Hudiksvall, Sweden
- Contact:
Re: Toggle a relais / relay for 1 second over MQTT?
And you need the subscription topic to be a none default one?
If you subscribe to the default one:
And then send the <name of unit>/cmd with payload gpio,5,1 still doesn't work?
Just to try I mean...
If you subscribe to the default one:
Code: Select all
%sysname%/#
Just to try I mean...
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: Toggle a relais / relay for 1 second over MQTT?
quite funny, I tried several things, at least changing again to OpenHAB-MQTT and now it works like it has to do:
But still 'cmd Reboot' doesn't work. Not the showstopper, I'm happy it is now working the standard way without adding the device 'MQTT Import'Controller Subscribe: any/set/WM/Relay01/#
Controller Publish: any/state/WM/%sysname%
any/set/WM/Relay01/cmd
GPIO,5,1
- grovkillen
- Core team member
- Posts: 3621
- Joined: 19 Jan 2017, 12:56
- Location: Hudiksvall, Sweden
- Contact:
Re: Toggle a relais / relay for 1 second over MQTT?
Good that it works now. What version are you on?
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: Toggle a relais / relay for 1 second over MQTT?
v2.0.0-dev10
Who is online
Users browsing this forum: No registered users and 20 guests