Zigbee2mqtt: Feature request. Make `retain: true` the default for some kind of devices

Created on 5 Apr 2020  Â·  7Comments  Â·  Source: Koenkk/zigbee2mqtt

Bug Report

Well, this is not actually a bug, but the current behaviour, that I think should be changed.

What happened

I'm using z2m with Home Assistant. I have several Aqara temp/humidity sensors and Aqara door sensor.
The problem is that when I restart Home Assistant I need to wait some time for the temp/humidity to appear in the interface. (And in the case of door sensor it is always "closed" after the restart)

The solution is simple. Just edit /usr/share/hassio/share/zigbee2mqtt/devices.yaml and add retain: true to the device description:

'0x00158d000422fde9':
  friendly_name: '0x00158d000422fde9'
  retain: true

What did you expect to happen

I'm not an expert in zigbee2mqtt nor in Home Assistant. My expectation was that zigbee2mqtt default setting is to send messages with retain flag, to prevent confusing behaviour.

I can't say for any type of devices, but for temp/humidity sensors and for door sensors I can't imagine situation when somebody needs to disable sending retain flag.

So, I would like to propose a feature — make the default retain: true for some kind of devices to simplify initial configuration for the users.

How to reproduce it (minimal and precise)

Debug Info

zigbee2mqtt version: 1.9.0
CC253X firmware version: not sure

stale

Most helpful comment

Setting retain true for all devices can easily be done with (https://www.zigbee2mqtt.io/information/configuration.html#changing-device-type-specific-defaults)

device_options:
  retain: true

All 7 comments

I actually think there should be a universal "retain" flag that applies to all devices. 100% of my devices have retain set, and I would guess that is true of the vast majority of z2m users.

I think that's the point of the birth/will message as shown here, to fix this problem:
https://www.zigbee2mqtt.io/integration/home_assistant.html

Do you have Home Assistant configured to use those?

Setting retain true for all devices can easily be done with (https://www.zigbee2mqtt.io/information/configuration.html#changing-device-type-specific-defaults)

device_options:
  retain: true

Setting retain true for all devices can easily be done with (https://www.zigbee2mqtt.io/information/configuration.html#changing-device-type-specific-defaults)

device_options:
  retain: true

My apologies for missing that. I read that in the documentation, but still did not understand exactly how to use device_options: in the configuration.yaml.

Are there other examples of configuration.yaml files this use device_options? Maybe another real-world example would make it more clear to me.

Is it just as simple as adding this to the configuration.yaml:

device_options:
  retain: true

Yes it's as simple as that.

Yes it's as simple as that.

Thanks. Not sure why I was making it so hard. Sorry for the dumb/newbie questions.

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

pepp86 picture pepp86  Â·  4Comments

Courty40 picture Courty40  Â·  4Comments

tb-killa picture tb-killa  Â·  3Comments

RefineryX picture RefineryX  Â·  4Comments

jwilling picture jwilling  Â·  4Comments