ECO Heating Climate - Motion Based with Window Open and Night Shutdown and Timer

Hello,
!! UPDATE: This blueprint now supports window sensors and helpers for temperature and times as I now use this not only at home but also for room lettings !!
Unfortunately, this is not compatible with the old first version!

The idea came that we have each radiator in the house fitted with a TRV (Thermostatic Radiator Valve).
Moes TRV


Also the basis is that we don’t want any room to cool down too much in order for the room not to lose too much heat but also for the heating to be efficient and faster spooling up.
Each room is also equipped with a Sonoff or Ikea Tradfri motion sensor to control the lights to some extend and we add the heating purpose to that here :wink:
So there are several factors considered in my motion controlled room heating.
The Base (ECO) temperature in my case 18 C, occupied room temperature 21 C or some even 22 C. The time of the day the system should work within and heat up the room as we don’t want it boiling hot at night, but also how long the heating should run for after last motion detected e.g.10min but it depends as with the TV room we don’t necessarily move a lot while watching a movie.
Problems? Yes, pets moving around the rooms. Solution don’t run the system at night and leave doors closed :wink:

blueprint:
  name: Motion-Activated Heating
  description: Turn up heating when motion is detected.
  domain: automation
#  source_url: https://community.home-assistant.io/t/motion-controlled-room-eco-heating/291322
  input:
    motion_entity:
      name: Motion Sensor
      selector:
        entity:
          domain: binary_sensor
          device_class: motion
    climate_target:
      name: Climate Device
      selector:
        target:
    eco_temperature:
      name: Eco Temperature
      description: Fallback temperature when no motion is detected
      selector:
        entity:
          domain: input_number
    comfort_temperature:
      name: Comfort Temperature
      description: Comfort temperature when motion is detected
      selector:
        entity:
          domain: input_number
    time_after:
      name: Time After
      description: Point from which the motion will control eco heating
      selector:
        entity:
          domain: input_datetime
    time_before:
      name: Time Before
      description: Point from which the motion will not trigger eco heating
      selector:
        entity:
          domain: input_datetime
    no_motion_wait:
      name: Hold time
      description: Time to leave the heating in comfort for after last motion is detected.
      default: 600
      selector:
        number:
          min: 0
          max: 3600
          unit_of_measurement: seconds
    window_sensors:
      name: Window Sensors
      description: List of window sensor to shut down heating when open
      default: []
      selector:
        entity:
#          multiple: true
          domain: binary_sensor
          device_class: opening
        
variables:
  input_eco: !input eco_temperature 
  input_comfort: !input comfort_temperature
  
# If motion or window open is detected within the delay,
# we restart the script.
mode: restart
max_exceeded: silent

trigger:
  - platform: state
    entity_id: !input motion_entity
  - platform: state
    entity_id: !input window_sensors

action:
  - if:
      - condition: state
        entity_id: !input window_sensors
        state: "on"
    then:
      - service: climate.set_temperature
        data:
          temperature: 5
        target: !input climate_target
    else:
      - if:
          - condition: time
            after: !input time_after
            before: !input time_before
        then:
          - if: 
              - condition: state
                entity_id: !input motion_entity
                state: "on"
            then:
                - service: climate.set_temperature
                  data:
                    temperature: "{{ states[input_comfort].state | int }}"
                    hvac_mode: heat
                  target: !input climate_target
            else:
                - delay: !input no_motion_wait
                - service: climate.set_temperature
                  data:
                    hvac_mode: heat
                    temperature: "{{ states[input_eco].state | int }}"
                  target: !input climate_target
        else:
          - service: climate.set_temperature
            data:
              hvac_mode: heat
              temperature: "{{ states[input_eco].state | int }}"
            target: !input climate_target

I have also an automation running to lower the night temperature by a further degree which gets overridden by first movements in a room (or another automation to increase temp in morning).
!! With this new script it’s not needed anymore !!

Hi Chris -

Just wanted to say I’ve using this with success (I did modify it for proper US units :)) in my office shed I built in the back. Thanks for writing and sharing this.

I’m using it with a Generic Thermostat entity with a zwave temp sensor and a zwave outlet that controls a space heater.

1 Like

Yes, should work with separate temperature sensors too. Good to see it works for you! Sorry we don’t do Farenheit in Europe :slight_smile:

Just set this up for my baseboard heaters here in Canada! Thanks again!

Very good indeed!
Two things:

  • Setting fixed 5 degrees causes an error in all of my thermostats, I changed it to the “eco” temperature.
  • Also, I removed the device_class: motion from the motion sensor setting, this way I can use a helper group with more than one actual motion sensors.

Very valid point about the motion sensor. I might have the need too to get this using multiple motion sensor.
Interesting to see 5 degrees an issue but note that this is Celsius in my case maybe I need to adopt that to american Fahrenheit or see if that can be determined in a blueprint automatically.