Make Switch as x platform options translatable (#130443)

Make Switch as x options translatable
This commit is contained in:
Joost Lekkerkerker 2024-11-14 19:45:42 +01:00 committed by GitHub
parent a97090e0d5
commit a1e3c7513b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 21 additions and 7 deletions

View File

@ -18,12 +18,12 @@ from homeassistant.helpers.schema_config_entry_flow import (
from .const import CONF_INVERT, CONF_TARGET_DOMAIN, DOMAIN from .const import CONF_INVERT, CONF_TARGET_DOMAIN, DOMAIN
TARGET_DOMAIN_OPTIONS = [ TARGET_DOMAIN_OPTIONS = [
selector.SelectOptionDict(value=Platform.COVER, label="Cover"), Platform.COVER,
selector.SelectOptionDict(value=Platform.FAN, label="Fan"), Platform.FAN,
selector.SelectOptionDict(value=Platform.LIGHT, label="Light"), Platform.LIGHT,
selector.SelectOptionDict(value=Platform.LOCK, label="Lock"), Platform.LOCK,
selector.SelectOptionDict(value=Platform.SIREN, label="Siren"), Platform.SIREN,
selector.SelectOptionDict(value=Platform.VALVE, label="Valve"), Platform.VALVE,
] ]
CONFIG_FLOW = { CONFIG_FLOW = {
@ -35,7 +35,9 @@ CONFIG_FLOW = {
), ),
vol.Optional(CONF_INVERT, default=False): selector.BooleanSelector(), vol.Optional(CONF_INVERT, default=False): selector.BooleanSelector(),
vol.Required(CONF_TARGET_DOMAIN): selector.SelectSelector( vol.Required(CONF_TARGET_DOMAIN): selector.SelectSelector(
selector.SelectSelectorConfig(options=TARGET_DOMAIN_OPTIONS), selector.SelectSelectorConfig(
options=TARGET_DOMAIN_OPTIONS, translation_key="target_domain"
),
), ),
} }
) )

View File

@ -26,5 +26,17 @@
} }
} }
} }
},
"selector": {
"target_domain": {
"options": {
"cover": "[%key:component::cover::title%]",
"fan": "[%key:component::fan::title%]",
"light": "[%key:component::light::title%]",
"lock": "[%key:component::lock::title%]",
"siren": "[%key:component::siren::title%]",
"valve": "[%key:component::valve::title%]"
}
}
} }
} }