Zigbee2mqtt: getting rid of your proprietary Zigbee bridges (Xiaomi, Hue, TRADFRI)

from this page in the wiki,

I don’t have mine setup and running at the moment, as the hive devices I bought it for aren’t supported, and are beyond my scope of adding them in, and the person that was working on them seem’s to have gone quiet, but an example from the page above,

devices: 
  '0x00158d0001d82999':
    friendly_name: 'my_occupancy_sensor'
    retain: true
    occupancy_timeout: 20
    qos: 1

But if you haven’t set up a friendly name then,

friendly_name: Used in the MQTT topic of a device. By default this is the device ID (e.g. 0x00128d0001d9e1d2).

Hope this helps out again.

It does! I now only seem to have a conflict with mqtt, but will investigate into it later on when I’m back at my desk. Thanks @Cee

Check entity_registry.yaml on double entries.

Thanks @kitus,
Just received the latest batch if anyone’s interested in a pre-flashed device PM me!

I love when one accomplishes something relevant. I’ve now just managed to switch on and off a Tradfri bulb using a xiaomi button, with no gateways in between!!!

I feel however that there is some room for improvement. I hope you guys can help me figure out a couple of things:

  1. I just paired the bulb, and configuration.yaml (zigbee2mqtt) did already display the new device with the friendly unfriendly name. I then edited the name but the entity in HA showed of course the previous unfriendly name. Do I really need to restart HA everytime I add a new device?
  2. When the system came up, it showed the Xiaomi button with state unknown and the tradfri light as off. Neither of both states was right because as soon as I clicked on the button, the light went off. This leads me to the main question: How do you guys harden your configuration (not only for this add-on but generally speaking) so that when you reboot your system, you reach a known state before accepting newer updates from the world?

Many thanks and congratulations to @Koenkk and the team. This is AWESOME!!

Well, it seems I was lucky enough with the two first devices I tried to add to Zigbee2mqtt because, as reported just above, it worked very well. However, I’ve decided to add two additional devices and it seems they don’t work:

  1. Xiaomi PIR: It seems the system sees it during pairing, and does embrace it a little bit different than with the Xiaomi switch (that’s at least my humble interpretation if I compare the log they both generated during the pairing process. And zigbee2mqtt is not fully recognizing the PIR based on what the log suggests:

    2018-7-29 02:09:14 INFO Currently 4 devices are joined:
    2018-7-29 02:09:14 INFO pulsador_xiaomi_test (0x00158d000252b7a5): WXKG01LM - Xiaomi MiJia wireless switch (EndDevice)
    2018-7-29 02:09:14 INFO kitchen_bulb (0x000b57fffedc1058): LED1623G12 - IKEA TRADFRI LED bulb E27 1000 lumen, dimmable, opal white (Router)
    2018-7-29 02:09:14 INFO tradfri.bulb-corridor (0x90fd9ffffe4bf6fd): LED1545G12 - IKEA TRADFRI LED bulb E26/E27 980 lumen, dimmable, white spectrum, opal white (Router)
    2018-7-29 02:09:14 INFO xiaomi.movement-kitchen (0x00158d000251f830): unkown - undefined unknown (EndDevice)

And, regarless what I try, the PIR detector will simply not appear on the entity view in States (Entities) view, whereas the other 3 do appear in there

  1. The second tradfri bulb that I just added to the system, can’t seem to be commanded by Home Assistant (it does not react when I turn it on or off in HA interface. If I review the log I see warning messages:

    2018-7-29 02:12:25 WARN Cannot handle MQTT message with topic ‘zigbee2mqtt/tradfri.bulb-corridor/set’ and message ‘{“state”: “ON”}’
    2018-7-29 02:12:31 WARN Cannot handle MQTT message with topic ‘zigbee2mqtt/tradfri.bulb-corridor/set’ and message ‘{“state”: “ON”}’
    2018-7-29 02:13:17 WARN Cannot handle MQTT message with topic ‘zigbee2mqtt/tradfri.bulb-corridor/set’ and message ‘{“state”: “ON”}’

On this note, I’ve seen there is a PR created for addressing a similar case TRADFRI bulb E27 opal 1000lm · Issue #21 · Koenkk/zigbee2mqtt · GitHub with a very similar IKEA bulb, but it looks like it was solved in May. Does anybody have an “IKEA TRADFRI LED bulb E26/E27 980 lumen” and is successfully using it with Z2MQTT?

I’m also attaching the full log I see in the add-on in case it helped understand what is going on:

    >[Info] Configuration file found. Will overwrite configurable               fields with values from add-on configuration
    [Info] Configuration written to /share/zigbee2mqtt/configuration.yaml
    [2018-07-29T02:08:58.721Z] PM2 log: Launching in no daemon mode
    [2018-07-29T02:08:59.639Z] PM2 log: Starting execution sequence in -fork mode- for app name:npm id:0
    [2018-07-29T02:08:59.746Z] PM2 log: App name:npm id:0 online
    > [email protected] start /app
    > node index.js
    2018-7-29 02:09:09 INFO Starting zigbee2mqtt version 0.1.1 (commit #738c31c)
    2018-7-29 02:09:09 INFO Starting zigbee-shepherd
    2018-7-29 02:09:14 INFO zigbee-shepherd started
    2018-7-29 02:09:14 INFO Currently 4 devices are joined:
    2018-7-29 02:09:14 INFO pulsador_xiaomi_test (0x00158d000252b7a5): WXKG01LM - Xiaomi MiJia wireless switch (EndDevice)
    2018-7-29 02:09:14 INFO kitchen_bulb (0x000b57fffedc1058): LED1623G12 - IKEA TRADFRI LED bulb E27 1000 lumen, dimmable, opal white (Router)
    2018-7-29 02:09:14 INFO tradfri.bulb-corridor (0x90fd9ffffe4bf6fd): LED1545G12 - IKEA TRADFRI LED bulb E26/E27 980 lumen, dimmable, white spectrum, opal white (Router)
    **2018-7-29 02:09:14 INFO xiaomi.movement-kitchen (0x00158d000251f830): unkown - undefined unknown (EndDevice)**
    2018-7-29 02:09:14 WARN `permit_join` set to  `true` in configuration.yaml.
    2018-7-29 02:09:14 WARN Allowing new devices to join.
    2018-7-29 02:09:14 WARN Set `permit_join` to `false` once you joined all devices.
    2018-7-29 02:09:14 INFO Zigbee: allowing new devices to join.
    2018-7-29 02:09:14 INFO Connecting to MQTT server at mqtt://core-mosquitto:1883
    2018-7-29 02:09:14 INFO zigbee-shepherd ready
    2018-7-29 02:09:14 INFO Connected to MQTT server
    2018-7-29 02:09:14 INFO MQTT publish, topic: 'zigbee2mqtt/bridge/state', payload: 'online'
    2018-7-29 02:09:14 INFO MQTT publish, topic: 'homeassistant/sensor/0x00158d000252b7a5/click/config', payload: '{"icon":"mdi:toggle-switch","value_template":"{{ value_json.click }}","json_attributes":["battery","voltage","action","duration"],"state_topic":"zigbee2mqtt/pulsador_xiaomi_test","availability_topic":"zigbee2mqtt/bridge/state","name":"pulsador_xiaomi_test"}'
    2018-7-29 02:09:14 INFO MQTT publish, topic: 'homeassistant/light/0x000b57fffedc1058/light/config', payload: '{"brightness":true,"platform":"mqtt_json","command_topic":"zigbee2mqtt/kitchen_bulb/set","state_topic":"zigbee2mqtt/kitchen_bulb","availability_topic":"zigbee2mqtt/bridge/state","name":"kitchen_bulb"}'
    2018-7-29 02:09:14 INFO MQTT publish, topic: 'homeassistant/light/0x90fd9ffffe4bf6fd/light/config', payload: '{"brightness":true,"color_temp":true,"platform":"mqtt_json","command_topic":"zigbee2mqtt/tradfri.bulb-corridor/set","state_topic":"zigbee2mqtt/tradfri.bulb-corridor","availability_topic":"zigbee2mqtt/bridge/state","name":"tradfri.bulb-corridor"}'
    spinlock: false []
    spinlock: true []
    2018-7-29 02:09:21 INFO Device incoming...
    **2018-7-29 02:09:21 INFO MQTT publish, topic: 'zigbee2mqtt/bridge/log', payload: '{"type":"pairing","message":"device incoming"}'**
**    2018-7-29 02:09:26 INFO Device incoming...**
    2018-7-29 02:09:26 INFO MQTT publish, topic: 'zigbee2mqtt/bridge/log', payload: '{"type":"pairing","message":"device incoming"}'
    2018-7-29 02:10:54 INFO Zigbee publish to '0x000b57fffedc1058', genOnOff - on - {} - null
    2018-7-29 02:10:54 INFO MQTT publish, topic: 'zigbee2mqtt/kitchen_bulb', payload: '{"state":"ON"}'
    2018-7-29 02:10:55 INFO MQTT publish, topic: 'zigbee2mqtt/kitchen_bulb', payload: '{"state":"ON"}'
    2018-7-29 02:10:57 INFO Zigbee publish to '0x000b57fffedc1058', genOnOff - off - {} - null
    2018-7-29 02:10:58 INFO MQTT publish, topic: 'zigbee2mqtt/kitchen_bulb', payload: '{"state":"OFF"}'
    2018-7-29 02:10:58 INFO MQTT publish, topic: 'zigbee2mqtt/kitchen_bulb', payload: '{"state":"OFF"}'
    2018-7-29 02:10:59 INFO Zigbee publish to '0x000b57fffedc1058', genOnOff - on - {} - null
    2018-7-29 02:10:59 INFO MQTT publish, topic: 'zigbee2mqtt/kitchen_bulb', payload: '{"state":"ON"}'
    2018-7-29 02:11:00 INFO MQTT publish, topic: 'zigbee2mqtt/kitchen_bulb', payload: '{"state":"ON"}'
    2018-7-29 02:11:00 INFO Zigbee publish to '0x000b57fffedc1058', genOnOff - off - {} - null
    2018-7-29 02:11:00 INFO MQTT publish, topic: 'zigbee2mqtt/kitchen_bulb', payload: '{"state":"OFF"}'
    2018-7-29 02:11:01 INFO MQTT publish, topic: 'zigbee2mqtt/kitchen_bulb', payload: '{"state":"OFF"}'
    **2018-7-29 02:11:38 WARN Cannot handle MQTT message with topic 'zigbee2mqtt/tradfri.bulb-corridor/set' and message '{"state": "ON"}'**
    2018-7-29 02:11:47 WARN Cannot handle MQTT message with topic 'zigbee2mqtt/tradfri.bulb-corridor/set' and message '{"state": "ON"}'
    2018-7-29 02:11:50 INFO Zigbee publish to '0x000b57fffedc1058', genOnOff - on - {} - null
    2018-7-29 02:11:50 INFO MQTT publish, topic: 'zigbee2mqtt/kitchen_bulb', payload: '{"state":"ON"}'
    2018-7-29 02:11:51 INFO MQTT publish, topic: 'zigbee2mqtt/kitchen_bulb', payload: '{"state":"ON"}'
    2018-7-29 02:11:52 INFO Zigbee publish to '0x000b57fffedc1058', genOnOff - off - {} - null
    2018-7-29 02:11:52 INFO MQTT publish, topic: 'zigbee2mqtt/kitchen_bulb', payload: '{"state":"OFF"}'
    2018-7-29 02:11:52 INFO MQTT publish, topic: 'zigbee2mqtt/kitchen_bulb', payload: '{"state":"OFF"}'
    spinlock: false []
    device already in network
    2018-7-29 02:12:25 WARN Cannot handle MQTT message with topic 'zigbee2mqtt/tradfri.bulb-corridor/set' and message '{"state": "ON"}'
    2018-7-29 02:12:31 WARN Cannot handle MQTT message with topic 'zigbee2mqtt/tradfri.bulb-corridor/set' and message '{"state": "ON"}'
    2018-7-29 02:13:17 WARN Cannot handle MQTT message with topic 'zigbee2mqtt/tradfri.bulb-corridor/set' and message '{"state": "ON"}'
    2018-7-29 02:13:44 INFO Zigbee publish to '0x000b57fffedc1058', genOnOff - on - {} - null
    2018-7-29 02:13:44 INFO MQTT publish, topic: 'zigbee2mqtt/kitchen_bulb', payload: '{"state":"ON"}'
    2018-7-29 02:13:45 INFO MQTT publish, topic: 'zigbee2mqtt/kitchen_bulb', payload: '{"state":"ON"}'
    2018-7-29 02:13:47 INFO Zigbee publish to '0x000b57fffedc1058', genOnOff - off - {} - null
    2018-7-29 02:13:47 INFO MQTT publish, topic: 'zigbee2mqtt/kitchen_bulb', payload: '{"state":"OFF"}'
    2018-7-29 02:13:48 INFO MQTT publish, topic: 'zigbee2mqtt/kitchen_bulb', payload: '{"state":"OFF"}'
    2018-7-29 02:16:37 INFO MQTT publish, topic: 'zigbee2mqtt/kitchen_bulb', payload: '{"state":"OFF"}'

Does anybody have any idea what may be going on with the PIR detector and the second IKEA bulb? The fact that I managed to pair and command the first IKEA bulb almost effortlessly, and now the second bulb is not propperly working is a bit weird.

  1. I see these messages poping up every now and then

    2018-7-29 10:56:34 INFO MQTT publish, topic: ‘zigbee2mqtt/kitchen_bulb’, payload: ‘{“state”:“OFF”}’
    2018-7-29 10:56:48 INFO Device incoming…
    2018-7-29 10:56:48 INFO MQTT publish, topic: ‘zigbee2mqtt/bridge/log’, payload: ‘{“type”:“pairing”,“message”:“device incoming”}’
    2018-7-29 10:59:35 INFO MQTT publish, topic: ‘zigbee2mqtt/pulsador_xiaomi_test’, payload: ‘{“click”:“single”}’

    but I don’t really know what they mean. Any ideas?

Thanks in advance everyone,

I can pick up the battery level through the gateway, are you saying it doesn’t come through for Zigbee2mqtt?

    kitchen_window_battery:
      value_template: '{{ states.binary_sensor.door_window_sensor_158d0001a4e17b.attributes.battery_level }}'

Just ordered my parts from AliExpress, and definitely looking forward to removing the Hub.
Thanks @Koenkk and team!!

Yeah so the switches show the battery level but the door sensors (binary sensors) and also the motion sensor (just added this weekend) dont show hte battery levels within HA.

They do present over MQTT just not in HA:

Received message on zigbee2mqtt/xds1bedroom: b'{"battery":"100.00","voltage":3035,"contact":true}'

Door and Motion:
1

Sensors:
2

This will display a seperate sensor for the battery within HA for the Sensor:

   - platform: template
     sensors:
       xiaomi_rb1_battery_sensor:
         friendly_name: 'Xiaomi Round Button 1 - Battery'
         value_template: '{{ states.sensor.xrb1bedroom.attributes.battery }}'
         unit_of_measurement: '%' 

But the same wont work for the binary sensors:

   - platform: template
     sensors:
       xiaomi_ds1_battery_sensor:
         friendly_name: 'Xiaomi Door Sensor 1 - Battery'
         value_template: '{{ states.binary_sensor.xds1bedroom.attributes.battery }}'
         unit_of_measurement: '%'

Yes, I am seeing the same.

I have a Xioami human presence and illuminance sensor (giving a HA binary sensor and a HA sensor) and a Xiaomi leak detection sensor (giving a HA binary sensor).

Both devices publish battery level and voltage to MQTT (although in an inconsistent fashion - not usually for a while after a restart), but only the HA sensor shows them.

Good to know, It must be coding in HA then thats not pulling in/allowing the data for binary_sensors.

I dont have any other binary_sensors that use a battery level to test with.

1 Like
  1. You indeed need to restart HA (limitation of MQTT discovery)
  2. You can set retain: true for the TRADFRI bulb to have the state on startup. See link

Hi, yes I added the retain: true and it seems to have done the trick thanks!

Thanks @Koenkk,

could you possibly review this other post that I made after that one: Zigbee2mqtt: getting rid of your proprietary Zigbee bridges (Xiaomi, Hue, TRADFRI) ?

Would like to know your feedback?

Hello everyone,

I have 2 ikea bulbs that were correctly paired but have started to act up a bit. Is there anyway one can double check whether they are still in the network? a sort of a “zigbee layer ping”?

The z2mqtt addon does see them while starting up.

thanks

  1. That means you did not completely complete the pairing process, try repairing and keep pressing the reset button for a longer time.
  2. I have this bulb and it is working, are you sure it is within range?
  3. Could this be the bulb from 2?
  1. That’s what I thought, but today I came across this video and all of the sudden I started to wonder whether I was doing something wrong: https://youtu.be/uhMrcIAdGxg

  2. Good tip!! many thanks @Koenkk

  1. how weird. I pressed it like a maniac and attempted pairing several times in a row. Will keep pressing the button longer and report back.
  2. It is absolutely within range and it has previously worked well with IKEA hub.
  3. Mmmm, fair point! I will disconnect the bulb from electricity and monitor the log.

@Koenkk, there is something fishy with the uplink from my home system towards my router devices. Initially I thought that the problem was limited to IKEA bulbs acting up a bit, but I’m now just through with setting up a Xiaomi power switch, with same results.

Here you can see how the two bulbs won’t accept orders comming from HA
2018-7-30 02:03:24 WARN Cannot handle MQTT message with topic ‘zigbee2mqtt/kitchen.light.1.tradfri/set’ and message ‘{“state”: “ON”}’
2018-7-30 02:03:48 INFO MQTT publish, topic: ‘zigbee2mqtt/kitchen.occupancy.xiaomi’, payload: ‘{“occupancy”:false}’
2018-7-30 02:04:45 WARN Cannot handle MQTT message with topic ‘zigbee2mqtt/corridor.light.1.tradfri/set’ and message ‘{“state”: “ON”}’
2018-7-30 02:04:45 WARN Cannot handle MQTT message with topic ‘zigbee2mqtt/corridor.light.1.tradfri/set’ and message ‘{“state”: “ON”}’

Zigbee2MQTT seems to recognize them as valid devices when it starts up:

2018-7-30 01:13:18 INFO kitchen.light.1.tradfri (0x000b57fffedc1058): LED1623G12 - IKEA TRADFRI LED bulb E27 1000 lumen, dimmable, opal white (Router)
2018-7-30 01:13:18 INFO corridor.light.1.tradfri (0x90fd9ffffe4bf6fd): LED1545G12 - IKEA TRADFRI LED bulb E26/E27 980 lumen, dimmable, white spectrum, opal white (Router)

same with the freshly installed power switch:

2018-7-30 02:53:03 WARN Cannot handle MQTT message with topic 'zigbee2mqtt/power-plug.1.xiaomi/set' and message 'ON'
2018-7-30 02:53:10 WARN Cannot handle MQTT message with topic 'zigbee2mqtt/power-plug.1.xiaomi/set' and message 'ON'
2018-7-30 02:53:18 WARN Cannot handle MQTT message with topic 'zigbee2mqtt/power-plug.1.xiaomi/set' and message 'ON'
2018-7-30 02:53:43 WARN Cannot handle MQTT message with topic 'zigbee2mqtt/power-plug.1.xiaomi/set' and message 'ON'
2018-7-30 02:53:43 INFO Zigbee: allowing new devices to join.
2018-7-30 02:53:48 INFO Zigbee: disabling joining new devices.
2018-7-30 02:53:56 WARN Cannot handle MQTT message with topic 'zigbee2mqtt/power-plug.1.xiaomi/set' and message 'ON'

but when I manually switch the power switch on, HA gets updated (the UI reflects it by flapping the radio button). This is what leds me to think that the communication path between the usb stick and the devices is somehow experiencing problems, while the retune path seems to work just fine: I see accupancy sensors information being displayed in HA, door sensors do appear in HA just right too, and now seeing that the power switch informs HA as well.

I’ve now switched the debug level to “debug” but I don’t get much more information on what is going on, apart of the message I reported earlier:

2018-7-30 10:37:42 INFO Switching log level to 'debug'
2018-7-30 10:37:50 DEBUG Check online 0x000b57fffedc1058
2018-7-30 10:37:50 DEBUG Check online 0x90fd9ffffe4bf6fd
2018-7-30 10:37:50 DEBUG Check online 0x00158d00022f35ca
2018-7-30 10:37:56 DEBUG Recieved mqtt message on topic 'zigbee2mqtt/power-plug.1.xiaomi/set' with data 'ON'
2018-7-30 10:37:56 WARN Cannot handle MQTT message with topic 'zigbee2mqtt/power-plug.1.xiaomi/set' and message 'ON'
2018-7-30 10:38:50 DEBUG Check online 0x000b57fffedc1058
2018-7-30 10:38:50 DEBUG Check online 0x90fd9ffffe4bf6fd
2018-7-30 10:38:50 DEBUG Check online 0x00158d00022f35ca
2018-7-30 10:39:50 DEBUG Check online 0x000b57fffedc1058
2018-7-30 10:39:50 DEBUG Check online 0x90fd9ffffe4bf6fd
2018-7-30 10:39:50 DEBUG Check online 0x00158d00022f35ca
2018-7-30 10:40:50 DEBUG Check online 0x000b57fffedc1058
2018-7-30 10:40:50 DEBUG Check online 0x90fd9ffffe4bf6fd
2018-7-30 10:40:50 DEBUG Check online 0x00158d00022f35ca
2018-7-30 10:40:55 DEBUG Recieved zigbee message with data {"cid":"genBasic","data":{"65281":{"3":34,"5":12,"7":"0x0000000000000000","8":4886,"9":256,"100":0,"149":0.0014568129554390907,"150":2240,"152":0,"154":16}}}
2018-7-30 10:40:55 INFO MQTT publish, topic: 'zigbee2mqtt/power-plug.1.xiaomi', payload: '{"state":"OFF","power":0,"voltage":224,"consumption":0,"temperature":34}'
2018-7-30 10:40:55 DEBUG Recieved zigbee message with data {"cid":"genBasic","data":{"65281":[null,null,null,null,null,12,null,"0x0000000000000000",4886,256,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,0,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,2240,null,0,null,16]}}
2018-7-30 10:41:50 DEBUG Check online 0x000b57fffedc1058

I don’t see much information around the relevant message:
2018-7-30 10:37:56 WARN Cannot handle MQTT message with topic ‘zigbee2mqtt/power-plug.1.xiaomi/set’ and message 'ON’

Does anybody have any experience with similar behaviour with Routers? Can anybody please advice what to do?

Thanks

I’ve been having 2 issues with my TRADFRI lights so far.

First of all, some of my lights keep trying to repair with my zigbee router and flashing.
This shows up in the log:

spinlock: false []
device already in network

Any ideas why this is happening?

Second of all, I’ve been having quite a bit of lag with some of the lights. When I try to turn on/off a light group, most of the time, only a few of the lights in the group turn off, while the rest need a few tries to actually turn on/off. I’ve checked the wifi channel in my apartment and it’s on 1, but due to living in a small apartment, there is a lot of other 2.4GHz wifi channels in the area, some on channel 11 too. Is there anything I can do to reduce the lag? It didn’t seem to happen when I used the TRADFRI gateway though.

My Ikea bulbs do that I think, along with this too. Can you confirm?

2018-7-29 10:56:48 INFO Device incoming…
2018-7-29 10:56:48 INFO MQTT publish, topic: ‘zigbee2mqtt/bridge/log’, payload: ‘{“type”:“pairing”,“message”:“device incoming”}’