I have an automation and script for my windows and climate, if window open call script and shut climate off. I fwindow closes set climate to a temperature.
Here is a sample for open window in one room. I would like to write the code more so it can handle all my rooms with one code. Maybe with variables, groups or whatever. I have no idea was solutions home assistant can present here. Maybe someone here as similar ideas and a solution for me.
Can it be done with script variables? I read in the forum that entity id can not work with variables?
Automation
alias: Badezimmer Heizung aus wenn Fenster auf
hide_entity: true
trigger:
- platform: state
entity_id: binary_sensor.bathroom_window_sensor_9_0
state: ‘on’
action:
service: homeassistant.turn_on
entity_id: script.bathroom_window_open
You want a automation to turn off your climate control if any window in your home/apartment is opened and send a notification?
You can have multiple triggers and multiple actions in an automation. The below example should provide the same result as your above code, however, it has multiple triggers. Any one of the triggers will start the automation.
Automation:
alias: Badezimmer Heizung aus wenn Fenster auf
hide_entity: true
trigger:
- platform: state
entity_id: binary_sensor.room1
state: 'on'
- platform: state
entity_id: binary_sensor.room2
state: 'on'
- platform: state
entity_id: binary_sensor.room3
state: 'on'
action:
- service: notify.server
data:
message: 'Badezimmerfenster offen, schalte Heizung aus'
- service: climate.set_temperature
entity_id: climate.bathroom_heating_heating_1_2_1
temperature: 4
If you wanted the climate control to turn back on when all the windows are closed you would just need to change the trigger values to off and add a condition that all the windows are “off”
Automation:
alias: Badezimmer Heizung aus wenn Fenster auf
hide_entity: true
trigger:
- platform: state
entity_id: binary_sensor.room1
state: 'off'
- platform: state
entity_id: binary_sensor.room2
state: 'off'
- platform: state
entity_id: binary_sensor.room3
state: 'off'
condition:
condition: and
conditions:
- condition: state
entity_id: binary_sensor.room1
state: off'
- condition: state
entity_id: binary_sensor.room2
state: 'off'
- condition: state
entity_id: binary_sensor.room3
state: 'off'
action:
- service: notify.server
data:
message: 'Alle Fenster geschlossen, schalten Heizung auf'
- service: climate.set_temperature
entity_id: climate.bathroom_heating_heating_1_2_1
temperature: #