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

Hi, my experience with zigbee is not really positive to be honest. Is it normal that the network is really fragile and not dynamic at all? Yesterday I had big issue - I have around 40devices and 2 routers (CC2530 + CC2591). I disconnected power to one router for few minutes and then discovered that some of my devices won’t work. The router somehow didn’t reconnect to the network. It looked like some other device connected to the remaining router and exhausted the 21devices/router limit and the second router couldn’t connect anymore? I don’t understand it in more detail. I tried re-pairing the router but it didn’t work (tried removing existing working devices but it didn’t help). Also couldn’t pair any new device. Only those previously removed. The only thing that helped was to re-flash firmware to the coordinator CC2531.

Also I added another router to the network and was thinking that this kind of mesh networks are somewhat dynamic - meaning if some router is disconnected all devices will find different way. Maybe not right now but in few minutes/on second button press etc. But instead those devices connected to the specific router just stopped responding and that is it. I also had to press pair button on like 10% of my devices to get them working again (even overnight they didn’t fix themself) - don’t know if it is xiaomi’s fault that the device will go to some “forever sleep” state if it fails to communicate for X hours or what…

How well is it supposed to work/is working for you? I have feeling that my network is fragile as glass and can break any moment. Some of my friends asked me to recommend “something like I have” but I really can’t recommend to someone system unstable as this…

Hi Atlantis,

sometimes I face similar issues. Yesterday, one of my ZigBee routers lost the connection and consequently all Xiaomi door sensors paired to this router as well. This is, in particular, a problem because, as pointed out in the zigbee2mqtt documentation, certain Xiaomi enddevices tend to stick to their paired router/coordinator and do not automatically reconnect to another working router/coordinator. Consequently, they remain isolated and offline. Do you also use Xiaomi sensors?

In order to fix this problem yesterday, I have tried to repair the router which didn’t work for no obvious reason. After about 1 1/2 hours of numerous trail & error I came to the conclusion that it is definitely not a software problem and that the problem must be related to the hardware of this particular router.

Ikea Tradfri bulbs also cause issues. They act as router which is, in principle, quite nice. However, sometimes they attend some kind of sleep mode and all Xiaomi sensors paired to the bulb remain isolated for quite some time. There are several bug reports on this issue too. Do you use Ikea Tradfri bulbs?

Thank you.
I tried this in the first time…what can be wrong?

Can I test it somehow step by step?

Or…can I put instead of sensor a value somehow to see if i can turn on a light (just to avoid any zigbee device for the moment)?

strange…it’s working now…

Hi, yes, all my sensors/buttons are xiaomi ones.
As routers I only have CC2530 + CC2591. No IKEA lamps etc…As a matter of fact I don’t have any device (except of those routers) that is plugged in power

For CC2531 coordinator and two routers with only Xiaomi devices (around 30) there have been at least four occasions in 6 months where I had to reflash one of the routers as it did not connect anymore (not the same device). I did not had to reflash the devices connected to that node, though.

After migrating to CC26X2R1 (and removing the routers) there was not a single issue.

Pairing of devices with CC2531 had to be done at less than one meter (and some times failing) while with CC26X2R1 it went through 3 walls on the first try.

Connection quality is also significantly improved (above 80 for most devices), while with CC2531 it was even less than 10 through one wall.

Hi again,

Another problem…
I’m using an Aqara water leak sensor…

What is wrong in the code?
I tried with “false” also…

For sure, is something in value_template…

I got this from mqtt:

zigbee2mqtt:info  2020-01-24 20:51:46: MQTT publish: topic 'zigbee2mqtt/0x00158*', payload '{"battery":100,"voltage":3025,"linkquality":34,"water_leak":false}'

Thank you!

- id: detectie_apa_notificare
  alias: detectie_apa_notificare
  trigger:
    platform: mqtt
    topic: 'zigbee2mqtt/0x00158d0001c3482b'
  condition:
    condition: template
    value_template: '{{ "true" == trigger.value_json.water_leak }}'
  action:
    entity_id: switch.switch11
    service: switch.turn_on

It uses on/off in HA :wink:

You can confirm using the states tab on the developer page :+1:

I have a lot of problems with zigbee2mqtt.
I’m using 40 xiaomi devices (mainly human body, door/windows and temperature/humidity Xiaomi sensors).
Since some weeks ago I had a network of one CC2531 coordinator and two CC2531 routers… and all worked fine.

Then I bought three CC2531 with the antenna, flashed its with last coordinator and router firmware and upgraded zigbee2mqtt to last version 1.9.0 on my Hassio v. 0.104.2. Then I replaced the old CC2531 without antenna.
I shoutdown Hassio and restart again.
A lot of the zigbee devices are recognized by zigbee2mqtt (i see them in the log) but do not works.
Sometime after I try to make pairing again they works, but are not stable. Not all devices I’m able to pair again.
If I use Zigbee2mqtt Assistant I see that only few devices are linked to the routers.
What do you suggest to me?
Please help me!!!

Try this : shutdown zigbee2mqtt and remove your coordinator for an hour. Then plug in your coordinator again and start zigbee2mqtt again. Xiaomi devices are notorious for sticking to their old route (your old CC2531 sticks).

I did it now…
After 1 hour I restarted Hassio with the coordionator… but now only half of Aqara devices works

Thank you! That solved my problem. Now all zigbee devices retain their status after restart.

1 Like

I was wondering if anyone could at least point me in the direction of where to look… I have an Aqara double wall switch, it was paired with Z2M without issue and then I deleted the entity of the “right button” from this switch in HA by mistake. Now, whatever I do I can’t get the “right button” entity created in HA. Pairing and re-pairing creates all the normal sensors plus the “left button” entity but not the “right button”.

In addition, I migrated a different (single button) Aqara switch to Z2M from Aqara gateway, and I’m only getting “Linkquality” sensor created for it in HA but nothing else. I see both devices in my network map and can control them via MQTT directly.

I tried: removing both devices from Z2M and re-pairing several times, uninstalling and re-installing both Mosquitto and Z2M add-ons. Every time result is the same.

Thank you!

Could you try setting up the switch manually?

On Zigbee2mqtt site there is a manual setup example for every device.

First of all make sure that you can see the event of the rich button in the z2m logs.

You could try to search for this entity in the core.entity_registry file (in the invisible .storage folder, you can find this folder in same directory as your config.yaml file) to see if it’s still there (and maybe some setting is set there to deactivate it) to maybe it made a second entity with _2 ending. But be careful with that file, as wrong changes will make your homeassisant unable to restart.
If that doesn’t help you should maybe describe, how/where you deleted your entity by mistake.

I did try defining both of them manually but to my surprise nothing happened. Unless I screwed something up of course.

I can see all the entities in there… the right button of the double switch and all 3 “missing” entities of the single key switch. Does this tell us anything?

I can also see discovery messages as well as updates in the corresponding topics in HA log for the missing entities. Like this:

Log extract
2020-02-03 23:13:21 DEBUG (MainThread) [homeassistant.components.mqtt] Received message on homeassistant/switch/0x00158d0003245435/switch_right/config (retained): b'{"payload_off":"OFF","payload_on":"ON","value_template":"{{ value_json.state_right }}","command_topic":"zigbee2mqtt/upstairs_lobby_light_switch/right/set","state_topic":"zigbee2mqtt/upstairs_lobby_light_switch","json_attributes_topic":"zigbee2mqtt/upstairs_lobby_light_switch","name":"upstairs_lobby_light_switch_switch_right","unique_id":"0x00158d0003245435_switch_right_zigbee2mqtt","device":{"identifiers":["zigbee2mqtt_0x00158d0003245435"],"name":"upstairs_lobby_light_switch","sw_version":"Zigbee2mqtt 1.9.0","model":"Aqara double key wired wall switch without neutral wire. Doesn\'t work as a router and doesn\'t support power meter (QBKG03LM)","manufacturer":"Xiaomi"},"availability_topic":"zigbee2mqtt/bridge/state"}'

2020-02-03 23:13:21 INFO (MainThread) [homeassistant.components.mqtt.discovery] Found new component: switch 0x00158d0003245435 switch_right

I removed the switch from the entities list in configuration > entities in HA.

Hi everyone!

I am blocked in a problem that I am not able to get out of and prevents me from advancing in the use of Hassio.

I have four xiaomi devices, two motion and lighting sensors, and two door / window sensors.

I installed mosquitto broker in hassio, and it connects me well or I think so, with my username and password (by the way I don’t know if it is necessary to use a separate user only for mqtt or have to use the main HA user).

I put the code to see if you can help me

Mosquitto broker configuration:

{
  "logins": [
    {
      "username": "username",
      "password": "password"
    }
  ],
  "anonymous": false,
  "customize": {
    "active": false,
    "folder": "mosquitto"
  },
  "certfile": "fullchain.pem",
  "keyfile": "privkey.pem",
  "require_certificate": false
}

This is the mosquitto broker connection log

[22:28:59] INFO: Setup mosquitto configuration
[22:28:59] INFO: Found local users inside config
[22:28:59] INFO: Initialize Hass.io Add-on services
[22:28:59] INFO: Initialize Home Assistant discovery
[22:28:59] INFO: Start Mosquitto daemon
1580246939: mosquitto version 1.6.3 starting
1580246939: Config loaded from /etc/mosquitto.conf.
1580246939: Loading plugin: /usr/share/mosquitto/auth-plug.so
1580246939: |-- *** auth-plug: startup
1580246939:  ├── Username/password checking enabled.
1580246939:  ├── TLS-PSK checking enabled.
1580246939:  └── Extended authentication not enabled.
1580246939: Opening ipv4 listen socket on port 1883.
1580246939: Opening ipv6 listen socket on port 1883.
1580246939: Opening websockets listen socket on port 1884.
1580246939: Opening ipv4 listen socket on port 8883.
1580246939: Opening ipv6 listen socket on port 8883.
1580246939: Opening websockets listen socket on port 8884.
1580246940: Warning: Mosquitto should not be run as root/administrator.
1580246940: New connection from 172.30.32.1 on port 1883.
[INFO] found "nombre de usuario" on local database
1580246940: New client connected from 172.30.32.1 as mqttjs_03eea5ef (p2, c1, k60, u'nombre de usuario').
1580246953: New connection from 172.30.32.1 on port 1883.
1580246953: New client connected from 172.30.32.1 as c5a1e42c590d4bb798b9945d8f80d0c1 (p2, c1, k15, u'nombre de usuario').

I also installed zigbee2mqtt with this configuration:

{
  "data_path": "/share/zigbee2mqtt",
  "devices": "devices.yaml",
  "groups": "groups.yaml",
  "homeassistant": true,
  "permit_join": false,
  "mqtt": {
    "base_topic": "zigbee2mqtt",
    "server": "mqtt://ipraspberry",
    "user": "username",
    "password": "password"
  },
  "serial": {
    "port": "/dev/ttyACM0"
  },
  "advanced":
  . . .

And this is part of the zigbee2mqtt connection log:

./run.sh: line 17: [Info] Configuration backup found in /share/zigbee2mqtt/.configuration.yaml.bk. Skipping config backup.: No such file or directory
[Info] Socat is DISABLED and not started
2020-01-28T22:36:21: PM2 log: Launching in no daemon mode
2020-01-28T22:36:21: PM2 log: App [npm:0] starting in -fork mode-
2020-01-28T22:36:21: PM2 log: App [npm:0] online
> [email protected] start /zigbee2mqtt-1.9.0
> node index.js
zigbee2mqtt:info  2020-01-28 22:36:25: Logging to console and directory: '/share/zigbee2mqtt/log/2020-01-28.22-36-25'
zigbee2mqtt:info  2020-01-28 22:36:26: Starting zigbee2mqtt version 1.9.0 (commit #unknown)
zigbee2mqtt:info  2020-01-28 22:36:26: Starting zigbee-herdsman...
zigbee2mqtt:info  2020-01-28 22:36:28: zigbee-herdsman started
zigbee2mqtt:info  2020-01-28 22:36:28: Coordinator firmware version: '{"type":"zStack12","meta":{"transportrev":2,"product":0,"majorrel":2,"minorrel":6,"maintrel":3,"revision":20190608}}'
zigbee2mqtt:info  2020-01-28 22:36:28: Currently 2 devices are joined:
zigbee2mqtt:info  2020-01-28 22:36:28: sensor_entrada_principal (0x0015...): MCCGQ11LM - Xiaomi Aqara door & window contact sensor (EndDevice)
zigbee2mqtt:info  2020-01-28 22:36:28: sensor_puerta_garaje (0x0015...): RTCGQ11LM - Xiaomi Aqara human body movement and illuminance sensor (EndDevice)
zigbee2mqtt:info  2020-01-28 22:36:28: Zigbee: disabling joining new devices.
zigbee2mqtt:info  2020-01-28 22:36:28: Connecting to MQTT server at mqtt://iddelaraspberry
zigbee2mqtt:info  2020-01-28 22:36:29: Connected to MQTT server
zigbee2mqtt:info  2020-01-28 22:36:29: MQTT publish: topic 'zigbee2mqtt/bridge/state', payload 'online'
zigbee2mqtt:info  2020-01-28 22:36:29: MQTT publish: topic 'zigbee2mqtt/sensor_entrada_principal', payload '{"battery":91,"voltage":2985,"contact":true,"linkquality":63}'
zigbee2mqtt:info  2020-01-28 22:36:29: MQTT publish: topic 'zigbee2mqtt/sensor_puerta_garaje', payload '{"battery":100,"voltage":3015,"illuminance":3,"linkquality":18,"occupancy":false}'
zigbee2mqtt:info  2020-01-28 22:36:29: MQTT publish: topic 'zigbee2mqtt/bridge/config', payload '{"version":"1.9.0","commit":"unknown","coordinator":{"type":"zStack12","meta":{"transportrev":2,"product":0,"majorrel":2,"minorrel":6,"maintrel":3,"revision":20190608}},"log_level":"info","permit_join":false}'

The zigbee2mqtt log shows me all the changes that occur in the sensors correctly.

I have done tests with the windows desktop application MQTT.fx, and it shows me the devices, the changes that occur in them, etc.
I think the zigbee network is working correctly.

But the problem comes in Hassio, where, I don’t know why, I don’t get the devices to appear as an entity, or automatically (I have the discovery a true in configuration.yaml) or adding the devices manually as per figure in the official documentation.
I no longer know what to do, I tried to uninstall the addons and reconfigure in case I had made mistakes, to install everything from 0 on the raspberry, to change parameters over and over again) but I don’t get any of the sensors to appear as an entity , so I can’t do anything with them.

I had many ideas for my home, but I refuse to buy anything until I am able to configure and use these devices.

Forgive my level of English, the message is as translated by Google

I hope my problem is understood
Thanks

For the missing entities, which value do you have for "disabled_by":?
If it is not null than try it out.
Should look like this:

"disabled_by": null,

Try it with only one entity first and remember the value it had before (set it to the old value if it did not help).

1 Like

I have some progress :slight_smile: All of the missing entities were set to "disabled_by": "user", so I changed them to null and it helped with entities from the single button switch. The right button of the double switch didn’t come back though.

Don’t change it to none, change it to null like I mentioned above.

Yes, sorry, misstype. I changed it to null
But it didn’t help with the stubborn right button :-/