Hi all,
I’d like to create an automation which turns off all thermostats in one room when a door/window is opened in the same room.
I saw that this should somehow be possible via area_name(trigger.entity_id), where the trigger is the door/window binary-sensor.
How can I then address all climate thermostats in that corresponding area?
The idea is to turn off the thermostats for the time a window or door is open and turn them back on, when the door/window is closed again.
I just saw, that I should be able to create a list of all entities in an are by using area_entities(are_name(trigger.entity_id))
How can I now turn off all climate.* entities in that list?
alias: example
trigger:
- platform: state
entity_id:
- binary_sensor.kitchen_window
- binary_sensor.front_door
- binary_sensor.bedroom_window
- binary_sensor.rear_door
to: 'on'
for:
seconds: 15
condition: []
action:
- service: climate.turn_off
target:
entity_id: "{{ trigger.entity_id | area_name | area_entities | select('match', 'climate') | list }}"
If any of the listed doors or windows are opened for more than 15 seconds, the automation is triggered and turns off the climate entity in the associated area.
EDIT
It appears that a template is unacceptable for entity_id when used with the climate.turn_off service.
You’re absolutely right, the example I posted uses entity_id in a way that is unacceptable for climate.turn_off.
Normally, when you use target with entity_id, the entity_id option accepts a template. The service calls for the climate integration appear to deviate from this norm because, according to the documentation, they only accept a “String or list of strings” as described here:
Service data attribute
Optional
Description
entity_id
yes
String or list of strings that define the entity ID(s) of climate device(s) to control. To target all climate devices, use all.
What I suggest is to simply avoid using entity_id and to use area_id. It supports templates and the required template is even simpler.
OK, this version definitely passes check configuration on my system:
Please consider marking my post above with the Solution tag. It will automatically place a check-mark next to the topic’s title which signals to other users that this topic is resolved. This helps other users find answers to similar questions. For more information, refer to guideline 21 in the FAQ.