Don't allow changing device class in template binary sensor options (#99720)

This commit is contained in:
Erik Montnemery 2023-09-06 15:59:30 +02:00 committed by Bram Kragten
parent 067f946129
commit 6f6306b39b
2 changed files with 4 additions and 5 deletions

View File

@ -40,11 +40,11 @@ from .template_entity import TemplateEntity
NONE_SENTINEL = "none"
def generate_schema(domain: str) -> dict[vol.Marker, Any]:
def generate_schema(domain: str, flow_type: str) -> dict[vol.Marker, Any]:
"""Generate schema."""
schema: dict[vol.Marker, Any] = {}
if domain == Platform.BINARY_SENSOR:
if domain == Platform.BINARY_SENSOR and flow_type == "config":
schema = {
vol.Optional(CONF_DEVICE_CLASS): selector.SelectSelector(
selector.SelectSelectorConfig(
@ -124,7 +124,7 @@ def options_schema(domain: str) -> vol.Schema:
"""Generate options schema."""
return vol.Schema(
{vol.Required(CONF_STATE): selector.TemplateSelector()}
| generate_schema(domain),
| generate_schema(domain, "option"),
)
@ -135,7 +135,7 @@ def config_schema(domain: str) -> vol.Schema:
vol.Required(CONF_NAME): selector.TextSelector(),
vol.Required(CONF_STATE): selector.TemplateSelector(),
}
| generate_schema(domain),
| generate_schema(domain, "config"),
)

View File

@ -33,7 +33,6 @@
"step": {
"binary_sensor": {
"data": {
"device_class": "[%key:component::template::config::step::sensor::data::device_class%]",
"state": "[%key:component::template::config::step::sensor::data::state%]"
},
"title": "[%key:component::template::config::step::binary_sensor::title%]"