From 1acbcf921aa9061af0a43a4ea893f49268f53270 Mon Sep 17 00:00:00 2001 From: G Johansson Date: Fri, 12 Jul 2024 15:50:21 +0200 Subject: [PATCH] Fix schema and strings in template switch (#121843) --- homeassistant/components/template/config_flow.py | 2 +- homeassistant/components/template/strings.json | 4 ++-- homeassistant/components/template/switch.py | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/homeassistant/components/template/config_flow.py b/homeassistant/components/template/config_flow.py index 71eb04d8ad9..e6b7a436084 100644 --- a/homeassistant/components/template/config_flow.py +++ b/homeassistant/components/template/config_flow.py @@ -136,7 +136,7 @@ def generate_schema(domain: str, flow_type: str) -> vol.Schema: if domain == Platform.SWITCH: schema |= { - vol.Required(CONF_VALUE_TEMPLATE): selector.TemplateSelector(), + vol.Optional(CONF_VALUE_TEMPLATE): selector.TemplateSelector(), vol.Optional(CONF_TURN_ON): selector.ActionSelector(), vol.Optional(CONF_TURN_OFF): selector.ActionSelector(), } diff --git a/homeassistant/components/template/strings.json b/homeassistant/components/template/strings.json index 649a1aa3898..2c0a1cdf501 100644 --- a/homeassistant/components/template/strings.json +++ b/homeassistant/components/template/strings.json @@ -68,7 +68,7 @@ "name": "[%key:common::config_flow::data::name%]", "turn_off": "Actions on turn off", "turn_on": "Actions on turn on", - "state": "[%key:component::template::config::step::sensor::data::state%]" + "value_template": "Value template" }, "data_description": { "device_id": "[%key:component::template::config::step::sensor::data_description::device_id%]" @@ -127,7 +127,7 @@ "data": { "device_id": "[%key:common::config_flow::data::device%]", "name": "[%key:common::config_flow::data::name%]", - "state": "[%key:component::template::config::step::sensor::data::state%]", + "value_template": "[%key:component::template::config::step::switch::data::value_template%]", "turn_off": "[%key:component::template::config::step::switch::data::turn_off%]", "turn_on": "[%key:component::template::config::step::switch::data::turn_on%]" }, diff --git a/homeassistant/components/template/switch.py b/homeassistant/components/template/switch.py index f1973ff96d4..e3dca1d5d80 100644 --- a/homeassistant/components/template/switch.py +++ b/homeassistant/components/template/switch.py @@ -63,7 +63,7 @@ PLATFORM_SCHEMA = SWITCH_PLATFORM_SCHEMA.extend( SWICTH_CONFIG_SCHEMA = vol.Schema( { vol.Required(CONF_NAME): cv.template, - vol.Required(CONF_VALUE_TEMPLATE): cv.template, + vol.Optional(CONF_VALUE_TEMPLATE): cv.template, vol.Optional(CONF_TURN_ON): selector.ActionSelector(), vol.Optional(CONF_TURN_OFF): selector.ActionSelector(), vol.Optional(CONF_DEVICE_ID): selector.DeviceSelector(),