I am trying to forward a message if I state change to 0 (OFF) or 1 (ON).
My item:
Switch SwitchDoo_Switch "SwitchDoo" ["Lighting"] {mqtt=">[broker:/switch/gpio/5:command:ON:1],>[broker:/switch/gpio/5:command:OFF:0],<[broker:/switch/door/state:command:OFF:0],<[broker:/switch/door/state:command:ON:1]", autoupdate="false"}
String VT_Notify_Alarm { mqtt=">[broker:/openhab/notification/alarm:state:*:default]" }
My rule:
rule "SwitchDoo"
when
Item SwitchDoo changed
then
if (SwitchDoo.state == 1) {
VT_Notify_Alarm.postUpdate("Haustor offen")
} else {
VT_Notify_Alarm.postUpdate("Haustor geschlossen")
}
end
MQTT output:
/switch/gpio/5
0
/switch/gpio/5
1
How can I post VT_Notify_Alarm.postUpdate("Haustor offen")
if state is 1 ?
I checked this Using MQTT command for Switch Item and this [SOLVED] Switch and icon update via MQTT but none of them worked.