mirror of
https://github.com/home-assistant/core.git
synced 2025-12-25 05:26:47 +00:00
Remove indents and decrease long string in template config file (#155340)
This commit is contained in:
@@ -84,22 +84,26 @@ def validate_binary_sensor_auto_off_has_trigger(obj: dict) -> dict:
|
||||
if CONF_TRIGGERS not in obj and DOMAIN_BINARY_SENSOR in obj:
|
||||
binary_sensors: list[ConfigType] = obj[DOMAIN_BINARY_SENSOR]
|
||||
for binary_sensor in binary_sensors:
|
||||
if binary_sensor_platform.CONF_AUTO_OFF in binary_sensor:
|
||||
identifier = f"{CONF_NAME}: {binary_sensor_platform.DEFAULT_NAME}"
|
||||
if (
|
||||
(name := binary_sensor.get(CONF_NAME))
|
||||
and isinstance(name, Template)
|
||||
and name.template != binary_sensor_platform.DEFAULT_NAME
|
||||
):
|
||||
identifier = f"{CONF_NAME}: {name.template}"
|
||||
elif default_entity_id := binary_sensor.get(CONF_DEFAULT_ENTITY_ID):
|
||||
identifier = f"{CONF_DEFAULT_ENTITY_ID}: {default_entity_id}"
|
||||
elif unique_id := binary_sensor.get(CONF_UNIQUE_ID):
|
||||
identifier = f"{CONF_UNIQUE_ID}: {unique_id}"
|
||||
if binary_sensor_platform.CONF_AUTO_OFF not in binary_sensor:
|
||||
continue
|
||||
|
||||
raise vol.Invalid(
|
||||
f"The auto_off option for template binary sensor: {identifier} requires a trigger, remove the auto_off option or rewrite configuration to use a trigger"
|
||||
)
|
||||
identifier = f"{CONF_NAME}: {binary_sensor_platform.DEFAULT_NAME}"
|
||||
if (
|
||||
(name := binary_sensor.get(CONF_NAME))
|
||||
and isinstance(name, Template)
|
||||
and name.template != binary_sensor_platform.DEFAULT_NAME
|
||||
):
|
||||
identifier = f"{CONF_NAME}: {name.template}"
|
||||
elif default_entity_id := binary_sensor.get(CONF_DEFAULT_ENTITY_ID):
|
||||
identifier = f"{CONF_DEFAULT_ENTITY_ID}: {default_entity_id}"
|
||||
elif unique_id := binary_sensor.get(CONF_UNIQUE_ID):
|
||||
identifier = f"{CONF_UNIQUE_ID}: {unique_id}"
|
||||
|
||||
raise vol.Invalid(
|
||||
f"The auto_off option for template binary sensor: {identifier} "
|
||||
"requires a trigger, remove the auto_off option or rewrite "
|
||||
"configuration to use a trigger"
|
||||
)
|
||||
|
||||
return obj
|
||||
|
||||
|
||||
Reference in New Issue
Block a user