Allow MQTT entities to be disabled by default#48284
Conversation
|
@Koenkk can you comment on if this would be useful for zigbee2mqtt? the idea is that the signal strength sensor (for example) is announced Home Assistant, but the user has to opt-in by enabling it |
|
@emontnemery the feature looks useful but I haven't seen anyone requesting this yet. |
|
@Koenkk It is a relatively recent feature. We try to disable/hide the less common things by default. It helps with things like performance, reduces the amount of historical data and keeps the state engine cleaner. |
|
I guess this indeed makes sense for e.g. the linkquality sensor, the values changes often while probably (almost) nobody looks at it. For the Zigbee2MQTT use case this linkquality can also be viewed via the "main" entity of the device (e.g. light) since the linkquality is included in the |
That should actually be removed... as that is a different measurement and should have its own entity (disabled by default 😉 ). We are phasing out state attributes that should have been their own sensor in general. Those attributes still trigger unneeded state changes for their entities. |
|
@frenck will |
There's no such plan (that I'm aware of), but the attributes are not meant for providing sub sensors, stuff like signal quality etc. should live in their own sensors |
|
No direct plan on deprecating those. We, however, reject "sensors" hidden in state attributes for new integrations or integrations that are refactored. It's simply harder for the end-user to control/use them (+ all the other stuff mentioned before). With the introduction of the concept of devices, it became no needed anymore as well. |
| @property | ||
| def entity_registry_enabled_default(self) -> bool: | ||
| """Return if the entity should be enabled when first added to the entity registry.""" | ||
| return self._config.get(CONF_ENABLED_BY_DEFAULT) |
There was a problem hiding this comment.
Since the key is always there, use square brackets. If you want to have teh default live here and not in the config schema, remove default=True from MQTT_ENTITY_COMMON_SCHEMA
Proposed change
Allow MQTT entities to be disabled by default
The purpose is to allow sub entities, for example a signal strength sensor for a zigbee light, to be hidden until actively enabled by the use.
Any disabled entities will be removed together with the device when the last enabled entity is removed through MQTT discovery.
Type of change
Example discovery message:
{ "platform": "mqtt", "name": "RSSI sensor", "state_topic": "test-topic", "device": {"identifiers": ["123"]}, "enabled_by_default": false, "unique_id": "veryunique" }Additional information
Checklist
black --fast homeassistant tests)If user exposed functionality or configuration variables are added/changed:
If the code communicates with devices, web services, or third-party tools:
Updated and included derived files by running:
python3 -m script.hassfest.requirements_all.txt.Updated by running
python3 -m script.gen_requirements_all..coveragerc.The integration reached or maintains the following Integration Quality Scale:
To help with the load of incoming pull requests: