mirror of
https://github.com/home-assistant/developers.home-assistant.git
synced 2025-08-04 06:57:41 +00:00
Make entity registry disabled_by an enum (#1144)
This commit is contained in:
parent
448c7c2335
commit
a630547686
@ -5,7 +5,7 @@ sidebar_label: Disabling entities
|
|||||||
|
|
||||||
The entity registry tracks all entities with unique IDs. For each entity, the registry keeps track of options that impact how the entity interacts with the core. One of these options is `disabled_by`.
|
The entity registry tracks all entities with unique IDs. For each entity, the registry keeps track of options that impact how the entity interacts with the core. One of these options is `disabled_by`.
|
||||||
|
|
||||||
When `disabled_by` is set to a string value, the entity will not be added to Home Assistant when the integration passes it to `async_add_entities`.
|
When `disabled_by` is set and not `None`, the entity will not be added to Home Assistant when the integration passes it to `async_add_entities`.
|
||||||
|
|
||||||
## Integration Architecture
|
## Integration Architecture
|
||||||
|
|
||||||
@ -15,21 +15,21 @@ Entity disabling works with entities provided via a config entry or via an entry
|
|||||||
|
|
||||||
## Users editing the entity registry
|
## Users editing the entity registry
|
||||||
|
|
||||||
One way an entity can be disabled is by the user editing the entity registry via the UI. In this case, the `disabled_by` value will be set to `user`. This will only work with entities that are already registered.
|
One way an entity can be disabled is by the user editing the entity registry via the UI. In this case, the `disabled_by` value will be set to `RegistryEntryDisabler.USER`. This will only work with entities that are already registered.
|
||||||
|
|
||||||
## Integrations setting default value of disabled_by for new entity registry entries
|
## Integrations setting default value of disabled_by for new entity registry entries
|
||||||
|
|
||||||
As an integration you can control if your entity is enabled when it is first registered. This is controlled by the `entity_registry_enabled_default` property. It defaults to `True`, which means the entity will be enabled.
|
As an integration you can control if your entity is enabled when it is first registered. This is controlled by the `entity_registry_enabled_default` property. It defaults to `True`, which means the entity will be enabled.
|
||||||
|
|
||||||
If the property returns `False`, the `disabled_by` value of the newly registered entity will be set to `integration`.
|
If the property returns `False`, the `disabled_by` value of the newly registered entity will be set to `RegistryEntryDisabler.INTEGRATION`.
|
||||||
|
|
||||||
## Config entry system options setting default value of disabled_by for new entity registry entries
|
## Config entry system options setting default value of disabled_by for new entity registry entries
|
||||||
|
|
||||||
The user can also control how new entities that are related to a config entry are received by setting the system option `disable_new_entities` of a config entry to `True`. This can be done via the UI.
|
The user can also control how new entities that are related to a config entry are received by setting the system option `disable_new_entities` of a config entry to `True`. This can be done via the UI.
|
||||||
|
|
||||||
If an entity is getting registered and this system option is set to `True`, the `disabled_by` property will be initialized as `config_entry`.
|
If an entity is getting registered and this system option is set to `True`, the `disabled_by` property will be initialized as `RegistryEntryDisabler.CONFIG_ENTRY`.
|
||||||
|
|
||||||
If `disable_new_entities` is set to `True` and `entity_registry_enabled_default` returns `False`, the `disabled_by` value will be set to `integration`.
|
If `disable_new_entities` is set to `True` and `entity_registry_enabled_default` returns `False`, the `disabled_by` value will be set to `RegistryEntryDisabler.INTEGRATION`.
|
||||||
|
|
||||||
## Integrations offering options to control disabled_by
|
## Integrations offering options to control disabled_by
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user