OH2 doesn't hear Tasmota Switch

  • Platform information:
    • Hardware: Pi 4
    • OS: Openhabian

I’ve had a working Tasmota/Zigbee setup running for the past year. I replaced my Sonoff Tasmota bridge last week, and now OH2 doesn’t hear data from my switches.
I can operate lights and plugs from within OH2, using the GUI, and the status of each plug and light is displayed in the GUI.
However, none of the data from the switches are being received by OH2. I’ve run an MQTT listener and the mqtt broker is receiving the data, but it doesn’t relay them to OH2. Other ZbData data are received.

Here is an example of the switch code:

MQTT bridge:

Bridge mqtt:broker:mqtt "MosquittoMQTTBroker" [
	//host="192.168.x.x",
	host="127.0.0.1",
	secure=false,
	port=1883]

Thing code:

Thing mqtt:topic:Zigbee:zSwitch4 "Zigbee Switch 4" (mqtt:broker:mqtt) {
	Channels:
		Type number : power "Power Switch" [
			stateTopic="tele/Zigbee/zSwitch4/SENSOR",
                        transformationPattern="JSONPATH:$.zSwitch4.Power"
			]
		Type number : battery "Battery" [
	     	      	stateTopic="tele/Zigbee/zSwitch4/SENSOR",
			transformationPattern="JSONPATH:$.zSwitch4.BatteryPercentage"]
}

Item code:

Number zSwitch4_item "Hall Lights" { channel="mqtt:topic:Zigbee:zSwitch4:power"}
Number zSwitch4_battery "Battery Status [%d %%]" { channel="mqtt:topic:Zigbee:zSwitch4:battery"}

Rule code:

rule "zSwitch 4 Rule"
when
    Item zSwitch4_item received update
then
    if(zSwitch4_item.state==0) {
    	den_lights.sendCommand(OFF)
	den.sendCommand(OFF)
	entrance.sendCommand(OFF)
	}
    if(zSwitch4_item.state==1) {
        if (den.state == ON) den.sendCommand(OFF)
	else den.sendCommand(ON)
	}
    if(zSwitch4_item.state==2) {
        if (den_lights.state == ON) den_lights.sendCommand(OFF)
	else den_lights.sendCommand(ON)	}
end

Any idea what I’m doing wrong? I’m frustrated because this code worked with the old bridge.
Thanks.

Mike

Are you sure about the Channel UID? Should be mqtt:topic:mqtt:zSwitch4:power
(and it would be better to call the broker not mqtt :wink: ).
Do you know about the alternative format for *.things?

Bridge mqtt:broker:mosquitto "Mosquitto MQTT Broker" [
    host="127.0.0.1",
    secure=false,
    port=1883
 ] {
    Thing topic zSwitch4 "Zigbee Switch 4" [
        // optional thing-settings like LWT
    ] {
    Channels:  // optional
        Type number : power "Power Switch" [ stateTopic="tele/Zigbee/zSwitch4/SENSOR",
                                             transformationPattern="JSONPATH:$.zSwitch4.Power" ]
        Type number : battery "Battery"    [ stateTopic="tele/Zigbee/zSwitch4/SENSOR",
                                             transformationPattern="JSONPATH:$.zSwitch4.BatteryPercentage" ]
    }
    Thing topic  zSwitch3 "Zigbee Switch 3" [] {
        Type number : power "Power Switch" [ stateTopic="tele/Zigbee/zSwitch3/SENSOR",
                                             transformationPattern="JSONPATH:$.zSwitch3.Power" ]
        Type number : battery "Battery"    [ stateTopic="tele/Zigbee/zSwitch3/SENSOR",
                                             transformationPattern="JSONPATH:$.zSwitch3.BatteryPercentage" ]
    }
   // more Things
}

Downside is, you have to create all things within one *.things file, but on the other hand, less text and a more clearly assignment to the bridge/broker. If using VS Code, there is an option to fold/unfold things to preserve a better overview.

Udo,
Thank you, I have combined my mqtt.things and tasmota.things into one file. We’ll see how it goes!

Mike

I renamed the broker, which I think makes my code less confusing.
However, OH2 still wasn’t receiving data from the switch. It turns out that I needed to enable SetOption112 to 1 in order to use friendly names in Zigbee topics.

Here are the options I have set:
SetOption83 1 //Uses Zigbee device friendly name instead of 16 bits short addresses as JSON key when reporting values and commands
SetOption89 1 // Configure MQTT topic for Zigbee devices (also see SensorRetain) 1 = unique device topic based on Zigbee device ShortAddr
SetOption100, 1 //remove Zigbee ZbReceived value from {"ZbReceived":{xxx:yyy}} JSON message
SetOption112 1 //use friendly name in Zigbee topic

Now all of my switches are reporting properly.