mirror of
https://github.com/home-assistant/core.git
synced 2025-07-09 14:27:07 +00:00
Don't allow changing device class in template binary sensor options (#99720)
This commit is contained in:
parent
067f946129
commit
6f6306b39b
@ -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"),
|
||||
)
|
||||
|
||||
|
||||
|
@ -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%]"
|
||||
|
Loading…
x
Reference in New Issue
Block a user