Automation not starting by time of day

Hi,

I have been playing around with HA for a while but not really doing much with automations.

I have it below but its not working as expected. The goal is:

If Jill’s office temperature is below 71 degrees AND it is Monday-Friday AND its 8am-6pm - Turn MBR heat on to 78 degrees - Check every 1 minute.

I couldnt figure out how to make it an ‘else’ but have a second automation -
If jill’s office is above 72 & its Monday-Friday - and it is 8am-6pm - Turn MBR Heat off - check every 1 minute.

It didnt ‘autostart’ this morning to check at 8:01am - at 8:45, I manually clicked “run” then it started but something isnt right.

Any ideas where i went wrong?

alias: Honeywell Thermostat - Jilly Office - Heat On
description: ""
trigger:
  - platform: numeric_state
    entity_id:
      - sensor.jilly_s_office_temperature
    below: 71
    for:
      hours: 0
      minutes: 1
      seconds: 0
condition:
  - condition: time
    after: "08:00:00"
    before: "18:00:00"
    weekday:
      - mon
      - tue
      - wed
      - thu
      - fri
    enabled: true
action:
  - service: climate.set_hvac_mode
    data:
      hvac_mode: heat
    target:
      entity_id: climate.mbr
  - service: climate.set_temperature
    data:
      temperature: 78
      hvac_mode: heat
    target:
      entity_id: climate.mbr
mode: single

2nd Automation

alias: Honeywell Thermostat - Jilly Office - Heat OFF
description: ""
trigger:
  - platform: numeric_state
    entity_id:
      - sensor.jilly_s_office_temperature
    for:
      hours: 0
      minutes: 1
      seconds: 0
    above: 72
condition:
  - condition: time
    after: "08:00:00"
    before: "18:00:00"
    weekday:
      - mon
      - tue
      - wed
      - thu
      - fri
    enabled: true
action:
  - service: climate.set_hvac_mode
    data:
      hvac_mode: "off"
    target:
      entity_id: climate.mbr
  - service: climate.set_temperature
    data:
      temperature: 78
      hvac_mode: "off"
    target:
      entity_id: climate.mbr
mode: single

alias: Honeywell Thermostat - Jilly Office - Heat On
description: ""
trigger:
  - platform: numeric_state
    entity_id:
      - sensor.jilly_s_office_temperature
    below: 71
    for:
      hours: 0
      minutes: 1
      seconds: 0
  - platform: time 
    at: '08:00:00'
condition:
  - condition: time
    after: "08:00:00"
    before: "18:00:00"
    weekday:
      - mon
      - tue
      - wed
      - thu
      - fri
    enabled: true
  - condition: numeric_state
    entity_id:
      - sensor.jilly_s_office_temperature
    below: 71
action:
  - service: climate.set_hvac_mode
    data:
      hvac_mode: heat
    target:
      entity_id: climate.mbr
  - service: climate.set_temperature
    data:
      temperature: 78
      hvac_mode: heat
    target:
      entity_id: climate.mbr
mode: single

If the temperature drops below 71 before 08:00, the automation’s Numeric State Trigger is triggered but the automation will not execute its actions because it’s not within the specified time range.

When the time becomes 08:00 or later, nothing happens because the Numeric State Trigger has already triggered and won’t trigger again until the temperature first rises above 71 and then decreases below 71. That’s how a Numeric State Trigger works; it triggers only when the monitored value crosses the threshold value.

The example I posted checks the temperature at 08:00 and if its already below 71 it proceeds to execute the actions.

Hi @JeepDog64

I think you may have a misunderstanding of how the automations that you have posted work. You say ‘Check every 1 minute’ but this isn’t what these automations do. Indeed, checking every 1 minute would generally be a bad approach to triggering an automation.

What your automations are actually doing is waiting until the temperature is below 71 (for the first automation, and waiting until the temperature is above 78 (for the second automation). In both cases you have specified that this temperature threshold must be passed for 1 minute. So, for the first automation the actions will only be performed if - and whenever - the temperature drops below 71 degrees and stays below 71 degrees for at least 1 minute. Once this happens then the conditions will be tested. If all the conditions are met then the actions will be performed.

If you think about it in this way then you may be able to understand why you see the behaviour that you do.

Thank you - that does make more logical sense.
Triggers - Temp below 71 for 1 minute & time is equal to 8am
Conditions - Time is 8-6, M-F, Jill’s temp is below 71
Action - Turn on heat to 78 in MBR.

So if I rebooted the system at 8:30am - would it wait until 8am was past until it triggered it again?

Is there a way to combine the shutoff into the same script?

Restarting Home Assistant at 8:30am won’t make your version of the automation, or mine, run its actions if the temperature had already decreased below 71 prior to 08:00.

However, if you add the following trigger to my example, it will serve to trigger the automation when Home Assistant is restarted.

  - platform: homeassistant 
    event: start

Yes but the resulting single automation will be more complex. I suggest maintaining two separate automations.

Thank you!