mirror of
https://github.com/home-assistant/core
synced 2024-10-06 20:17:55 +00:00
Allow system and helper integrations to provide entity_component icons (#109045)
This commit is contained in:
parent
be4631cbf8
commit
4170a447fc
18
homeassistant/components/automation/icons.json
Normal file
18
homeassistant/components/automation/icons.json
Normal file
|
@ -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"
|
||||
}
|
||||
}
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue