Skip to content

Commit

Permalink
Don't allow changing device class in template binary sensor options (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
emontnemery authored and bramkragten committed Sep 6, 2023
1 parent 067f946 commit 6f6306b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
8 changes: 4 additions & 4 deletions homeassistant/components/template/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,11 @@
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(
Expand Down Expand Up @@ -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"),
)


Expand All @@ -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"),
)


Expand Down
1 change: 0 additions & 1 deletion homeassistant/components/template/strings.json
Original file line number Diff line number Diff line change
Expand Up @@ -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%]"
Expand Down

0 comments on commit 6f6306b

Please sign in to comment.