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

If you scroll back a few weeks you’ll see the discussion about creating a battery sensor. You can use the following to calculate the battery % which is close to what zigbee2mqtt uses I think. Personally instead of using 3000 (3 volts) as a full battery, I use 3075 in the formula below because I didn’t like so many of my batteries at 100% even after they’ve been in use for months. Even at 3075, I have 2 brand new Xiaomi sensors at 102%. 2700 in the formula below represents a battery near depletion but I’m not sure it shouldn’t be lower. Time will tell.

  - platform: mqtt
    name: Rain Sensor Battery
    state_topic: "zigbee2mqtt/0x00158d0002393f65"
    unit_of_measurement: "%"
    value_template: "{{ ((value_json.voltage - 2700)/(3000-2700)  * 100) | int }}"

Thank you, I think I’m going to use your value template as my sensors are also still showing 100% while being used a lot already. Do you know what formula Zigbee2MQTT uses by default? I can’t find it in the GitHub.

According to this post:
https://community.home-assistant.io/t/zigbee2mqtt-getting-rid-of-your-proprietary-zigbee-bridges-xiaomi-hue-tradfri/52108/623

The formula is:
(in xiaomi_aqara.py -> percent = ((voltage - min_volt) / (max_volt - min_volt)) * 100)

With values of:
const battery3V = {
min: 2700,
max: 3000,
};

Since my sensors were all above 3000v, I set my max to the highest v my sensors had which at the time was 3075. Since then I’ve added 2 new door sensors for my garage doors. At 3075, they are currently showing 102% with my template so I may bump the max up a little bit.

I justed started with Zigbee2mqtt
So I have added 2 devices to

  • xiaomi aqara human body sensor > name = Move_woonkamer
  • LED1545G12 > name = IkeaLed
    Hassio is running on another PI.
    I managend to get the Ikealed working, but not the xiaomi aqara human body sensor
    How can post his/her config?

At the moment I have 3 sensors connected. The Xiaomi cube, the motion with lux sensor and the square temperature sensor. Everything works reliable except the temperature sensor.
It works for about a day and after that it stops reporting the temperature. Rebooting the raspberry pi doesn’t make it work again, but I do get 1 temperature reading in node red. But this temperature value isn’t representative of the current temperature. It’s from the last time it reported the actual temperature.
When I press the connect button of the sensor it starts working again, giving me the actual temperatures again.
What could be wrong? Is my sensor faulty. Is it a software glitch? Common issue with this sensor maybe?

The square temperature sensor is Xiaomi also? My Xiaomi temperature sensor currently works perfectly. The only time I had problems similar to what you posted is when it got a little moisture in it.

I had it sitting on a window sill prior to mounting it permanently below the eave. After a heavy rain, I had major problems with readings and connectivity until I brought it in and let it dry out for a couple of days.

After that the temp and humidity readings have been spot on now that its mounted in a more weatherproof location. Is it located a long distance from the pi?

There’s no config necessary to get that sensor working. Just put the bridge in join mode. While holding the sensor near the bridge, press the little button on the sensor and hold for a few seconds. Then keep pressing the button momentarily until it pairs. While watching and refreshing the zigbee2mqtt log, you should see the sensor pair successfully with the bridge.

Maybe it is moisture then. I did blow some warm air into it with my mouth to check if it worked :wink: Maybe it got wet :smile:
I will let it dry then and see if it works reliable. Still odd that it works for a day.

I have some similar problems with this sensor. It is currently attached to xiaomi hub and works well most of the time. Still sometimes (about once a month) it stops sending updates. It can be fixed by pressing a button but it’s not very convenient anyway.

Posting the config won’t really help, I think. You just need to pair it by (I think) holding down the button on the right until it starts blinking, then pressing the button every second or so. Keep an eye on the log file to see what kind of feedback the sensor is returning.

is there a way to add the hue bulbs without the need of a remote ? maybe sending the reset true the sniffer if that would be possible ?

Edit: a reboot of the Pi fixed my problem.

Original post:
Have any of you had any luck adding more than one of the new Trådfri control outlets? I got one up and running fine, but the two others I have tried refuse to pair.
Running the zigbee2mqtt hass.io addon (edge version).

Hello everyone I have been thinking about trying out zigbee2mqtt but wanted to know if it supported showing devices as offline if they are unplugged/powered off. For example a light bulb that got turned off at the switch. If so does it update when powered back on? I have tried searching but kinda hard to phrase that in a searchable question.

First I want to say that I love the Zigbee2mqtt project and have hopes to exchange my ~20 Xiaomi sensors and other devices to Zigbee2mqtt. I also love the simple and cheap setup with USB CC2531 devices.

I now have the CC2531 working with Zigbee2mqtt (as coordinator) and its functionality is great in test. I also have a few CC2531 devices running the Ptvo cc2531 router and are also working fine in test (did not test routing yet).

But I am worried they don’t have enough RF connectivity to span my 4 layer house (with concrete floors).

Between 1 or 2 floors the connection between Xiaomi gateway and Xiaomi sensors works fine.

But testing the connection between the cc2531 device (as coordinator on 1st floor) and a Xiaomi sensor (2nd floor) the linkquality drops to 10…15 and the connection with the cc2531 router (2nd floor) it shows a linkquality: 0.
So even with using ptvo cc2531 routers it looks like it will be difficult to span my house.

Q: Is there someone who did some hacking for a better antenna on the cc2531 device?

I’m looking to get some extra switches for my z wave lights. Is it possible to use this with a Trådfri dimmer and dim a z wave light? Or any of the other switches with a hold function?

I do the opposite. I use my a GE zwave dimmer in my bedroom’s double tap event to turn my bedside sconces with Tradfri bulbs on and off.

I think you can reset them though the api on the hue bridge but I guess you can only do it once. I was in the same boat but ended up buying a hue dimmer which I think was worth it for the hassle it saved and I use it to control my chromecast audio :slight_smile:

the hint would be to use a cc2530+cc2591 + external antenna.
I own one, I’m going to use it as a coordinator to replace the cc2531 and I’m thinking about re-using a high gain wireless antenna (or something from an old cisco AP)

I’m having the same issue but i have a long house rather than tall. I have the coordinator located central to the home and routers on either side of the length of home but still have bad link quality on devices.

@lolorc, if you try this out, I’m interested to hear of the improvement if any.

Thanks! I know the cc2530 and have one (not in use yet), and I’m very interested if you succeed in having a better link quality with the cc2530+cc2591 as coordinator and cc2531 as zigbee router.

But with the cc2530 or cc2530+cc2591 I miss the hardware simpleness of just plugging in the cc2531 in a usb port on a HA Pi (for the Zigbee2mqtt coordinator) or plugging in the cc2531 in 5 volt usb adapter (for the Zigbee router).

Connecting the cc2530+cc2591 to the HA Pi (or other HA device such as a NUC) takes some cumbersome
wiring as far as I know… isn’t it?