Allow to set icon based on state

This commit is contained in:
Paul Bottein 2024-09-11 14:18:06 +02:00
parent 9614a8d1ca
commit 71f89dd759
No known key found for this signature in database
2 changed files with 19 additions and 3 deletions

View File

@ -163,7 +163,16 @@ def websocket_get_entities(
# remove the entity from the category.
vol.Optional("categories"): cv.schema_with_slug_keys(vol.Any(str, None)),
vol.Optional("device_class"): vol.Any(str, None),
vol.Optional("icon"): vol.Any(str, None),
vol.Optional("icon"): vol.Any(
vol.Schema(
{
vol.Required("default"): str,
vol.Optional("state"): dict,
}
),
str,
None,
),
vol.Optional("labels"): [str],
vol.Optional("name"): vol.Any(str, None),
vol.Optional("new_entity_id"): str,

View File

@ -138,6 +138,13 @@ class _EventEntityRegistryUpdatedData_Update(TypedDict):
old_entity_id: NotRequired[str]
class EntityRegistryEntryIcon(TypedDict):
"""Icon state definition for entity registry."""
default: str
state: dict[str, str] | None
type EventEntityRegistryUpdatedData = (
_EventEntityRegistryUpdatedData_CreateRemove
| _EventEntityRegistryUpdatedData_Update
@ -1035,7 +1042,7 @@ class EntityRegistry(BaseRegistry):
disabled_by: RegistryEntryDisabler | None | UndefinedType = UNDEFINED,
entity_category: EntityCategory | None | UndefinedType = UNDEFINED,
hidden_by: RegistryEntryHider | None | UndefinedType = UNDEFINED,
icon: str | None | UndefinedType = UNDEFINED,
icon: str | EntityRegistryEntryIcon | None | UndefinedType = UNDEFINED,
has_entity_name: bool | UndefinedType = UNDEFINED,
labels: set[str] | UndefinedType = UNDEFINED,
name: str | None | UndefinedType = UNDEFINED,
@ -1162,7 +1169,7 @@ class EntityRegistry(BaseRegistry):
disabled_by: RegistryEntryDisabler | None | UndefinedType = UNDEFINED,
entity_category: EntityCategory | None | UndefinedType = UNDEFINED,
hidden_by: RegistryEntryHider | None | UndefinedType = UNDEFINED,
icon: str | None | UndefinedType = UNDEFINED,
icon: EntityRegistryEntryIcon | str | UndefinedType = UNDEFINED,
has_entity_name: bool | UndefinedType = UNDEFINED,
labels: set[str] | UndefinedType = UNDEFINED,
name: str | None | UndefinedType = UNDEFINED,