Setting up zigbee devices witha tasmota bridge

Hi

I’ve tried the Z2T on the Sonoff Bridges and I got it working well. However, there is no way to backup the device and its configuration (which is VERY complex) and having set up three bridges (yes, three) I lost the configuration of all during a power cut.

I switched to Zigbee to MQTT, running on a Pi and I am SOOOOO glad I did. It’s a vastly better solution, with backup options, much better interface, additional capabilities (e.g. OTA device updates).

I love tasmota and appreciate the effort that went into creating Z2T but it’s an unfinished science project that isn’t actually needed by Openhab users. Z2M is far superior.

Change now before you get too much set up.

Could you please post your configuration files (tings and items)? Thanks.

I made backups from each of my tasmota devices, at the moment 30+ plus 2 zigbee coordinators,
Never lost config through power fail or out of the blue, when i lost config it was user error, restoring was never a problem!

HI

I can’t post entire files, but here are some example things and items

Candeo Dimmer Switch item

Switch LoungeWallLights “Lounge Ceiling Lights” (Glounge) { channel=“mqtt:topic:LoungeWallLights_thg:PushButton” }
Dimmer LoungeWallLightsDimmer “Lounge Wall Lights [%.0f %%]” (Glounge) { channel=“mqtt:topic:LoungeWallLights_thg:Brightness” }

Candeo Dimmer Switch Thing

Thing mqtt:topic:LoungeWallLights_thg “Lounge Wall” (mqtt:broker:home) @ “Lounge” {
Channels:
Type switch : PushButton “Lights Switch” [ stateTopic=“zigbee2mqtt01/Lounge_Wall_Dimmer/state”, commandTopic=“zigbee2mqtt01/Lounge_Wall_Dimmer/set/state”, on=“ON”, off=“OFF” ]
Type dimmer : Brightness “Lights Brightness” [ stateTopic=“zigbee2mqtt01/Lounge_Wall_Dimmer/brightness”, commandTopic=“zigbee2mqtt01/Lounge_Wall_Dimmer/set/brightness”, min = 0, max = 254, step = 1 ]} // end of thing

I’ve done switches, dimmers, sockets, Ledvance coloured LED… What do you need an example of?

Cheers
Barry

Try and restore that configuration backup onto another Sonoff Bridge and see if it will start the coordinator and recover all the devices you have configured.

That configuration certainly transfers the WiFi settings etc - but not the devices…

The designers confirmed that it wasn’t possible. (You will find a thread on the Github for the Z2T project.

Barry, I want to use zigbee leak sensors and smart plugs to replace my existing insteon devices as they wear out.

Can you post your mqtt thing/configuration?
Thanks.

I have not done a leak sensor (though it interests me) but I have used the Osram/Ledvance zigbee sockets.

This is the socket powering a recliner chair :
Thing:

Thing mqtt:topic:ReclinerChair_thg “OsramSocket01” (mqtt:broker:home) @ “Lounge” {
Channels:
Type switch : Power “Osram Socket” [ stateTopic = “zigbee2mqtt01/Lounge_Recliner/state”, commandTopic = “zigbee2mqtt01/Lounge_Recliner/set/state” , on=“ON”, off=“OFF” ]
} // end of thing

Item:

Switch ReclinerChair “Recliner Chair” (Glounge){ Channel=“mqtt:topic:ReclinerChair_thg:Power” }

here is a temperature sensor…

Thing :

Thing mqtt:topic:ZigbeeSensorTH01_thg “Temperature and Humidity Sensor 01” (mqtt:broker:home) @ “Louise Office” {
Channels:
Type string : Temperature “Louise Office Temperature” [ stateTopic=“zigbee2mqtt01/Louise_Office_TH/temperature” ]
Type string : Humidity “Louise Office Humidity” [ stateTopic=“zigbee2mqtt01/Louise_Office_TH/humidity” ]
Type number : BatteryP “Louise Office THBattery” [ stateTopic=“zigbee2mqtt01/Louise_Office_TH/battery” ]
} // end of thing

Item:

Number LouiseOfficeTH_BatteryP “Louise Office TH Battery [%s]” (Gbatteries) { channel=“mqtt:topic:ZigbeeSensorTH01_thg:BatteryP” }
Number LouiseOfficeTH_Temperature “Louise Office Temperature [%.1f C]” (Gloffice,Gtemps) { channel=“mqtt:topic:ZigbeeSensorTH01_thg:Temperature” }
Number LouiseOfficeTH_Humidity “Louise Office Humidity [%s]” (Gloffice) { channel=“mqtt:topic:ZigbeeSensorTH01_thg:Humidity” }

I tried to install zigbee2mqtt but I think I failed. Using openhabian-config failed with an error. I installed it manually but I run into problems with the version of npm (I installed 7.x and it says I need to upgrade to 9.2 but the installer fails.

I am trying to use the Paper UI (still without success). When I configure a channel for a thing (Power), what do I need to enter for the state and command topics - mqtt:zplug1:state:power?

I have Zigbee2MQTT on it’s own Pi - My OpenHab installation is on Windows - (which I love)

I think (at least part of) my problem is in openhab - I don’t think my item is actually sending an mqtt command. When I change the setting in the UI, it reports that the item is changed from off to on, but nothing else is called/executed.

I figured out part of my problem - I was looking at the mosquitto log and not using a proper mqtt client.

Using mqtt Explorer, I tried to activate the zigbee plug, without success. Here are the commands and responses:

cmnd/zPlug1/ZbSend/POWER/ON

12:18:18.189 SRC: MQTT
12:18:18.191 CMD: Grp 0, Cmd 'ON', Idx 1, Len 0, Pld -99, Data ''
12:18:18.195 MQT: stat/41picX/RESULT = {"Command":"Unknown"}

cmnd/41picX/zPlug1/ZbSend/POWER/ON

12:18:18.189 SRC: MQTT
12:18:18.191 CMD: Grp 0, Cmd 'ON', Idx 1, Len 0, Pld -99, Data ''
12:18:18.195 MQT: stat/41picX/RESULT = {"Command":"Unknown"}

Part of my confusion is on the command topic (and I assume that the state topic will follow). I have a tasmota bridge (Sonofff bridge flashed to and running tasmota), and trying to control a zigbee plug. Do I need to include the bridge (41picX) in the command topic?

It does appear that openHAB is talking to the mqtt broker - I see traffic when a switch is changed - pretty much the same errors I get from mqtt Explorer.

I went back and redid my files based on this tutorial. Unfortunately, it still isn’t working.

Here are my files.

mqtt.things:

Bridge mqtt:broker:MosquittoMQTTBroker "MosquittoMQTTBroker" [
	host="192.168.0.14",
	secure=false,
	port=1883]
	{
	Thing topic myThing {
	      Channels:
		Type switch : power "Power" [
		     stateTopic="tele/tasmota/STATE",
		     commandTopic="cmnd/tasmota/POWER",
		     transformationPattern="JSONPATH:$.POWER", on="ON", off="OFF" ]

}}

tamota.items:

Switch zPlug1_item "Zigbee Light"  { channel="mqtt:topic:MosquittoMQTTBroker:myThing:power" }

tasmota.sitemap:

sitemap tasmota label="Tasmota Devices" {
   Frame label="Device List" {
	Switch item=zPlug1_item label="Zigbee Plug"
    }
}

The broker, thing and item all show up as good in the paper UI.
When I switch the plug in the basic UI i get:

2022-12-17 07:07:18.309 [nt.ItemStatePredictedEvent] - zPlug1_item predicted to become ON
2022-12-17 07:07:18.443 [vent.ItemStateChangedEvent] - zPlug1_item changed from OFF to ON

I am seeing nothing on MQTT Explorer.

I wonder if you ever came across this site with lots of informations about how to.

Understanding Zigbee messages

Sending Device Commands

MQTT command example

But first of all you should understand how the MQTT topic works

In my case Zigbee is the topic which i set in the mqtt settings.

You can find this topic again in the output of the console

tele/Zigbee/Lamp/SENSOR = {"Lamp":{"Device":"0xFB7F","Name":"Lamp","Power":1,"Endpoint":1,"LinkQuality":44}}

you can see now Zigbee is the topic and Lamp is my device

The state topic for Power should now look like this

stateTopic: tele/Zigbee/Lamp/SENSOR
transformationPattern: JSONPATH:$.Lamp.Power

and the command topic shoul look like as described here

commandTopic="cmnd/Zigbee/Lamp/ZBSEND",
formatBeforePublish: "{\"device\":\"Lamp\", \"send\":{\"Power\":\"%s\"} }",
on="1",
off="0"

and this

setoption112 1

I’m getting closer! The switch is activating, but I’m getting the following error:

==> /var/log/openhab2/events.log <==
2022-12-19 21:31:18.159 [ome.event.ItemCommandEvent] - Item 'zPlug1_item' received command ON
2022-12-19 21:31:18.210 [nt.ItemStatePredictedEvent] - zPlug1_item predicted to become ON
2022-12-19 21:31:18.333 [vent.ItemStateChangedEvent] - zPlug1_item changed from OFF to ON

==> /var/log/openhab2/openhab.log <==
2022-12-19 21:31:19.201 [WARN ] [t.generic.ChannelStateTransformation] - Executing the JSONPATH-transformation failed: Invalid path '$.POWER' in '{"zPlug1":{"Device":"0x8BAD","Name":"zPlug1","Power":1,"Endpoint":1,"LinkQuality":66}}'

==> /var/log/openhab2/events.log <==
2022-12-19 21:31:20.519 [ome.event.ItemCommandEvent] - Item 'zPlug1_item' received command OFF
2022-12-19 21:31:20.576 [nt.ItemStatePredictedEvent] - zPlug1_item predicted to become OFF
2022-12-19 21:31:20.704 [vent.ItemStateChangedEvent] - zPlug1_item changed from ON to OFF

==> /var/log/openhab2/openhab.log <==
2022-12-19 21:31:22.033 [WARN ] [t.generic.ChannelStateTransformation] - Executing the JSONPATH-transformation failed: Invalid path '$.POWER' in '{"zPlug1":{"Device":"0x8BAD","Name":"zPlug1","Power":0,"Endpoint":1,"LinkQuality":66}}'

Here is the workng things files:

Thing mqtt:topic:Zigbee:zPlug1 "Zigbee Plug 1" (mqtt:broker:mqtt) {
	Channels:
		Type switch : power "Power Switch" [
			stateTopic="tele/Zigbee/zPlug1/SENSOR",
                        transformationPattern="JSONPATH:$.POWER",
                        commandTopic="cmnd/Zigbee/zPlug1/ZBSEND",
                        formatBeforePublish="{\"device\":\"zPlug1\", \"send\":{\"Power\":\"%s\"} }",
							on="1",
							off="0"
			]
                Type switch : reachable "Reachable" [
                        stateTopic = "tele/Zigbee/zPlug1/LWT",
                        on="Online",
                        off="Offline"
                ]

                Type number:rssi "RSSI" [
                        stateTopic="tele/Zigbee/zPlug1/STATE",
                        transformationPattern="JSONPATH:$.Wifi.RSSI"
                ]
}

In the warn log you can see that your path is wrong

==> /var/log/openhab2/openhab.log <==
2022-12-19 21:31:22.033 [WARN ] [t.generic.ChannelStateTransformation] - Executing the JSONPATH-transformation failed: Invalid path '$.POWER' in '{"zPlug1":{"Device":"0x8BAD","Name":"zPlug1","Power":0,"Endpoint":1,"LinkQuality":66}}'

the transformationPattern should be

transformationPattern="JSONPATH:$.zPlug1.Power",

and your mqtt broker is talking to the tasmota topic and not directly to your device, so you only need Zigbee without zPlug1

Thing mqtt:topic:Zigbee "Zigbee Plug 1" (mqtt:broker:mqtt)
Thing mqtt:topic:Zigbee "Zigbee Plug 1" (mqtt:broker:mqtt) {
	Channels:
		Type switch : power "Power Switch" [
			stateTopic="tele/Zigbee/zPlug1/SENSOR",
                        transformationPattern="JSONPATH:$.zPlug1.Power",
                        commandTopic="cmnd/Zigbee/zPlug1/ZBSEND",
                        formatBeforePublish="{\"device\":\"zPlug1\", \"send\":{\"Power\":\"%s\"} }",
							on="1",
							off="0"
			]
                Type switch : reachable "Reachable" [
                        stateTopic = "tele/Zigbee/zPlug1/LWT",
                        on="Online",
                        off="Offline"
                ]

                Type number:rssi "RSSI" [
                        stateTopic="tele/Zigbee/zPlug1/STATE",
                        transformationPattern="JSONPATH:$.Wifi.RSSI"
                ]
}

SO, I have it mostly working. The switches operate and the leak sensor sends alerts. I am still working on getting devices to report status - things like reachable and battery level - but at least I have basic functionality.

Here is my code, such as it is:

tasmota.things:

Thing mqtt:topic:Zigbee "Tasmota" (mqtt:broker:mqtt) {
      Channels:
	  // Tasmota Status
          Type string : Version      [stateTopic="stat/Zigbee/STATUS2", transformationPattern="JSONPATH:$.StatusFWR.Version"]
          Type switch : Reachable    [stateTopic="tele/Zigbee/LWT",
	     	    on="Online",
		    off="Offline"]

       	  // Diagnostics: Define specific for what you really need on a regular basis, use standalone MQTT client for troubleshooting
          Type string : RestartReason [
	       stateTopic="tele/Zigbee/INFO3",
	       transformationPattern="JSONPATH:$.Info3.RestartReason"
	       ]
       	  // old one, have to query it
          Type string : Version2      [
	       stateTopic="stat/Zigbee/STATUS2",
	       transformationPattern="JSONPATH:$.StatusFWR.Version"
	       ]
          // new one - comes for free at startup
          Type string : Version       [
	       stateTopic="tele/Zigbee/INFO1",
	       transformationPattern="JSONPATH:$.Info1.Version"
	       ]
          Type number : RSSI          [
	       stateTopic="tele/Zigbee/STATE",
	       transformationPattern="JSONPATH:$.Wifi.RSSI"
	       ]
          Type string : WifiDowntime  [
	       stateTopic="tele/Zigbee/STATE",
	       transformationPattern="JSONPATH:$.Wifi.Downtime"
	       ]
          Type number : LoadAvg       [
	       stateTopic="tele/Zigbee/STATE",
	       transformationPattern="JSONPATH:$.LoadAvg"
	       ]
          Type number : Uptime        [
	       stateTopic="tele/Zigbee/STATE",
	       transformationPattern="JSONPATH:$.UptimeSec"
	       ]
          Type string : Result        [
	       stateTopic="stat/Zigbee/RESULT"
	       ]
}

Thing mqtt:topic:Zigbee:zPlug1 "Zigbee Plug 1" (mqtt:broker:mqtt) {
	Channels:
		Type switch : power "Power Switch" [
			stateTopic="tele/Zigbee/zPlug1/SENSOR",
                        transformationPattern="JSONPATH:$.zPlug1.Power",
                        commandTopic="cmnd/Zigbee/ZBSEND",
                        formatBeforePublish="{\"device\":\"zPlug1\", \"send\":{\"Power\":\"%s\"} }",
							on="1",
							off="0"
			]
                Type switch : Reachable "Reachable" [
                        stateTopic = "tele/Zigbee/zPlug1/LWT",
                        on="Online",
                        off="Offline"
                ]
}

Thing mqtt:topic:Zigbee:zPlug2 "Zigbee Plug 2" (mqtt:broker:mqtt) {
	Channels:
		Type switch : power "Power Switch" [
			stateTopic="tele/Zigbee/zPlug2/SENSOR",
                        transformationPattern="JSONPATH:$.zPlug2.Power",
                        commandTopic="cmnd/Zigbee/ZBSEND",
                        formatBeforePublish="{\"device\":\"zPlug2\", \"send\":{\"Power\":\"%s\"} }",
							on="1",
							off="0"
			]
                Type switch : Reachable "Reachable" [
                        stateTopic = "tele/Zigbee/zPlug2/LWT",
                        on="Online",
                        off="Offline"
                ]
}

Thing mqtt:topic:Zigbee:zLeak1 "Zigbee Leak Sensor 1" (mqtt:broker:mqtt) {
        Channels:
		Type contact: water_leak "Water detected" [
			stateTopic="tele/Zigbee/zLeak1/SENSOR",
			transformationPattern="JSONPATH:$.zLeak1.Water"]
		//Type string : battery "Battery" [
	     	//      	stateTopic="tele/Zigbee/zLeak1/STATE",
		//	transformationPattern="JSONPATH:$.zLeak1.BatteryPercentage"]
		Type switch : Reachable "Reachable" [
                        stateTopic = "tele/Zigbee/zLeak1/LWT",
                        	   on="Online",
                        	   off="Offline"
				   ]

    }

tasmota.items:

// zPlug1
Switch zPlug1_item "zPlug 1"  { channel="mqtt:topic:Zigbee:zPlug1:power" }
Switch string_zPlug1Reachable "Reachable" { channel="mqtt:topic:Zigbee:zPlug1:Reachable" }

//zPlug2
Switch zPlug2_item "zPlug 2"  { channel="mqtt:topic:Zigbee:zPlug2:power" }
Switch string_zPlug2Reachable "Reachable" { channel="mqtt:topic:Zigbee:zPlug2:Reachable" }

//zLeak1
Contact zLeak1_leak "Leak Sensor Status [MAP(zleak.map):%s]" { channel="mqtt:topic:Zigbee:zLeak1:water_leak"}
String zLeak1_battery "Battery Status" { channel="mqtt:topic:Zigbee:zLeak1:battery"}
Switch zLeak1_reachable "Reachable" {channel="mqtt:topic:Zigbee:zLeak1:Reachable"}

//Tasmota system
// Tasmota Status
String             Tasmota_Version   "Tasmota Version [%s]" {channel="mqtt:topic:Zigbee:Version", channel="mqtt:topic:Zigbee:Version2"}
Switch             Tasmota_Reachable "Reachable"            {channel="mqtt:topic:Zigbee:Reachable"}

// Diagnostics
String               Tasmota_RestartReason "Restart Reason [%s]"  {channel="mqtt:topic:Zigbee:RestartReason"}
Number:Dimensionless Tasmota_RSSI          "Signal [%d %%]"       {channel="mqtt:topic:Zigbee:RSSI"}
String               Tasmota_WifiDowntime  "Wifi Downtime [%s]"   {channel="mqtt:topic:Zigbee:WifiDowntime"}
Number:Dimensionless Tasmota_LoadAvg       "Load [%d %%]"         {channel="mqtt:topic:Zigbee:LoadAvg"}
String               Tasmota_Result        "Result [%s]"          {channel="mqtt:topic:Zigbee:Result"}
Number:Time          Tasmota_Uptime        "Uptime [%.1f s]"      {channel="mqtt:topic:Zigbee:Uptime"}

tasmota.sitemap:

sitemap tasmota label="Tasmota Devices" {
   Frame label="Zigbee Plug 1" {
	Switch item=zPlug1_item label="Zigbee Plug 1"
	Text item=string_zPlug1Reachable labelcolor=["ONLINE"="green","OFFLINE"="red"]
}
   Frame label="Zigbee Plug 2" {
	Switch item=zPlug2_item label="Zigbee Plug 2"
	Text item=string_zPlug2Reachable labelcolor=["ON"="green","OFF"="red"]
    }
   Frame label="Zigbee Leak Sensor 1" {
   	 Text item=zLeak1_leak labelcolor=["CLOSED"="green","OPEN"="red"] icon="water"
	 Text item=zLeak1_reachable labelcolor=["ON"="green","OFF"="red"]
	 Text item=zLeak1_battery
	 }
   Frame label="Tasmota Status" {
   	 // Tasmota Status
	 Text item=Tasmota_Version
	 Text item=Tasmota_Reachable labelcolor=["ON"="green","OFF"="red"]


	 // Diagnostics
	 Text item=Tasmota_RestartReason
	 Text item=Tasmota_RSSI
	 Text item=Tasmota_WifiDowntime
	 Text item=Tasmota_LoadAvg
	 Text item=Tasmota_Uptime label="Uptime [%.1f d]"
	 Text item=Tasmota_Result
	 }
}

and here’s what I’m seeing in the basic UI:

Thanks for everyone’s help. I’m still trying to get my head around some of the tasmota idiosyncrasies, but at least I know it’s doable!

What is still not working?

I can’t get the devices to report reachable. So long as the device is reporting its on/off status, I think that tells me if it is reachable or not.