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

oke, will give it a try. Tnx

My automation using a Xiaomi wireless button.

  - alias: Drukknop bedlamp rechts schakelt bedlamp links aan-uit dmv single klik
    trigger:
      platform: mqtt
      topic: 'zigbee2mqtt/xiaomi_mijia_sw01'
    condition:
      condition: template
      value_template: "{{ 'single' == trigger.payload_json.click }}"
    action:
      entity_id: light.tlamp02
      service: light.toggle

Your automation should be something like:

  - id: '1529615997019'
    alias: Wandschakelaar badkamer plafond lamp aan
    trigger:
      platform: mqtt
      topic: 'zigbee2mqtt/0x00158d0001834370'
    condition:
      condition: template
      value_template: "{{ 'single' == trigger.payload_json.click }}"
    action:
      entity_id: light.0x000b57fffeb72a6d
      service: light.toggle

Got it working, tnx! still a big noob, steep learning curve for me.

Hi, thank you for the nice tool and job! I have successfully paired Xiaomi temperature sensor, ikea light and ikea dimmer (ICTC-G-1). In HA I see temperature and humidity form the sensor. Can control light (on/off/brightness). Also see dimmer and changing values if I rotate it.
But how to control light with the dimmer? I guess it should be some kind of automation. But I am such a beginner in all this. I tried write something similar what @doubleUS wrote for Xiaomi wireless button, but failed miserably…
Maybe somebody could help me in creating automation for IKEA TRADFRI wireless dimmer?
Thank you!

Is there a reliable method of adding battery voltage of devices to HA? I can see the battery attributes in the mqtt logs but how can I use them in automations?

edit: this is for temp/humidity sensors as well as door and motion sensors (binary). cheers!

@talondnb

I used this as a guide:

MQTT Sensor - Home Assistant

And ended up with this:

  • platform: mqtt
    name: “Temp Sensor Battery”
    state_topic: “zigbee2mqtt/0x00158d0001e7bc14”
    unit_of_measurement: ‘%’
    value_template: “{{ value_json.battery }}”
2 Likes

Awesome, this is it, thanks!

Thanks to @scottdarby for the USB Sniffer, can highly recommend him if anyone in the UK want’s one. Already flashed, ready to go, fast postage.

Got mine setup with two Xiaomi contact sensors (although one sensors seems to be faulty and killing batteries every 2/3 days) and one Xiaomi Temp/Humidity sensors, all works ok so far.

Trying to set it up on with some Hive contact sensors though, but having problems getting it to recognise event’s on them.

Has anyone successfully flashed and using a CC2531 as a router to extend range? Would like to hear your experiences.

I’m having intermittent issues with two contact sensors (xiaomi) and I think it may be down to the signal strength.

I flashed a CC2531 as a router, per the zigbee2mqtt wiki instructions. It seems to work fine for me.

Make sure you’re running the right version of nodejs and npm. I realized that I had the incorrect version of npm (as per the wiki). When running an older version of npm, the CC2531 router would crash zigbee2mqtt when pairing.

Thanks. I’m running the hassio addon so we’ll see.

I think I am in the same boat here and able to help. I just moved all my Xiaomi (only 10 or so) devices over from the aqara hub to a flashed cc2531 stick running zigbee2mqtt. I am using the built in mqtt broker in Home Assistant. HASS and zigbee2mqtt are both running in docker containers.

I’ve only been running this for a couple days now and don’t fully understand it all myself. I’ve been using HASS for a year now and am fairly comfortable with it, but this MQTT stuff is new to me. For the Xiaomi temp sensors and door sensors I have added ‘retain: true’ for those devices in the zigbee2mqtt configuration.yaml in an attempt to get the last status to display in Home Assistant during reboots but it doesn’t seem to last when I reboot the zigbee2mqtt container and the home assistant container. I end up having to wait ~30 mins for values for those devices to re-populate. I also have the following in my home assistant configuration.yaml

birth_message:
topic: 'hass/status'
payload: 'online'
retain: true
  will_message:
topic: 'hass/status'
payload: 'offline'
retain: true

To be honest I don’t fully understand what those different retain: true in the HASS configuration.yaml and the zigbee2mqtt configuration.yaml are intended to do.

Anyway – I can help when I get home. So I am understanding right - you want me to close a door with a sensor on it (verify HASS status shows it as closed), then reboot Home Assistant and then open the door quick while HASS is rebooting and unavailable to the zigbee2mqtt? Then see when HASS comes back up see if it detects the sensor state correctly in the States page? Should I have retain=true set for this sensor I am testing?

For sensors to keep state also needed to add retain:true line to every sensor in sensors:

My Xiaomi sensors don’t show up in my sensors.yaml. Where would I put retain: true ?

I’m using it without “discovery” so every sensor needs to be defined manually from this list:

Doh! Could I add retain: true to customize.yaml for the sensor?

Did anybody been able add the IKEA motion sensor?

I can’t find to get a reliable way of having the battery details appear after adding a new sensor. Once I’ve paired a device, I’ll add the following into sensors.yaml:

- platform: mqtt
  name: Front Door Sensor Battery
  state_topic: "zigbee2mqtt/0x00158d000239f6ee"
  unit_of_measurement: '%'
  value_template: "{{ value_json.battery | int }}"

I’ll restart a few times and wait an hour or so, press the trigger on the sensor to send data, but still no battery detail.

Any suggestions?

Looks like it’s working fine with Hassio too. :slight_smile:

Although it seems you have to manually initiate the router after a bootup?

1 Like

@ryanbeaton do you run any xiaomi motion sensors? Have you managed to get the battery sensor working for them at all?