Hi all,
First post. I have been working with openHAB for about two weeks now so forgive my stupidity, for context I have a Sonoff Zigbee Bridge (ESP8266) running Tasmota and I am trying to communicate with a S26 ZB Smart Plug via the Bridge using MQTT.
This post is mainly a sanity check, I have achieved the outcome I want with the method below but I was wondering if this is the correct, and most importantly the cleanest way to do it? My assumption is that the MQTT addon bindings are design to talk directly to MQTT devices and not to a ZigBee device connected to a MQTT Bridge?
.things
Bridge mqtt:broker:1 "Mosquitto MQTT Broker" @ "Office" [ host="openhabian", clientId="openhabian", username="openhabian", password="" ]
Thing mqtt:topic:1 "MQTT Topic" (mqtt:broker:1) {
Type number : S26x1_Power [stateTopic="zigbee/switches/s26x1/power"]
}
zigbee/switches/s26x1/power is published from ZbReceived using a Tasmota rule.
.items
Number S26x1_State "S26x1 State" { channel="mqtt:topic:1:S26x1_Power" }
Switch S26x1_Switch "S26x1 Switch"
Using a virtual switch and number to track the state.
.rules
rule "SB26x1_Switch"
when
Item S26x1_Switch changed
then
val mqttActions = getActions("mqtt","mqtt:broker:1")
mqttActions.publishMQTT("cmnd/tasmota_E24D4E/ZbSend", '{ "Device": "0xBAED", "Send": { "Power": "' + S26x1_Switch.state + '" } }')
end
rule "SB26x1_State"
when
Item S26x1_State changed
then
val state = if (S26x1_State.state == 1) ON else OFF
if (state !== S26x1_Switch.state) {
logInfo("zbbridge", "S26x1 state was changed outside of openHAB.")
S26x1_Switch.sendCommand(state)
}
end
Thanks,
Mike