From 4170a447fc0f5d0395790576948d3c794aca7058 Mon Sep 17 00:00:00 2001 From: Paul Bottein Date: Mon, 29 Jan 2024 19:26:55 +0100 Subject: [PATCH] Allow system and helper integrations to provide entity_component icons (#109045) --- .../components/automation/icons.json | 18 +++++++++++ script/hassfest/icons.py | 32 ++++++++++--------- 2 files changed, 35 insertions(+), 15 deletions(-) create mode 100644 homeassistant/components/automation/icons.json diff --git a/homeassistant/components/automation/icons.json b/homeassistant/components/automation/icons.json new file mode 100644 index 000000000000..7a95b4070d50 --- /dev/null +++ b/homeassistant/components/automation/icons.json @@ -0,0 +1,18 @@ +{ + "entity_component": { + "_": { + "default": "mdi:robot", + "state": { + "off": "mdi:robot-off", + "unavailable": "mdi:robot-confused" + } + } + }, + "services": { + "turn_on": "mdi:robot", + "turn_off": "mdi:robot-off", + "toggle": "mdi:robot", + "trigger": "mdi:robot", + "reload": "mdi:robot" + } +} diff --git a/script/hassfest/icons.py b/script/hassfest/icons.py index f5e07a0d3482..2b28312284aa 100644 --- a/script/hassfest/icons.py +++ b/script/hassfest/icons.py @@ -70,14 +70,14 @@ def icon_schema(integration_type: str) -> vol.Schema: ), } - base_schema = vol.Schema( + schema = vol.Schema( { vol.Optional("services"): state_validator, } ) - if integration_type == "entity": - return base_schema.extend( + if integration_type in ("entity", "helper", "system"): + schema = schema.extend( { vol.Required("entity_component"): vol.All( cv.schema_with_slug_keys( @@ -89,20 +89,22 @@ def icon_schema(integration_type: str) -> vol.Schema: ) } ) - return base_schema.extend( - { - vol.Optional("entity"): vol.All( - cv.schema_with_slug_keys( + if integration_type not in ("entity", "system"): + schema = schema.extend( + { + vol.Optional("entity"): vol.All( cv.schema_with_slug_keys( - icon_schema_slug(vol.Optional), - slug_validator=translation_key_validator, + cv.schema_with_slug_keys( + icon_schema_slug(vol.Optional), + slug_validator=translation_key_validator, + ), + slug_validator=cv.slug, ), - slug_validator=cv.slug, - ), - ensure_not_same_as_default, - ) - } - ) + ensure_not_same_as_default, + ) + } + ) + return schema def validate_icon_file(config: Config, integration: Integration) -> None: # noqa: C901