#Thermostat automation that returns to "before" state after window is closed based on time of day

1 messages · Page 1 of 1 (latest)

vital anchor
#

I've read through all of this post and it was pretty helpful: #1300511146520084632 message
Although it was more complex than I actually need/ want my setup to be. Please note that I'm really new to home assistant. I read through a bunch of stuff, but I can't wrap my head around this topic.

**My goal is: **

  1. Have defined temperatures to specific times (without presence detection)
  2. Turn off the heat if the window is open
  3. Return heating depending of the time of day after window is closed

1 & 2 are pretty easy and I already set this up, the problem is that I need some sort of check if the window is closed again if it should heat or not, depending on the time.

(the following temps and times are just for my example)
Let's assume I want it to be 20°C between 15:00-20:00 and 15°C between 20:00-15:00. When I open the window at 16:00 and close it at 16:30, it should fall back to the temperature I declared for this timeframe (so 20°). But when I open the window at 19:50, but close it at 20:10, I want it to be at 15°, so it must check what time it is when closing the window and get the desired temperature from there.

What is a simple way to set this up? I can't get my head around how to do it with simple if else statements. I would like to use some sort of variables, so I can defined my temperature and times in one place and the rest is dependant on that. So if I change something with the timings I don't have to go into 10 automations and change stuff around.

Thanks!

lime nova
#

You could use a scheduler entity to do this (https://www.home-assistant.io/integrations/schedule/) - just define your schedule temperatures as a data key so when the schedule changes and you're not in "window open" mode change temperature to that value, and when the window gets closed you go back to it
If you are open to using a custom integration - I really like using Schedule State for this as it's much more powerful than the schedule helper, able to set overrides and conditional periods, as well as not having to define every day individually

#

Using Schedule State you could do the following:

- platform: schedule_state
  name: base_heating_schedule
  default_state: 15
  events:
    - start: "21:00"
      end: "6:30"
      state: 13
    - start: "6:30"
      end: "8:00"
      state: 20
      condition: 
    - start: "16:30"
      end: "20:00"
      state: 20
      condition: 
        condition: state
        entity_id: binary_sensor.workday_with_override
        state: 'on'
    - start: "8:00"
      end: "20:00"
      state: 20
      condition: 
        condition: state
        entity_id: binary_sensor.workday_with_override
        state: 'off'
    - state: 7
      condition:
        condition: state
        entity_id: binary_sensor.window_sensor
        state: 'on'

Then your automation reduces entirely to "schedule state sensor changes -> set climate temperature to sensor's value

vast crane
#

Just trigger on the time moments and on opening and closing the window. After which you check what to do: Something like:

description: ""
mode: single
triggers:
  - trigger: time
    at: "15:00:00"
  - trigger: time
    at: "20:00:00"
  - trigger: state
    entity_id:
      - binary_sensor.window
    to: null
conditions: []
actions:
  - choose:
      - conditions:
          - condition: state
            entity_id: binary_sensor.window
            state: "on"
        sequence:
          - action: climate.turn_off
            metadata: {}
            data: {}
            target:
              entity_id: climate.test
      - conditions:
          - condition: time
            after: "15:00:00"
            before: "20:00:00"
        sequence:
          - action: climate.set_temperature
            metadata: {}
            data:
              temperature: 20
            target:
              entity_id: climate.test
      - conditions:
          - condition: time
            after: "20:00:00"
            before: "15:00:00"
        sequence:
          - action: climate.set_temperature
            metadata: {}
            data:
              temperature: 15
            target:
              entity_id: climate.test

You could use schedule_state instead but the logic pretty much stays the same.

vital anchor
#

Thank you very much! Will look into it

vital anchor