Hi,
I am currently working on a seemingly simple blueprint to turn off climate entities when a window is opened. I have everything neatly organized in areas in home assistant so i am trying to use them to dynamically pass the entities to the automation via the area name. The only thing that does not work yet is the trigger of the automation. Here is the Blueprint:
blueprint:
name: Climate Pause
description: Automatically pauses the thermostats in an area when windows/doors are open and resumes when closed, based on the selected area.
domain: automation
input:
area:
description: Select the area where the climate entities and window sensors are located.
name: Area
selector:
area: {}
pause_delay:
description: Time to wait before pausing the heating.
name: Pause Delay
default:
hours: 0
minutes: 0
seconds: 30
selector:
duration: {}
resume_delay:
description: Time to wait before resuming the heating.
name: Resume Delay
default:
hours: 0
minutes: 2
seconds: 0
selector:
duration: {}
variables:
area: !input area
climate_entities: >
{{
expand(states.climate)
| selectattr('entity_id', 'in', area_entities(area))
| map(attribute='entity_id')
| list
}}
doors_windows: >
{{
expand(states.binary_sensor)
| selectattr('entity_id', 'in', area_entities(area))
| selectattr('attributes.device_class', 'eq', 'window')
| map(attribute='entity_id')
| list
}}
name_id:
'{{ area |lower |replace('' '',''_'')
| regex_replace(find=''[^\w]'', replace='''') ~ ''_climate_snapshot'' }}'
mode: single
trigger:
- platform: template
value_template: >-
{{ expand(doors_windows) | selectattr('state', 'eq', 'on') | list | length > 0}}
action:
- service: scene.create
data:
scene_id: "{{ name_id }}"
snapshot_entities: "{{ climate_entities }}"
- service: climate.set_temperature
target:
entity_id: "{{ climate_entities }}"
data:
temperature: 12
hvac_mode: heat
- wait_for_trigger:
- platform: template
value_template: >-
{{ expand(doors_windows) | selectattr('state', 'eq', 'on') | list | length == 0}}
continue_on_timeout: false
- service: scene.turn_on
target:
entity_id: "{{ 'scene.' ~ name_id }}"
- service: scene.delete
metadata: {}
data: {}
target:
entity_id: "{{ 'scene.' ~ name_id }}"
Using the template editor in the dev tools i can validate that my template is working as intended. When any window is open in the area the template is true:
{%- set area = 'G182_Raum_208' -%}
{%- set doors_windows =
expand(states.binary_sensor)
| selectattr('entity_id', 'in', area_entities(area))
| selectattr('attributes.device_class', 'eq', 'window')
| map(attribute='entity_id')
| list
-%}
{{ expand(doors_windows) | selectattr('state', 'eq', 'on') | list | length > 0}}
The only way i found to get the trigger to work is to hard code the sensors into the trigger into the blueprint, defeating the purpose of a blueprint:
trigger:
- platform: template
value_template: >-
{%- set doors_windows = [
'binary_sensor.raum_208_f1',
'binary_sensor.raum_208_f2',
'binary_sensor.raum_208_f3'
] -%}
{{ expand(doors_windows) | selectattr('state', 'eq', 'on') | list | length > 0}}
I am happy about every hint