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

Hi, I am using this addon with Hassio. When it is starting I get the following message:

node index.js Zigbee2mqtt requires node version >=8.11 10, you are running v8.11.4!

Then my hassio crash until I remove the CC2531 from the usb port. Just by removing the CC2531 from USB port, HASSIO is revovering.
Does anyone as experience the same issue?

Automatically, or just one-off?

For one-off production of the graph, it’s pretty simple.

In hassio, at the very bottom of the left hand menu, click the second to last option at the bottom (hovertip is “dev-mqtt”). Once in the MQTT “Publish a packet” screen, enter “zigbee2mqtt/bridge/networkmap” in the topic, and “graphviz” in the payload. Click “Publish”.

Then goto the “Hassio” menu, click on the zigbee2mqtt plug-in, then at the bottom of the log it should have published the network map as text.
It will look something like this:

zigbee2mqtt:info 2018-11-16 18:02:55 MQTT publish, topic: ‘zigbee2mqtt/bridge/networkmap/graphviz’, payload: ‘digraph G {
node[shape=record];
“0x00124b0018ed2f8b” [label=“{0x00124b0018ed2f8b|Coordinator|No model information available|online}”];
“0x00124b0018ed2f8b” → “0x0022a300001af914” [label=“249”]
“0x00158d000244e585” [label=“{0x00158d000244e585|EndDevice|Xiaomi MiJia human body movement sensor (RTCGQ01LM)|online}”];
“0x00158d000244e585” → “0x00124b0018ed2f8b” [label=“75”]
“0x00158d00028ed383” [label=“{0x00158d00028ed383|EndDevice|Xiaomi MiJia door & window contact sensor (MCCGQ01LM)|online}”];
“0x00158d00028ed383” → “0x00124b0018ed2f8b” [label=“43”]
“0x0022a3000021e49a” [label=“{0x0022a3000021e49a|Router|GE ZigBee plug-in smart dimmer (45852GE)|offline}”];
“0x0022a3000021e49a” → “0x0022a300001af914” [label=“252”]
“0x00158d00029a9ea8” [label=“{0x00158d00029a9ea8|EndDevice|Xiaomi Aqara human body movement and illuminance sensor (RTCGQ11LM)|online}”];
“0x00158d00029a9ea8” → “0x00124b0018ed2f8b” [label=“21”]
“0x00158d00022878bb” [label=“{0x00158d00022878bb|EndDevice|Xiaomi MiJia wireless switch (WXKG01LM)|online}”];
“0x00158d00022878bb” → “0x00124b0018ed2f8b” [label=“53”]
“0x00158d0001f57f9b” [label=“{0x00158d0001f57f9b|EndDevice|Xiaomi MiJia temperature & humidity sensor (WSDCGQ01LM)|online}”];
“0x00158d0001f57f9b” → “0x00124b0018ed2f8b” [label=“52”]
“0x00158d00020b4c53” [label=“{0x00158d00020b4c53|EndDevice|Xiaomi MiJia human body movement sensor (RTCGQ01LM)|online}”];
“0x00158d00020b4c53” → “0x00124b0018ed2f8b” [label=“39”]
“0x0022a300001af914” [label=“{0x0022a300001af914|Router|GE ZigBee plug-in smart dimmer (45852GE)|online}”];
“0x0022a300001af914” → “0x0022a3000021e49a” [label=“254”]
}’

Copy that, starting with "digraph G " and ending with the last “}” and then go to this website. Paste your graph into the left hand side, and change the engine to “Circo”.

There’s your graph!

4 Likes

@Silicon_Avatar Thanks for the instructions!

I was finally able to get an Xioami sensor to use one of the plugs as a router. Below is the graph that shows the Xiaomi Occupancy sensor using an Iris Smart Plug as a router.

hi, i’m ussing Hassio addon too and getting same error message on bridge logs.

In addition to this, all mi sensors lost connectivity from time to time and all values turn to “unknown”…

It seems to happening since i upgraded HA to version 0.82

How can i update node version to 8.11.10 on hassio?

@chavi78, may I ask you to check if you get the same problem as mine. Can you:

  • open a terminal
  • ping your hassio box (continuous ping)
  • start zigbee2mqtt plugins
  • when it start to report your devices in the log check the ping value : on my side I get up to 20000ms
  • unplug your CC2135 d’ongle and check if it’s come back to normal ping value: around 1ms

Thanks worked a treat!!

I can see my IKEA bulb is connected to the Aqara power switch router, but it still wont power on or off unless i move the lamp within a few metres of the Pi/Sniffer. Makes no difference on that the switch is next to it… doing my head in

Just solved the issue of HASSIO crashing. Uninstall the add on, delete the configuration.yaml and database.db in the share/zigbee2mqtt folder and now everything seems to be fine.

thank you @yaazzz

I’ve solved my issue following your steps too…

Issue is back today:(
It seems it appear when in the log I have the following message but not sure if there is a link:

zigbee2mqtt:info 2018-11-19 20:31:41 
	{"message":"request timeout","stack":"Error: request timeout\n    at CcZnp.<anonymous> (/zigbee2mqtt-0.2.0/node_modules/cc-znp/lib/ccznp.js:255:22)\n    at Object.onceWrapper (events.js:315:30)\n    at emitOne (events.js:116:13)\n    at CcZnp.emit (events.js:211:7)\n    at Timeout.<anonymous> (/zigbee2mqtt-0.2.0/node_modules/cc-znp/lib/ccznp.js:234:18)\n    at ontimeout (timers.js:498:11)\n    at tryOnTimeout (timers.js:323:5)\n    at Timer.listOnTimeout (timers.js:290:5)"}

Does anyone get the same thing?

/usr/bin/socat -d -d pty,raw,echo=0,link=/dev/ttyACM1 tcp-connect:192.168.1.4:1775

1 Like

Hi and thanks for this.
Just a (maybe deeply stupid) question: il could be possible to include in the map the sonoff devices, working in MQTT but directly, not through zigbee2mqtt? they work with the tele/sonoff/ topic…
Thanks a lot again

Answer to myself: it’s only for zigbee2mqtt…

I made a small sh script to generate the map, and to copy it to local (www) dir, in order to be shown on a HA Lovelace card.

#!/bin/bash
D=$(date +%Y%m%d%H%M%S)
mosquitto_sub -V mqttv311 -C 1 -u XXXXXX -P YYYYY -h 192.168.1.xxx -t zigbee2mqtt/bridge/networkmap/graphviz | sed -e 's/|EndDevice//' -e 's/|[^|]\+(.*)|/|/' -e 's/No [^|]\+|//' | sfdp -Tpng > /tmp/map$D.png &
sleep 15s
mosquitto_pub -V mqttv311 -u XXXXXX-P YYYYY -h 192.168.1.xxx -m "graphviz" -t zigbee2mqtt/bridge/networkmap
sleep 15s
sudo cp /tmp/map$D.png /home/homeassistant/.homeassistant/www/map.png
sudo rm -rf /tmp/map$D.png
sudo chown homeassistant:homeassistant /home/homeassistant/.homeassistant/www/map.png

It can be run as daemon with sysctl.
It wipes away the old maps.

2 Likes

I’m using zigbee2mqtt for quite a long time, for xiaomi temperature sensor & xiaomi wireless button. now I bought additional xiaomi aqara motion & illuminance sensor and having some problems setting this up. I mean: it works & reads values correctly [I guess] but I can’t customize it in the way I did it with temperature sensor & button.

so, in the share\zigbee2mqtt\configuration.yaml I’ve got the following:

devices:
  '0x00158d0001c2ce03':
    ##### this is the temperature & humidity sensor WSDCGQ01LM
    friendly_name: sns_bedroom_RAW
    qos: 1
    retain: true
  '0x00158d0001e5f6b4':
    ##### this is the button WXKG01LM
    friendly_name: sns_clicker_RAW
    qos: 1
    retain: true
  '0x00158d00029c0330':
    ##### this is the occupancy sensor with light sensor RTCGQ11LM
    friendly_name: sns_downstairs_RAW
    qos: 1
    retain: true
    occupancy_timeout: 90

as you can see I set my friendly_names so in the further configuration I can adress the sensors/button with it, for example:

sensor:
  - platform: template
    sensors:
      sns_bedroom_temperature:
        value_template: >
          {{ states.sensor.sns_bedroom_RAW_temperature.state | round(1) }}

…and so on - and it works great with all but the newest motion/occupancy sensor. it just ignores my friendly name and makes it’s own ugly [for my OCD ;)] sensor.0x00158d00029c0330_illuminance and binary_sensor.0x00158d00029c0330_occupancy - how can I change it? I tried to force edit the state.json located with zigbee2mqtt configuration file, but with no luck. it comes back to it’s “ugly” state [which is understood, as it is written every change of the state :wink: I guess].

when I tried to bypass this and like in the above temperature sensor example I created additional template:

sensor:
  - platform: template
    sensors:
      sns_downstairs_illuminance:
        value_template: >
          {{ states.sensor.0x00158d00029c0330_illuminance.state }}

but it fails config-check with:
Invalid config for [sensor.template]: invalid template (TemplateSyntaxError: expected token 'end of print statement', got 'x00158d00029c0330_illuminance') for dictionary value @ data['sensors']['sns_downstairs_illuminance ']['value_template']. Got '{{ states.sensor.0x00158d00029c0330_illuminance.state }}\n'. (See ?, line ?). Please check the docs at https://home-assistant.io/components/sensor.template/

both sns_downstairs_illuminance and sns_bedroom_temperature are configured in the same way, and still one of them fails with strange error…

can please somebody point me out to the right direction? or maybe I’m missing something and this is a no-can-do with the occupancy/illuminance sensor?

hi @Silicon_Avatar
i followed your instructions and i got following image:


I’m a little bit concerned about not having any router device, and because i have more than 15 devices paired to my coordinator.
would it affect to system performance?

Yes, I would not be surprised if things were not working as well as they could be.

Perhaps because it seems they are all battery powered devices that are not constantly connected and reporting, that might help not overloading the coordinator?

I’m not 100% sure, or particularly knowledgeable about the specifics of zigbee.

If you are using the CC2531 sniffer as the coordinator, I thought the limit was 15 devices directly connected to it, since the documentation states as much:

The CC2531 USB sniffer zigbee2mqtt firmware has a limit of 15 direct children. This means 1 coordinator + 15 end devices and 0 routers.

However by adding routers to your network you can overcome the limit of 15 devices. This means that, e.g. a network of 1 coordinator, 4 routers and 50 end devices is possible.

But maybe them all being slow reporting battery devices helps.
It’s also odd that only 9 of them are reporting signal strength to the coordinator.

You can pick up some more of the cheap CC2531 sniffers and flash them with router firmware (since you already have the programmer) if you feel better having some on the network, or a wall switch dimmer or anything that’s plugged into mains so is always powered would probably work as a router too.

thanks @Silicon_Avatar

it’s funny you mentioned it , because i already bought another CC2531 yesterday (i’m looking forward to receive it).

However, i’ll uninstall bridge addon and pair all zigbee sensors again , maybe it works…

Just wanted to say I had been seeing inconsistent results with just the CC2531 coordinator stick, even though I live in a open loft and the stick was centrally located.

My Ikea Tradfri lights would work fine if right next to it but some on the far side of my apartment kept falling off the network. Also my Xiaomi buttons were kind of inconsistent. With the Tradfri hub never had any issues, obviously the stick is not nearly as good.

I added 2 CC2531 routers and power cycled all my bulbs and I see a very noticeable improvement in response time. Also seeing a lot more frequent pings from the battery devices and sensors.

So if you are having connection issues with devices, adding routers does seem to fix it.

Very timely subject. I’ve got a CC2531 coordinator attached to a raspberry pi running Mosquitto and zigbeetomqtt, and I’ve got a second CC2531 to act as a router. However, whenever I map the zigbee devices as shown above, all I ever get is a star, ie nothing is connected via the router.
I have attempted to “force” devices to pair via the router by moving them (router and device) a bit farther away from the coordinator and holding the device to be paired directly next to the router, but in that case I end up with this in the log:

info: MQTT publish, topic: ‘zigbee2mqtt/CC2531 Zigbee Router’, payload: ‘{“state”:false,“linkquality”:0}’
warn: No converter available for ‘CC2530.ROUTER’ with cid ‘genOnOff’, type ‘devChange’ and data ‘{“cid”:“genOnOff”,“data”:{“onOff”:0}}’
warn: Please see: GitHub - Koenkk/zigbee2mqtt: Zigbee 🐝 to MQTT bridge 🌉, get rid of your proprietary Zigbee bridges 🔨.
error: Cannot get the Node Descriptor of the Device: 0x84182600000d022c (Error: Timed out
after 10000 ms)

The last line being the id of the device I’m trying to pair, which fails a number of times and then gives up.
I spent quite some time googling last night and couldn’t find a definitive answer, on the CC2531 stick, is it necessary to set the stick to a certain “mode” via the buttons? Some of the issues on github referenced needing to put button 1 in order to set the green light on and enable pairing, but I found no difference in behavior when doing this.
How can you otherwise “force” devices to pair through the router and not directly to the coordinator?

2 Likes

I`m quite shure this ll go under in the amount of messages - But I have a Question.

I think you can define a seccond sniffer by adding them to the configuration with

serial:
  port: /dev/ttyACM1
  port: /dev/ttyACM0

would this distribute the network a little?
Ive got maybe 10 routers - but have the problem that sometimes the rout takes some time.
one of my bulbs for example lost the route and I had to reconfigure it.
(maybe to the offline router?)

nope, there can only be one coordinator in a zigbee network.

some of my router are also marked as offline, but they are not. it’s probably a zigbee-sheperd issue.