Automation Running at Incorrect Time

Hi - Very new to HA so I’m hoping there is a simple answer to this!!

I setup a heating automation that should run between 4.30 & 9pm on Weekdays only once a temperature sensor is <19 degrees C.

Today (Friday), at 4.30pm the temperature sensor was reading 18.2 Dec C. The automation didn’t run and I have no idea why. Trace and YAML of the automation is below - Any help or feedback on what I have done wrong would be great, Thanks!!

TRACE

YAML

alias: "Heating: Weekday Evening On"
description: >-
  Heating comes on between 4 & 9pm, Mon-Fri , providing temperature of Kitchen
  is below 19 Degrees.
trigger:
  - type: temperature
    platform: device
    device_id: b1d32186d409451454d356057cf33a25
    entity_id: e796076b3661029149245e09931d8694
    domain: sensor
    below: 19
condition:
  - condition: time
    weekday:
      - mon
      - tue
      - wed
      - thu
      - fri
    after: "16:00:00"
    before: "21:00:00"
action:
  - type: turn_on
    device_id: 0b04a55bca7d0c3cf310c52f3868fba7
    entity_id: 2910695b1e1a0f4e70a24187f22a528b
    domain: switch
mode: single

Thanks for your help.

if it’s been below 19 degrees all day since yesterday, then it won’t fire. or really if it hits 19 anytime before 16:00 it wont’ fire. (because you told it not to)

what do you want to do in that case? do you want it to not fire? or do you want it to fire at 16:00 anyways?

i suspect you would want something like this maybe?

note that i’ve changed the devices to use the friendly entity name… which you should always do when you can.

alias: "Heating: Weekday Evening On"
description: >-
  Heating comes on between 4 & 9pm, Mon-Fri , providing temperature of Kitchen
  is below 19 Degrees.
trigger:
  - platform: time
    at: "16:00:00"
  - platform: numeric_state
    entity_id:
      - sensor.your_temp_sensor
    below: 19
condition:
  - condition: time
    weekday:
      - mon
      - tue
      - wed
      - thu
      - fri
    after: "16:00:00"
    before: "21:00:00"
  - condition: numeric_state
    entity_id: sensor.your_temp_sensor
    below: 19
action:

Hi Armedad

If it’s been below 19 degrees all day since yesterday, then it won’t fire. or really if it hits 19 anytime before 16:00 it wont’ fire. (because you told it not to) - No, it was above 19 degrees yesterday evening when I manually turned on the heating. It dropped below 19 today when nobody was in the house so I presumed it would fire then at 16:00 as the temp was reading 18.2 which is below 19.

what do you want to do in that case? do you want it to not fire? or do you want it to fire at 16:00 anyways? - I want it to fire every weekday if the temperature at 16:00 is <19 Deg. However, if at 16:00, the temp is >19 Deg then I don’t want it to fire. If the temperature drops to <19 deg anywhere between 16:00 and 21:00 then I want it to fire again (I have another automation to turn the heating off when the temperature is >21.5 Deg between the same time range but it’s not working either - I’d like to fix this one first though!!)

Thanks for your assistance.

PS. Apologies as well, my heading is probably a little misleading - The automation isn’t runing at the wrong time, it’s not running at all. It seemed to check the automation at 3.16pm instead of 4.00pm so not sure why this is?

you should think about condition as “restriction” saying “do not fire unless”

which means that if it hits 18 at 15:59, then the restrction says “do not fire”

that’s all it says. it does not say “fire again later” it does not say "fire at 16:00. it just says “do not fire”

the trigger says “try to fire when it changes to be 19”. it doesn’t say fire whenever it is 19. only at that time when it drops below 19.

so if you think about that, at 15:59, it tried to fire. the restriction says “no”. then it’s done. nothing else triggers it to fire again.

if you look at my code, i set a trigger event to also fire at 16:00… that handles the case if the temp fell to 18 before 16:00. it create an new trigger at 16:00… but i then added the restriction that it has to still be below 19. in case it went below 19 before 16:00 then rose again…

1 Like

Any reason why you’re not using the Generic Thermostat integration to control heating? It creates a climate entity that can also controlled via service calls and/or the UI via the Thermostat card.

You can then use an automation with simple Time Triggers to turn on/off the climate entity at whatever times you need or, better yet, using the Schedule integration.

1 Like

I didn’t know this was a thing!! I’ll have a look at it and see what it does. I’m very new to this so any advice is appreciated!

Hi Armedad - That seems to work now - heating came on at a set time and when the temperature was below a certain value. Thanks.

One more question - Is there anything I can add to the YAML to make the automation check the temperature again say every 10 or 15 minutes and either leave the heating on if temp is < 21.5 Deg, turn it off if temp is >21.5 degrees and turn it back on again if temp has dropped below 19 Deg?

This should all occur between 16:00 and 21:00 on a Weekday only. Thanks for your help

That’s why it’s preferable to use Generic Thermostat. Set the target temperature you want and it automatically maintains it by turning the heater on/off as needed.

1 Like

you should indeed eval what @123 suggest. but to answer your specific question, if you want to run an automation every 15 minutes ,you would do:

  - platform: time_pattern
    minutes: /15

as a trigger. however i would tell you that it is unlikely the right thing to do.

if you want to do something when it reaches 21.5, then you should trigger on that.

Thanks all. I’ll give the Generic Thermostat a try and hopefully this will do what I’m looking for.

cool… if you decide you do want to keep your automation. i would create a separate “turn off” automation that triggers when the temp rises above 21.5. the existing automation you have will take care of if it falls back below 19 again.