Howto use zigbee2mqtt with openHAB, removing proprietary bridges / gateways

zigbee
mqtt
xiaomi
Tags: #<Tag:0x00007f51ea3e22e8> #<Tag:0x00007f51ea3e1e60> #<Tag:0x00007f51ea3e1cd0>

(Joachim Boeddeker) #21

Thanks for the clarification @chris.


(Lars Jakobsen) #22

Added a some ikea-bulbs, a float led-panel and some xiaomi motion and windowsensors this weekend, and it seems to be stable so far.


(Joachim Boeddeker) #23

Did you need additional Javascript transformation or were the ones already posted sufficient?


(Lars Jakobsen) #24

Updated some to reflect other attributes and added one for triggering a low-battery alarm. But they are pretty much the same.


(Jose Antonio) #25

Any tutorial to install and use in openHab?


(Joachim Boeddeker) #26

The openHAB specific configuration is in the first post.

I doubt combining everything in a single install/tutorial makes sense, zigbee2mqtt is pretty well documented, so is the mqtt stuff. It just would be a duplicate.

Do you have any specific question?


(Jose Antonio) #27

Thank you.

One question, devices automatically appear in openHAB under “things”?

Now I use zigbee2mqtt in home assistant and I’m considering moving to OH, but I have doubts about how the devices work, I have several


(Joachim Boeddeker) #28

No, the mqtt binding is an old binding, you need to configure your items files with the information from the first post manually.

Oh, btw, you need to install the Javascript and JsonPath transformations as well.


(Lars Jakobsen) #29

I have started experiencing periodical loss of control over the bulbs now, have reported the issue to zigee2mqtt. Have anybody else experienced this?


(Joachim Boeddeker) #30

I changed the definition of Xiaomi Aqara wireless switch WXKG11LM in the first post. The difference is, that the trigger should now work on received command instead of changed.

In addition to that i also corrected the getZigbeeClick.js transformation.


(Joachim Boeddeker) #31

I added this:

  • Xiaomi Aqara temperature, humidity and pressure sensor WSDCGQ11LM

(machnetz) #32

Hello Joachim,

i cannot get my Aqara botton WXKG11LM to work. I defined my button as you did above:

string XB1_CLICK "BUTTON [%s]"  <button>  {mqtt="<[broker:zigbee2mqtt/XB1_Button:command:JS(getZigbeeClick.js)]"

and placed the “getZigbeeClick.js” in the transform-folder. JAVASCRIPT and JSONPATH transformations are activated in OH2, MQTT Binding is also active. When I now press the button I see the following js-error in the openhab2.logfile:

2018-08-14 18:57:21.847 [ERROR] [.mqtt.internal.MqttMessageSubscriber] - Error processing MQTT message.
org.openhab.core.transform.TransformationException: An error occurred while executing script.
at org.openhab.core.transform.TransformationHelper$TransformationServiceDelegate.transform(TransformationHelper.java:67) [217:org.openhab.core.compat1x:2.2.0]
at org.openhab.binding.mqtt.internal.MqttMessageSubscriber.processMessage(MqttMessageSubscriber.java:138) [219:org.openhab.binding.mqtt:1.11.0]
at org.openhab.io.transport.mqtt.internal.MqttBrokerConnection.messageArrived(MqttBrokerConnection.java:556) [220:org.openhab.io.transport.mqtt:1.11.0]
at org.eclipse.paho.client.mqttv3.internal.CommsCallback.deliverMessage(CommsCallback.java:475) [220:org.openhab.io.transport.mqtt:1.11.0]
at org.eclipse.paho.client.mqttv3.internal.CommsCallback.handleMessage(CommsCallback.java:379) [220:org.openhab.io.transport.mqtt:1.11.0]
at org.eclipse.paho.client.mqttv3.internal.CommsCallback.run(CommsCallback.java:183) [220:org.openhab.io.transport.mqtt:1.11.0]
at java.lang.Thread.run(Thread.java:748) [?:?]
2018-08-14 18:57:21.886 [ERROR] [.mqtt.internal.MqttMessageSubscriber] - Error processing MQTT message.
org.openhab.core.transform.TransformationException: An error occurred while executing script.
at org.openhab.core.transform.TransformationHelper$TransformationServiceDelegate.transform(TransformationHelper.java:67) [217:org.openhab.core.compat1x:2.2.0]
at org.openhab.binding.mqtt.internal.MqttMessageSubscriber.processMessage(MqttMessageSubscriber.java:138) [238:org.openhab.binding.mqtt:1.11.0]
at org.openhab.io.transport.mqtt.internal.MqttBrokerConnection.messageArrived(MqttBrokerConnection.java:556) [220:org.openhab.io.transport.mqtt:1.11.0]
at org.eclipse.paho.client.mqttv3.internal.CommsCallback.deliverMessage(CommsCallback.java:475) [220:org.openhab.io.transport.mqtt:1.11.0]
at org.eclipse.paho.client.mqttv3.internal.CommsCallback.handleMessage(CommsCallback.java:379) [220:org.openhab.io.transport.mqtt:1.11.0]
at org.eclipse.paho.client.mqttv3.internal.CommsCallback.run(CommsCallback.java:183) [220:org.openhab.io.transport.mqtt:1.11.0]
at java.lang.Thread.run(Thread.java:748) [?:?]

What i’m doing wrong - any hints? Greetings from Hamburg, machnetz


(Joachim Boeddeker) #33

Hi Machnetz,

did you define the battery items as well? If yes, this may be the cause. The click-message does not contain the battery values, that’s whythe message parser runs into exceptions. But my exceptions differ slightly, i am running openHAB 2.3, not 2.2 like you (did you perhaps filter the log for mqtt?). But the click is working nevertheless.

Here is what i get:

2018-08-14 22:37:09.014 [ERROR] [.mqtt.internal.MqttMessageSubscriber] - Error processing MQTT message.

org.openhab.core.transform.TransformationException: Invalid path '$.voltage' in '{"click":"single"}'
	at org.openhab.core.transform.TransformationHelper$TransformationServiceDelegate.transform(TransformationHelper.java:67) [194:org.openhab.core.compat1x:2.3.0]
	at org.openhab.binding.mqtt.internal.MqttMessageSubscriber.processMessage(MqttMessageSubscriber.java:138) [277:org.openhab.binding.mqtt:1.12.0]
	at org.openhab.io.transport.mqtt.internal.MqttBrokerConnection.messageArrived(MqttBrokerConnection.java:574) [278:org.openhab.io.transport.mqtt:1.12.0]
	at org.eclipse.paho.client.mqttv3.internal.CommsCallback.deliverMessage(CommsCallback.java:475) [278:org.openhab.io.transport.mqtt:1.12.0]
	at org.eclipse.paho.client.mqttv3.internal.CommsCallback.handleMessage(CommsCallback.java:379) [278:org.openhab.io.transport.mqtt:1.12.0]
	at org.eclipse.paho.client.mqttv3.internal.CommsCallback.run(CommsCallback.java:183) [278:org.openhab.io.transport.mqtt:1.12.0]
	at java.lang.Thread.run(Thread.java:748) [?:?]
2018-08-14 22:37:09.021 [ERROR] [.mqtt.internal.MqttMessageSubscriber] - Error processing MQTT message.
org.openhab.core.transform.TransformationException: Invalid path '$.battery' in '{"click":"single"}'
	at org.openhab.core.transform.TransformationHelper$TransformationServiceDelegate.transform(TransformationHelper.java:67) [194:org.openhab.core.compat1x:2.3.0]
	at org.openhab.binding.mqtt.internal.MqttMessageSubscriber.processMessage(MqttMessageSubscriber.java:138) [277:org.openhab.binding.mqtt:1.12.0]
	at org.openhab.io.transport.mqtt.internal.MqttBrokerConnection.messageArrived(MqttBrokerConnection.java:574) [278:org.openhab.io.transport.mqtt:1.12.0]
	at org.eclipse.paho.client.mqttv3.internal.CommsCallback.deliverMessage(CommsCallback.java:475) [278:org.openhab.io.transport.mqtt:1.12.0]
	at org.eclipse.paho.client.mqttv3.internal.CommsCallback.handleMessage(CommsCallback.java:379) [278:org.openhab.io.transport.mqtt:1.12.0]
	at org.eclipse.paho.client.mqttv3.internal.CommsCallback.run(CommsCallback.java:183) [278:org.openhab.io.transport.mqtt:1.12.0]
	at java.lang.Thread.run(Thread.java:748) [?:?]

==> /var/log/openhab2/events.log <==

2018-08-14 22:37:09.031 [vent.ItemStateChangedEvent] - SZKEY1_CLICK changed from NULL to single

(Thomas) #34

I’m thinking of creating a specific OpenHab plugin for the zigbee2mqtt firmware.
The idea is to declare “properly” elements & transformations :slight_smile:

  • to prevent from using javascript calls in the mapping
  • to be able to generate/manage the mappings from paperUI, without heavy manual configuration (auto-discovery & so on)

Do you think it should be a good idea ?


(Matthias) #35

For some Inspiration you can have a look into the current ESH development:


(Joachim Boeddeker) #36

No, i don’t think so. It would be better in my opinion to put that effort into the zigbee binding.


(machnetz) #37

Hello Joachim,

sorry for my delayes answer. Yes, the buttons are defined :slight_smile:

I’ve seen your posted error-messages in my logfiles too. Yesterday I found out that the extended data (battery, voltage, click) would only be sent if the logon button was pressed on the button:

2018-08-15 09:07:59.286 [ERROR] [.mqtt.internal.MqttMessageSubscriber] - Error processing MQTT message.
org.openhab.core.transform.TransformationException: An error occurred while executing script.
at org.openhab.core.transform.TransformationHelper$TransformationServiceDelegate.transform(TransformationHelper.java:67) [217:org.openhab.core.compat1x:2.2.0]
at org.openhab.binding.mqtt.internal.MqttMessageSubscriber.processMessage(MqttMessageSubscriber.java:138) [239:org.openhab.binding.mqtt:1.11.0]
at org.openhab.io.transport.mqtt.internal.MqttBrokerConnection.messageArrived(MqttBrokerConnection.java:556) [220:org.openhab.io.transport.mqtt:1.11.0]
at org.eclipse.paho.client.mqttv3.internal.CommsCallback.deliverMessage(CommsCallback.java:475) [220:org.openhab.io.transport.mqtt:1.11.0]
at org.eclipse.paho.client.mqttv3.internal.CommsCallback.handleMessage(CommsCallback.java:379) [220:org.openhab.io.transport.mqtt:1.11.0]
at org.eclipse.paho.client.mqttv3.internal.CommsCallback.run(CommsCallback.java:183) [220:org.openhab.io.transport.mqtt:1.11.0]
at java.lang.Thread.run(Thread.java:748) [?:?]
2018-08-15 09:07:59.319 [ERROR] [.mqtt.internal.MqttMessageSubscriber] - Error processing MQTT message.
org.openhab.core.transform.TransformationException: Invalid path ‘$.click’ in ‘{“battery”:“100.00”,“voltage”:3045}’

And i cannot get my stick properly running. It might be my setup a have to review. Thank you for your reply. I’ll test it again…


(Thomas) #38

I don’t use the “Zigbee binding” plugin, because :

  • it is NOT compatible with the Zigbee2MQTT firmware
  • standard CC2531 firmware (working with the Zigbee binding) are NOT compatible with many items (Xiaomi switches/sensors, Philips Hue, Ikea Tradfri, etc. (what’s why I use zigbee2MQTT)

So I don’t have any interest in developping this plugin (and I don’t either have a dedicated CC2531 key with related zigbee sensors to test…).


(Joachim Boeddeker) #39

Oh, i didn’t knew this. I thought it was just a matter of missing implementation, never thought of incompatible firmwares.

Then this is different… although i wouldn’t be interested in a binding for that, i guess many others would.


(Chris Jackson) #40

Why not look at fixing this? I tend to focus on the Ember dongles so am not particularly familiar with the TI firmware, but given the protocol is largely the same between versions (I think it’s completely the same) it is likely to just be configuration. To me, this would make more sense than yet another ZigBee binding.

Are you sure? So TI dongles are not compatible with Hue? This for sure I know is wrong as I have personally tested the TI dongle with these devices you list with the ZigBee binding.