Howto use zigbee2mqtt with openHAB, removing proprietary bridges / gateways

Have you installed the JSONPATH transformation? It’s an addon you have to install via paperui or the addons file:

It seems like that you have the payload on a NUmber item and not a string? Maybe post your setup?

Otherwise I have about the same setup as Kiryl and my Tradfri buttons are working flawlessly

You are right the JSONPATH addon was missing. How stupid of me…
Many thanks for your quick answer

Yes. Transformation is required. There were some samples in this discussion. But you may simply ignore this error. Everything should be fine.

That’s not completely true. I am running without. No ugly transformations anymore.

You need a quite recent zigbee2mqtt and need to enable the attribute transmission. This removes jsonpath and transmits single attributes.

I have installed Zigbee2mqtt version 1.7.1 but I do not know how to enable the attribute transmission?

experimental:
  output: attribute

I have tried to add that in the zigbee2mqtt configuration.yaml file but with no effect. Also how does it work when there are multiple attributes (click, battery, linkquality for example) for one device?

Strange. That’s exactly how it was described:

Did you restart zigbee2mqtt after changing configuration.yaml?

Quite simple:
image

How does the publish from zigbee2mqtt with attributes then look like? Because if I remember right (it’s a few months back when I configured everything), zigbee2mqtt publishes everything to e.g. statetopic= zigbee2mqtt/cube. So on this you have to filter this publish for the different attributes like battery, action, etc.
Isn’t there json the right thing as its really easy to parse this “string” then?

No, no filter involved. Zigbee2mqtt creates a subtopic for each attribute with its own value. Just look in my screenshot.

If you are interested in details, have a look here:

experimental: output: attribute

After reboot zigbee2mqtt send the payload as expected:

zigbee2mqtt:info  2019-11-26T22:32:58: MQTT publish: topic 'zigbee2mqtt/switch1/linkquality', payload '21'
zigbee2mqtt:info  2019-11-26T22:32:58: MQTT publish: topic 'zigbee2mqtt/switch1/battery', payload '87'
zigbee2mqtt:info  2019-11-26T22:32:58: MQTT publish: topic 'zigbee2mqtt/switch1/click', payload 'on'

I then updated my mqtt.things as followed:

Thing topic switch1 "switch 1" {
Channels:
    Type string : click   [ stateTopic="zigbee2mqtt/switch1/click" ]
}

and kept the .item as it was.
This works but I keep having a warning message:

00:04:38.604 [WARN ] [hab.binding.mqtt.generic.ChannelState] - Command 'off' not supported by type 'OnOffValue': No enum constant org.eclipse.smarthome.core.library.types.OnOffType.off
00:04:38.604 [INFO ] [smarthome.event.ItemStateChangedEvent] - switch1Click changed from ON to OFF

How could I get rid of that warning?

I would also to get rid of the ZigbeeLogType messages (INFO and WARNING) that appears in my log tail every 2 minutes:

00:04:24.253 [INFO ] [smarthome.event.ItemStateChangedEvent] - ZigbeeLogType changed from devices to groups
00:04:24.269 [WARN ] [nternal.JSonPathTransformationService] - JsonPath expressions with more than one result are only supported for Boolean, Number and String data types, please adapt your selector. Result: [{"ieeeAddr":"0x00124b000be89d05","type":"Coordinator","networkAddress":0,"friendly_name":"Coordinator","softwareBuildID":"zStack12","dateCode":"20190608","lastSeen":1574809464259},{"ieeeAddr":"0xccccccfffe924769","type":"EndDevice","networkAddress":63209,"model":"E1743","friendly_name":"switch2","manufacturerID":4476,"manufacturerName":"IKEA of Sweden","powerSource":"Battery","modelID":"TRADFRI on\/off switch","hardwareVersion":1,"softwareBuildID":"2.2.008","dateCode":"20190410","lastSeen":1574809175502},{"ieeeAddr":"0xccccccfffe2fbaa0","type":"EndDevice","networkAddress":47694,"model":"E1525","friendly_name":"Motion Sensor","manufacturerID":4476,"manufacturerName":"IKEA of Sweden","powerSource":"Battery","modelID":"TRADFRI motion sensor","hardwareVersion":1,"softwareBuildID":"2.0.022","dateCode":"20190308","lastSeen":null},{"ieeeAddr":"0xccccccfffe925007","type":"EndDevice","networkAddress":18691,"model":"E1743","friendly_name":"switch1","manufacturerID":4476,"manufacturerName":"IKEA of Sweden","powerSource":"Battery","modelID":"TRADFRI on\/off switch","hardwareVersion":1,"softwareBuildID":"2.2.008","dateCode":"20190410","lastSeen":1574809438004},{"ieeeAddr":"0x000d6ffffeaf6ff8","type":"Router","networkAddress":48108,"model":"E1603\/E1702","friendly_name":"Prise","manufacturerID":4476,"manufacturerName":"IKEA of Sweden","powerSource":"Mains (single phase)","modelID":"TRADFRI control outlet","hardwareVersion":1,"softwareBuildID":"2.0.022","dateCode":"20190308","lastSeen":1574809454446},{"ieeeAddr":"0x000d6ffffefd566c","type":"Router","networkAddress":4667,"model":"E1603\/E1702","friendly_name":"Prise_Denon","manufacturerID":4476,"manufacturerName":"IKEA of Sweden","powerSource":"Mains (single phase)","modelID":"TRADFRI control outlet","hardwareVersion":1,"softwareBuildID":"2.0.022","dateCode":"20190308","lastSeen":null},{"ieeeAddr":"0x000d6ffffefd4f11","type":"Router","networkAddress":20717,"model":"E1603\/E1702","friendly_name":"Prise_Sony","manufacturerID":4476,"manufacturerName":"IKEA of Sweden","powerSource":"Mains (single phase)","modelID":"TRADFRI control outlet","hardwareVersion":1,"softwareBuildID":"2.0.022","dateCode":"20190308","lastSeen":1574807409334},{"ieeeAddr":"0x000d6ffffefc1b85","type":"Router","networkAddress":6524,"model":"E1603\/E1702","friendly_name":"Eclairage_Armoire","manufacturerID":4476,"manufacturerName":"IKEA of Sweden","powerSource":"Mains (single phase)","modelID":"TRADFRI control outlet","hardwareVersion":1,"softwareBuildID":"2.0.022","dateCode":"20190308","lastSeen":1574808391061},{"ieeeAddr":"0x000d6ffffef51948","type":"EndDevice","networkAddress":963,"model":"E1743","friendly_name":"Switch_Armoire1","manufacturerID":4476,"manufacturerName":"IKEA of Sweden","powerSource":"Battery","modelID":"TRADFRI on\/off switch","hardwareVersion":1,"softwareBuildID":"2.0.020","dateCode":"20180921","lastSeen":null},{"ieeeAddr":"0x000d6ffffef34653","type":"EndDevice","networkAddress":43146,"model":"E1743","friendly_name":"Switch_Armoire2","manufacturerID":4476,"manufacturerName":"IKEA of Sweden","powerSource":"Battery","modelID":"TRADFRI on\/off switch","hardwareVersion":1,"softwareBuildID":"2.2.008","dateCode":"20190410","lastSeen":null}]
00:04:24.269 [INFO ] [smarthome.event.ItemStateChangedEvent] - ZigbeeLogType changed from groups to devices

Any suggestions?

1 Like

@regissg, this thread is about mqtt1 & jsonpath solution. Please use the other thread linked above to discuss attribute transmission.

I am trying to add an ikea tradfri outlet linked through zigbee2mqtt.

I am able to switch it from an openhab sitemap. I am also able to switch it from Alexa but in that case the sitemap does not update the outlet state.

when looking at the MQTT traffic with MQTT.fx I could see that in both case the zigbee2mqtt/Prise/state has the proper ON/OFF payload. Same with the Openhab log tail that shows in both case the proper outlet state

Here is my thing setup:

Thing topic Prise "IKEA prise de test" {
Channels:
    Type switch : PowerSwitch "Ikea Prise" [ stateTopic="zigbee2mqtt/Prise/state", commandTopic="zigbee2mqtt/Prise/set", on="on", off="off" ]
}

my item setup

Switch prise1  "Prise de test"  <switch> { channel="mqtt:topic:myMQTTBroker:Prise:PowerSwitch" , alexa="Switchable"}

and my test sitemap

sitemap demo label="Main Menu" {
Frame {
    Switch item=prise1 
       }
}

What could explain that the sitemap does not to update ?

I want to share experience in Aqara Wireless Switch js rules .
I’m new to it so sorry if something is wrong.

for click

(function(x) {
var json = JSON.parse(x);
result=json.click
if (result == null ) { process.exit(-1); }
return result;
})(input)

and action

(function(x) {
var json = JSON.parse(x);
result=json.action
if (result == null ) { process.exit(-1); }
return result;
})(input)

It works for me. Let me know if something is wrong.

Apologies if it’s dump question - if I pair xiaomi/aqara device to universal Ziggbee adapter this device cannot be paired to Xiaomi gateway at the same time - respectively won’t be seen and controlled from Mi Home app, right?

Correct.

Thanks a lot for the immediate reply. So it seems for door/windows sensors and wall switches is good but for ziggbee lights where a lot of adjustments are possible (white color temperature, colors change, brightness, different modes) losing the native all is not a good option.

If the devices you have are supported by zigbee2mqtt, then I don’t think you’ll lose any features.

Yes, I meant not the features itself but their control/adjustment - for example light bulbs settings are very intuitive and well shaped in Mi Home or Phillips Hue apps. For door/window sensors, wall switches or motion sensors from aqara no any special settings/features that are more convenient to be reached by the native app, so it’s absence won’t be noticed from my side. Thanks again!

Hi, help needed.
I want to use Dimmer item for curtains position, but no luck.
If i use Number in things and in items - all ok. When i change Number to Dimmer i got error:

MQTT message received. MqttMessageSubscriber#processMessage implementation failurejava.lang.IllegalArgumentException: Value must be between 0 and 100

But position value is 78 now:

//Zigbee2MQTT:info  2021-02-19 15:20:53: MQTT publish: topic 'z2m/zCurtBed', payload '{"linkquality":57,"options":{"hand_open":false,"reverse_direction":true},"position":78,"running":false}'


My settings with Numer items:

Thing topic zcurtbed "Curtains Position" @ "MQTT"  {
    Channels:
          Type number : position     "Curtains Position"        [ stateTopic="z2m/zCurtBed", commandTopic="z2m/zCurtBed/set", transformationPattern="JSONPATH:$.position", formatBeforePublish="{   \"brightness\": %s }" ] 
    }
Number  zCurtBed_Position        "Curtains Position"                    {channel="mqtt:topic:mosquitto:zcurtbed:position"}

Any suggestions?