This guide explains how to set up a smart heating automation in Home Assistant that reacts to your window sensors to maximize comfort and save energy.
Input Numbers are used to remember the last desired temperature for each room. Example configuration for the living room:
wohnzimmer_last_temp:
  name: Living Room Last Temperature
  min: 5
  max: 30
  step: 0.1
  unit_of_measurement: "°C"
  initial: 23.5
      This automation triggers whenever a window sensor changes state. When the window opens, it stores the current temperature and turns off the heater. When the window closes, it restores the previous temperature.
alias: Living Room Window Heating Control
trigger:
  - platform: state
    entity_id: binary_sensor.living_room_windows
condition: []
action:
  - choose:
      - conditions:
          - condition: state
            entity_id: binary_sensor.living_room_windows
            state: "on"
        sequence:
          - service: input_number.set_value
            target:
              entity_id: input_number.wohnzimmer_last_temp
            data:
              value: "{{ state_attr('climate.living_room', 'temperature') }}"
          - service: climate.turn_off
            target:
              entity_id: climate.living_room
      - conditions:
          - condition: state
            entity_id: binary_sensor.living_room_windows
            state: "off"
        sequence:
          - service: climate.set_temperature
            target:
              entity_id: climate.living_room
            data:
              temperature: "{{ states('input_number.wohnzimmer_last_temp') | float }}"
mode: single
      This automation setup ensures: