Daveps
(Dave)
November 7, 2016, 6:42pm
1
Hi All,
I need a momentary pulse from a GPIO pin on an ESP8266 running ESPeasy to set or reset my workshop alarm.
Using the line below in items file the GPIO toggles OK,could someone please edit my config below to show me how to implement autoupdate=“false” I tried this but either the GPIO did not change state or it went high and stayed like that.
Sitemap
Switch item=Wshop_Alarm label=“Workshop Alarm”
Items
Switch Wshop_Alarm {mqtt=">[mymosquitto:/Workshop_1/gpio/2:command:ON:1],>[mymosquitto:/Workshop_1/gpio/2:command:OFF:0]"}
Thanks
Dave
sihui
(SiHui)
November 7, 2016, 8:24pm
2
Try adding the state as input:
Switch Wshop_Alarm {mqtt=">[mymosquitto:/Workshop_1/gpio/2:command:ON:1],>[mymosquitto:/Workshop_1/gpio/2:command:OFF:0],<[mymosquitto:/Workshop_1/gpio/2:state:default]"}
Instead of trying to solve this in Openhab you could try setting up ESP easy to handle the momentary part.
I use this for my doorbell using MQTT… pressed once this makes the switch in OpenHAB turn ON and OFF again.
see screenshot for ESP easy setup:
The MQTT item setup in Openhab would look like this ( only looking at topic state!)
{mqtt="<[broker:/Home/Hall/Doorbell/Doorbell/state:state:MAP(mqtt.map)]"}
p.s. i use a map to transform the 0 and 1 coming from esp easy into on and off.
Daveps
(Dave)
November 8, 2016, 5:36pm
4
Thanks chaps for the reply …
Roel, I need to send the momentary pulse to the ESP,not the other way around.
Sihui, adding the state as an input results in the GPIO toggling but still latches,it does not return to the off state by itself.
Any other ideas please ?
Thanks
Dave
sihui
(SiHui)
November 8, 2016, 5:44pm
5
Daveps:
Any other ideas please ?
Did you play around with the “Switch Button Type”?
“Push Button Active Low” (or High depending on your setup) should do it …
A dirty trick would be to setup a rule like this:
rule "toggle workshop alarm"
when
Item Wshop_Alarm received update
then
if (Wshop_Alarm.state == ON) {
sendCommand(Wshop_Alarm, OFF
}
end
Daveps
(Dave)
November 9, 2016, 5:25pm
7
Thanks snoekieboe,your rule trick works exactly as needed.
1 last thing please,can a delay be added to the rule so that the GPIO stays high for a second when triggered before going low again ?
The pulse is a bit short with no delay.
Thanks again you chaps for the help.
Davve
sihui
(SiHui)
November 9, 2016, 6:53pm
8
Daveps:
can a delay be added
Just add
Thread::sleep(300) //time is in millis
to your rule.
rule "toggle workshop alarm"
when
Item Wshop_Alarm received update
then
if (Wshop_Alarm.state == ON) {
Thread::sleep(300)
sendCommand(Wshop_Alarm, OFF)
}
end
Would be your optimized result
1 Like