Howto use zigbee2mqtt with openHAB, removing proprietary bridges / gateways

zigbee
mqtt
xiaomi
Tags: #<Tag:0x00007f51e1b09160> #<Tag:0x00007f51e1b08b98> #<Tag:0x00007f51e1b08710>

(M) #102

Danke!! (Bin auch Deutscher btw)…


(JT) #103

Just wondering if anyone has any experience with the Xiaomi “Vibration” sensor.
Just curious to know if it’s an actual vibration sensor or a more simple tilt and movement sensor.
Anyone know what kind of data is exposed by the sensor?


(Stefan) #104

Continuing the discussion from Howto use zigbee2mqtt with openHAB, removing proprietary bridges / gateways:

I want openHAB control my IKEA tradfri lighting. I am using openHAB 2.4 with the new mqtt binding (2.4). If my understanding is correct, this Howto is designed for the old 1.x binding and I have to do some changes to get things working with 2.4 binding. (I think the MQTT binding in my openhab configuration as well as zigbee2mqtt are working. I use some Aqara sensors which deliver values as expected to openHAB.)

I started with the initial example:

Switch IKEAE27_TOGGLE "IKEAE27 [%s]" <light> {mqtt=">[broker:zigbee/IKEAE27/set:command:*:JS(setZigbeeState.js)],<[broker:zigbee/IKEAE27:state:JSONPATH($.state)]", expire="120m,command=OFF"}

Within PaperUI I created a Generic MQTT Thing for the Ikea tradfri lighting:

IKEA Tradfri 001
Generic MQTT Thing
mqtt:topic:50cfd56d

Then I added some channels (state, brightness, color_temp, …). Here’s what I entered for the state channel:

Channel Type: Text value
Channel id: state
Label: state
MQTT state topic: zigbee2mqtt/0x000b57fffe9dafee
MQTT command topic: zigbee2mqtt/0x000b57fffe9dafee/set
Incoming value transformation: JSONPATH:$.state
IS command: checked 

Here started my problems… Will it work using channel type “Text value” or do I have to use another channel type? And what about the JavaScript transformation (setZigbeeState.js)?

Well, afterwards I created an item as follows:

Switch  FF_Bedroom_Light "Licht Schlafzimmer [%s]" <dimmablelight> { channel="mqtt:topic:50cfd56d:state" }

Neither does my item show any value nor does it send anything via mqtt when I change its state.


(Fraser Howell) #105

You are correct that V2 requires a different setup.

You need to send command to Zigbee2MQTT in JSON format like the below.

{"state":"ON","brightness":255}

That’s what the js files do.

I had some bulbs working in V2 - see post Howto use zigbee2mqtt with openHAB, removing proprietary bridges / gateways

But I had some issues so I went back to V1 and used the scripts from the examples. Now I have some more time I’m having a play to get it working in V2 to my taste.

The above example was done in text files and not PaperUI.

Here’s a screenshot of what on of my bulb items looks like in PaperUI


(Stefan) #106

This was clear to me but I did not know how to post it via MQTT without the JavaScript transformation. Your screenshot saved my life:

Outgoing value format: { "brightness": %s }

I used it in my “state”-channel as follows, which works perfectly with my described switch item:

Outgoing value format: { "state": "%s" }

Thanks a lot for your help!