Automating my AirCon

I’m trying to workout the logic needed to turn on the aircon during the night, if the temp is over a threshold, I now that I cant use a simple temp & time range, as if the temp is already exceeded when the time range is met then it wont fire, so I’m not sure how to get HA to constantly check the temp setting - any clues ?

Hi, welcome to the forum!

The temperature threshold is your trigger and the time range is the condition to fire the action.

But if the temp trigger has already been met when the timer condition is true, then it wont fire as HA needs the trigger to also be true, and as there is no change to trigger the temp condition it does not work.

Use two triggers. One for the temperature and one for the time. Then add two conditions for the temperature and time.

unless I’m being daft (entirely possible as I’m new to HA) I cant set a trigger to be a time range, just after a set time. I can set the AndIf to a time range, but not the ‘When’

As @vic4news said, use 2 triggers.
One to be time, the other one to be temp.

Then also add 2 conditions, time after and temp higher

So when triggered at time, the temperature must be higher then set.
When triggered by temp, the time must be after the set time :wink:


description: ""
mode: single
triggers:
  - trigger: time
    at: "22:00:00"
  - trigger: numeric_state
    entity_id:
      - sensor.ac2729_master_bedroom_temperature
    above: 22
conditions:
  - condition: time
    after: "21:59:59"
    before: “07:00:00”
  - condition: numeric_state
    entity_id: sensor.ac2729_master_bedroom_temperature
    above: 21,9
actions: []

Correct. You can’t have the time trigger be a range, but you can add triggers for different times or you can trigger every X minutes.
See this thread for ideas

Thank You, trying that tonight.

So i have tried every solution to this that i can find, and nothing works correctly:

I currently have the Automation to trigger every 10 minutes during the time period, and then an AndIf check on the temperature of the sensor in the room, and the check does not work on the temp, so the aircon wont fire. What am i doing wrong.

alias: AC Auto On
description: ""
triggers:
  - hours: "20"
    minutes: /10
    trigger: time_pattern
  - hours: "21"
    minutes: /10
    trigger: time_pattern
  - hours: "22"
    minutes: /10
    trigger: time_pattern
  - hours: "23"
    minutes: /10
    trigger: time_pattern
  - hours: "23"
    minutes: /10
    trigger: time_pattern
  - hours: "00"
    minutes: /10
    trigger: time_pattern
  - hours: "01"
    minutes: /10
    trigger: time_pattern
  - hours: "2"
    minutes: /10
    trigger: time_pattern
  - hours: "3"
    minutes: /10
    trigger: time_pattern
  - entity_id:
      - sensor.sonoff_snzb_02d_temperature
    for:
      hours: 0
      minutes: 5
      seconds: 0
    trigger: numeric_state
    above: 22
    enabled: false
conditions:
  - condition: time
    weekday:
      - sat
      - fri
      - thu
      - wed
      - tue
      - mon
    enabled: false
  - type: is_temperature
    condition: device
    device_id: cbf1819ce489da302f8306340639095d
    entity_id: 8f3972aa94ef444ed9ecbb91a6029d1d
    domain: sensor
    above: 23
    below: 25
actions:
  - action: climate.turn_on
    metadata: {}
    data: {}
    target:
      device_id: 624f06282b94eaee92808a2e1038d0ab
  - action: climate.set_temperature
    metadata: {}
    data:
      temperature: 18
      hvac_mode: cool
    target:
      device_id: 624f06282b94eaee92808a2e1038d0ab
  - action: climate.set_hvac_mode
    metadata: {}
    data:
      hvac_mode: cool
    target:
      device_id: 624f06282b94eaee92808a2e1038d0ab
  - action: climate.set_fan_mode
    metadata: {}
    data:
      fan_mode: "1"
    target:
      device_id: 624f06282b94eaee92808a2e1038d0ab

What I posted earlier will work.

  • when time triggers at 22:00, the first condition returns true (time after 21:59:59), so it wether the AC will turn on depends only on the temperature being above 21.9 degs or not

  • when temperature reaches 22 the degrees, the second condition returns true (temp above 21.9), and the AC will only turn on when time is after 21:59:59 or before: 07:00:00

  • try to avoid device ID’s, use entity instead… Why and how to avoid device_ids in automations and scripts

What about a template helper

{{temperature > x & time > x}}

With a boolean template helper it would be on when both things were true and off if either are false.

Example:

 {{((states('sensor.master_bedroom') > '64') and (now().hour > 15)) }}

if this is going to run after midnight you’ll need an OR for the time change

{{((states('sensor.master_bedroom') > '64') and (now().hour > 15) or (states('sensor.master_bedroom') > '64') and (now().hour < 7) ) }}

True, my automation wouldn’t trigger after midnight when temp > 22.
Adding before: “07:00:00” should take care of that (edited yaml)