Add aliases to entity registry items (#84239)
This commit is contained in:
parent
8ca92254b6
commit
1f3da9cf1a
5 changed files with 36 additions and 3 deletions
|
@ -102,6 +102,7 @@ def websocket_get_entity(
|
|||
vol.Required("type"): "config/entity_registry/update",
|
||||
vol.Required("entity_id"): cv.entity_id,
|
||||
# If passed in, we update value. Passing None will remove old value.
|
||||
vol.Optional("aliases"): list,
|
||||
vol.Optional("area_id"): vol.Any(str, None),
|
||||
vol.Optional("device_class"): vol.Any(str, None),
|
||||
vol.Optional("icon"): vol.Any(str, None),
|
||||
|
@ -160,6 +161,10 @@ def websocket_update_entity(
|
|||
if key in msg:
|
||||
changes[key] = msg[key]
|
||||
|
||||
if "aliases" in msg:
|
||||
# Convert aliases to a set
|
||||
changes["aliases"] = set(msg["aliases"])
|
||||
|
||||
if "disabled_by" in msg and msg["disabled_by"] is None:
|
||||
# Don't allow enabling an entity of a disabled device
|
||||
if entity_entry.device_id:
|
||||
|
@ -265,6 +270,7 @@ def _entry_dict(entry: er.RegistryEntry) -> dict[str, Any]:
|
|||
def _entry_ext_dict(entry: er.RegistryEntry) -> dict[str, Any]:
|
||||
"""Convert entry to API format."""
|
||||
data = _entry_dict(entry)
|
||||
data["aliases"] = entry.aliases
|
||||
data["capabilities"] = entry.capabilities
|
||||
data["device_class"] = entry.device_class
|
||||
data["options"] = entry.options
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue