zigbee2mqtt icon indicating copy to clipboard operation
zigbee2mqtt copied to clipboard

[Feature request]: Customize HA discovery and/or disable discovery on a per-device basis

Open nateww opened this issue 1 year ago • 8 comments

Is your feature request related to a problem? Please describe

I have a Zigbee thermostat (https://www.zigbee2mqtt.io/devices/Zen-01-W.html) setup to controller my in-floor heating system. As such, when I configure the thermostat, it has no cooling mode OR fan-mode. Unfortunately, the default discovery sends out discovery for both the cooling mode and fan-mode, which causes multiple errors, and then one annoyance. Because the fan , and one error. First, the device can not be created properly, because the thermostat does not report the fan-mode, causing the following to appear in the home-assistant logs.

 [homeassistant.helpers.template] Template variable warning: 'dict object' has no attribute 'fan_mode' when rendering '{{ value_json.fan_mode }}'
[homeassistant.helpers.template] Template variable warning: 'dict object' has no attribute 'occupied_cooling_setpoint' when rendering '{{ value_json.occupied_cooling_setpoint }}'

The fix is to update the configuration to remove these from the discovery config line.

Similarly, the default discovery template also sets both the high/low setpoint for the thermostat, which has no value in my setup (and the thermostat doesn't actually support this functionality as configured in my environment).

Since I had to modify the HA configuration anyway, it was trivial to remove the extra functionality and create a custom HA configuration that only contains the functionality my thermostat supports.

Describe the solution you'd like

Unfortunately, everytime Zigbee2MQTT restarts, it over-writes my customized discovery line. One solution is to disable HA discovery. However, I have dozens of other devices (and am constantly adding/removing devices on a fairly regular basis as I build out my new house), so I'd rather not disable discovery completely.

Two solutions come to mind:

  1. Allow a configuration item (in the devices perhaps) that would allow me to disable discovery for a single device. Then, I could create a custom discovery topic JUST for the misbehaving device. This would allow me to leave HA discovery on for the dozens of other devices.
  2. Allow me to customize the discovery information on a per-device basis. Then, I could remove the fan properties from the discovery (ie; suppress that functionality from the discovery payload) and thus have a long-term solution that doesn't require me to create custom MQTT messages at startup.

These are two potential solutions I've considered, but perhaps others have ideas I haven't considered.

Describe alternatives you've considered

Disabling discovery completely, and then manually creating discovery topics for all of my devices. This is both error-prone, and removes one of the single-biggest advantage to Zigbee2MQTT, which is auto-configuration setup of Zigbee devices.

Additional context

I have researched the documentation as well as looked through the historical record, and I couldn't find anything of note that indicates it was possible to accomplish what I was hoping for.

https://www.zigbee2mqtt.io/guide/usage/integrations/home_assistant.html#overriding-discovery-properties

I attempted to decode the above information, and it wasn't obvious (to me) how to customize the discovery properties to modify and/or suppress existing discovery properties, or a way to disable discovery for a particular device.

nateww avatar Feb 13 '24 21:02 nateww