Setting up zigbee devices witha tasmota bridge

I am trying to set up zigbee devices through a bridge.
I flashed the Sonoff bridge to tasmota, and can control devices through the console (although it needs the hex name - it gives and error using friendly names)

zbsend{“device”:“0xA123”, “send”:{“power”:“on”}} works; using “device”:“zigbeePlug” doesn’t.

I installed MQTT and the JSON transformation tools.
As of now, the bridge talks with MQTT, MQTT talks with openHAB, and it appears that information flows to openHAB from the bridge, but commands from openHAB do not go to the bridge.

MQTT and the devices are constantly cycling from offline to online and back again.

Here are my settings:

mqtt.things

Bridge mqtt:broker:MosquittoMqttBroker "Mosquitto MQTT Broker" [
	host="192.168.0.14",
	secure=false,
	port=1883,
	clientID="DVES_E23EA9",
	username="openhabian",
	password=""
	] {
	  Thing mqtt:topic:0x8BAD "Zigbee Switch" (mqtt:broker:MosquittoMqttBroker) {
	  	Channels:
			Type switch : switch "Power Switch" [
			     stateTopic="stat/0x8BAD/POWER",
			     commandTopic="cmnd/0xBAD/POWER",
			     			on="ON",
						off="OFF"
						]
			Type string : reachable "Reachable" [
				stateTopic = "tele/0x8BAD/LWT"
				]
	}
}

tasmota.items

Switch switch_zPlug1 "Zigbee Switch"  { channel="mqtt:topic:0x8BAD:switch" }
String string_zPlug1Reachable "Device Status" { channel="mqtt:topic:0x8BAD:reachable" }

tasmota.sitemap

sitemap tasmota label="Tasmota Setup" {
				       Switch item=switch_zPlug1
				       Text   item=string_zPlug1Reachable
				       }

I’ve tried following the howtos, with no success. Is using the bridge part of the problem?

Thanks.
Mike

  • Platform information:
    • Hardware: _Pi Zero
    • OS: openhab
    • openHAB version: 2.5

It might be your Thing configuration. You have nested it underneath your Bridge configuration, but then linked it again to your Bridge from within the Thing. Have a look at the documentation for an example of a correct configuration.

More examples here.

Thanks for the links. I think I have almost everything correct - probably just one little thing that is causing it to fail.

I took the MQTT link out and reloaded the file. Still no success. It appears that the zigbee data is not reaching openHAB, and commands from openHAB are not reaching MQTT.

Does the bridge have to be included in the message path (mqtt:topic:bridge:item:action) or is the bridge invisible as far as routing?

Can you show all the parts of your latest configuration?

With Tasmota Zigbee you can not use the same MQTT commands as usual with tasmota.
For the command topic you have to use zbSend, see here

commandTopic="cmnd/0xBAD/ZbSend"

and i use Outgoing Value Transformation with payload in a js file in the transformation folder

(function(x){

    var result = new Object();
    result.Power = x;
   
    return JSON.stringify({ Device: "your device", "send": result });
       
})(input)

If you want to use the frienly name you have to set Setoption83 1, see here

1 Like

Did you know that you could probably use the Jinja Transformation Service to do this instead? It would mean the entire configuration remains within your Things file - no separate JS file required!

See here for an example.

1 Like

Didn’t know that, i’ll try. Thanks for the hint.

Thanks for the help, but I’m still not getting it. Here are the files as I’ve rewritten them, along with a screenshot of the tasmota server. I also set the tasmota server to use friendly names.

mqtt.things:

Bridge mqtt:broker:MosquittoMqttBroker "Mosquitto MQTT Broker" [
	host="192.168.0.14",
	secure=false,
	port=1883,
	clientID="DVES_E23EA9",
	username="openhabian",
	password=""
	]

tasmota.things (I’ve tried both transformation formats with no success.):

Thing mqtt:topic:zPlug1 "Zigbee Switch"
    (mqtt:broker:MosquittoMqttBroker)
        {
 	Channels:
		Type switch : power "Power" [
		     stateTopic="tele/zPlug1/STATE",
		     commandTopic="cmnd/zPlug1/ZbSend",
		     transformationPattern="JSONPATH:$.POWER",
		     on="ON",
		     off="OFF" ]


		Type string : reachable "Reachable" [
			stateTopic = "JINJA:{\"mqtt\":\"tele\", \"zPlug1\":\"LWT\"}"
			]
	}

tasmota.map:

Online=ON
Offline=OFF

(function(x){

    var result = new Object();
    result.Power = x;

    return JSON.stringify({ Device: "your device", "send": result });

})(input)

tasmota.items:

Switch switch_zPlug1 "Zigbee Switch"  { channel="mqtt:topic:zPlug1:power" }
String string_zPlug1State "Device Status" { channel="mqtt:topic:zPlug1:state" }
String string_zPlug1Reachable "Device Status" { channel="mqtt:topic:zPlug1:reachable" }

tasmota.sitemap:

sitemap tasmota label="Tasmota Setup" {
				       Switch item=switch_zPlug1
				       Text   item=string_zPlug1State
				       Text   item=string_zPlug1Reachable
				       }

This part of your Bridge configuration needs changing. It sets a unique name with which openHAB communicates with the MQTT broker. However, it’s identical to your Tasmota device name. So now two devices are trying to talk to the MQTT broker using the same unique name - this confuses the broker, and it will refuse to talk to one of the devices.

There may be other issues, but that’s an immediate one to try. Just change it to clientID="openHAB" - or whatever: just make sure that nothing else is talking to your MQTT broker with the same name.

First of all, i`m not using files, everything is UI configured

in your tasmota console type following commands

Setoption83 1
Setoption89 1  // set unique device topic based on Zigbee device ShortAddr 
Setoption100 1  // remove Zigbee ZbReceived value from  JSON message

If you then send a command from your tasmota console it should look like

11:07:07.511 CMD: ZbSend { "device":"Lamp", "send":{"Power":"Off"} }
11:07:07.520 MQT: stat/Zigbee/RESULT = {"ZbSend":"Done"}
11:07:08.389 MQT: tele/Zigbee/Lamp/SENSOR = {"Lamp":{"Device":"0xFB7F","Name":"Lamp","Power":0,"Endpoint":1,"LinkQuality":68}}

My thing configuration looks like this

UID: mqtt:topic:d0a861377f:Tasmota_Zigbee
label: Tasmota Zigbee
thingTypeUID: mqtt:topic
configuration:
  payloadNotAvailable: Offline
  availabilityTopic: tele/Zigbee/LWT
  payloadAvailable: Online
bridgeUID: mqtt:broker:d0a861377f
channels:
  - id: Lamp_Switch
    channelTypeUID: mqtt:switch
    label: Lamp Switch
    description: ""
    configuration:
      commandTopic: cmnd/Zigbee/Lamp/ZbSend
      transformationPatternOut: JINJA:{ "device":"Lamp", "send":{"Power":"{{value}}"} }
      stateTopic: tele/Zigbee/Lamp/SENSOR
      transformationPattern: JSONPATH:$.Lamp.Power
      off: "0"
      on: "1"

No more js transformation file needen anymore

Hope this helps

Thanks to @hafniumzinc for the hint with Jinja.

This looks painful. Why not use zigbee2mqtt?
Also:

  • don’t use clientid for your mqtt bridge
  • Don’t use username / password on the bridge unless your mqtt server needs it. If you have secure=false you should remove username/password.

Why use JINJA here? Try removing transformationPatternOut and add formatBeforePublish: { "device":"Lamp", "send":{"Power":"%s"} }

It is not painfull once you get used to it, i tryed zigbee2mqtt but i prefer zigbeetasmota.

formatBeforePublish is even better, Thanks

Can you elaborate why you like tasmota over zigbee2mqtt? I have used tasmota but I’m not too familiar with the zigbee support. I use zigbee2mqtt.

because i had 30+ tasmota devices before i startet with zigbee, so was used to tasmota.

Rolli,
I’m still very confused.

In your configuration, what is d0a861377f? Where is that value set? Is Tasmota_Zigbee your physical zigbee bridge?

Is Lamp your zigbee device, as listed on the tasmota bridge?

What is your items configuration to manipulate the device?

Thanks for the help.

On wich OH version are you and i guess you do your configuration in files?

UID: mqtt:broker:d0a861377f

is the UID of my mqtt broker

I’m using OH 2.5 and yes, I manage it through files.

is this your mqtt broker and is it shown online?

If yes, remove the clientID