Help with simple heating automation

Hey All,

been beating my head against a wall for a few days now getting this rather simple heating automation to fire.

what i want is simple:
1/ temp falls below 18 (measured on aeon labs multisensor 6)
2/ time is between 5am and 9am
3/ switch on heater

The ACTION ive confirmed working. The TRIGGER never (or more accurately rarely) fires.

- alias: 'CLIMATE: smart winter heating'
  trigger:                        #logical OR (any item in list can invoke entry)
#    - platform:  homeassistant    #i THINK i need this to correctly set state at startup? 
#      event:     start
#    - platform:  time             #dont think i need this.... 
#      at:        '05:00:01'
    - platform:  numeric_state    #the main trigger
      entity_id: sensor.aeon_labs_zw100_multisensor_6_temperature         #      entity_id: climate.current_temperature
      below:     18
#      for:       '00:30:00'      #BEAWRE! doesnt run 'action' for 30 mins.... it means this trigger wont eval to true unless it has been below 18 for 30 mins!
  condition:                      #logical AND at this level (default
#    - condition: or               #logical OR at the indent sub-conditions
#      conditions: 
#        - condition: time
#          after:     '05:00:00'
#          before:    '09:00:00'
#        - condition: time
#          after:     '17:00:00'
#          before:    '21:30:00'
    - condition: numeric_state
      entity_id: sensor.aeon_labs_zw100_multisensor_6_temperature
      below:     18
  action:
    - service: notify.k_slack_push
      data:
        message: "LG air ->HEAT (<18->20) turn on (called)"
    - service: climate.turn_on
      entity_id: climate.air
    - delay: 00:00:20
    - service: climate.set_hvac_mode
      data:
        entity_id: climate.air
        hvac_mode: heat
    - delay: 00:00:20
    - service: climate.set_temperature
      data:
        entity_id:        climate.air
        hvac_mode:        heat      
        temperature:      20          #new target temp or 'setpoint' (when LG hits this +1c, it switches off, no fan either).
        target_temp_high: 22          #highest temperature that the climate device will allow. Required if hvac_mode is heat_cool.
        target_temp_low:  18          #lowest temperature that the climate device will allow. Required if hvac_mode is heat_cool.
    - delay: 00:00:20
    - service: climate.set_fan_mode
      data:
        entity_id: climate.air
        fan_mode: 'high'              #values = high, medium, low

ive read all the forums i can find to try and solve this (remnants of things ive tried in the commented out bits), but still no joy. So, as you can see ive stripped it right back. Ive isolated the problem to be in the initial trigger, i.e. i can easily make the automation fire when i do a simple time of day trigger, i.e.:

 - alias: 'CLIMATE: simple test (heat)'
   trigger:                        #logical OR (any item in list can invoke entry)
     - platform:  time             
       at:        '18:54:00'
   action:   .... (identical to above) 

any ideas/focused education GREATLY appreciated

i think what has frustrated me is im not sure how i can debug the trigger state, other than just watching the temp fall below the value… but nothing fires. I saw some good posts about flipping this into template logic or input_boolean (that way i can see the state at least)… will dabble with that at the weekend unless people can steer me otherwise.

what am i doing wrong?
thanks!
Keiran.

The key information you are missing is that when you define a trigger like this:

    - platform:  numeric_state
      entity_id: sensor.aeon_labs_zw100_multisensor_6_temperature
      below:     18

It will only trigger when the temperature goes from above 18 to below 18. If it is already below 18 when home assistant starts or when your time conditions are true the automation will not be triggered.

Thanks for quick reply! Yes ive seen other posts about that - isnt that the point of the ‘condition’ code repeating the test? Ive also sat there watching my sensor going down: 20… 19… 18… 17… no fire.

My hass container reboots nightly at 1am (temp is much greater than 18 at that point)… and is rock stable outside of that so i shouldnt need to test on startup? Or should i? So theoretically it should fire somewhere just before dawn as temp slowly falls under 18.

How do you suggest i should i fix?

The condition is evaluated after the trigger occurs so that means the first time the temperature falls below 18. When the temperature is already below 18 and continues to fall, the automation is not re-triggered so the condition is not evaluated.

Note

To re-trigger the automation, the temperature must rise above 18 first then fall below 18. It’s the act of crossing the threshold while falling that serves to trigger it.

1 Like

Thanks! I keep reading that, so it must be right, but i must be dense as im not following when applying to my situation. Let me walk you thru it and maybe you can point out my logic flaw:

EVERY NIGHT:
10pm: go to bed… temp is 21’ish
1am: hass reboots… temp is 20’ish
6am: temp falls from 18 to 17.9.

At this point, at 6am it should fire right? Im obv not getting it.

You’re correct; it should trigger around 6am when it dips below 18.

You’re saying it fails to trigger and that suggests something, somewhere isn’t working nominally. Not sure what that might be though.

Confirm the automation is enabled.
Check the sensor’s history to confirm it truly falls below 18.
Check the automation’s last_triggered time.


EDIT

Remove the Numeric State Condition. In this situation, there’s no need to test for what the trigger has already confirmed.

The Time Conditions you’ve commented out appear to be correct.

1 Like

Ok good. Some sanity restored. Thanks for the t/shooting tips, i didn’t know i could see the last fired time. Seems it was Saturday night when i was trying loads of things to get it to work. Ive been testing loads since then so should have fired since. Ive literally watched the temp fall below on the sensor so thats ok. Ive no idea where to go next. Apart from flipping the complex states into templates so i can more readily see their states to debug?

Hmm just seen your edit. Let me think that through. You mean comment out the condition section entirely then? Will it work (as a simple test) without any condition?

Hey guess what, its 930pm here in sydney, which means im off to bed haha. Have just tried what you suggested (and upped to 19c as the threshold). Ill cross fingers in this rather simple test one more time for a fire in the early am.

Yes. The condition section is optional. An automation can consist of just a Trigger and an Action.

Awesome. We will see!

Im wondering about something you said earlier now. Is it something about the state of the trigger condition not resetting properly?

You have mixed requirements here and you are not considering them all. (well you are but you’ve commented most out)
Consider : -
A. I want the heating on only beteween these times (A = on, E = off)
B. I want the heating on if below this value
C. If already below B then it should come on with the time
D. regardless of time the heating should go off when above another value
E. regardless of temp the heating should go off at thingy time

This is thus broken into two automations (you could get it into one but thats a pretty complex template required (leave that to a time when you are more clear about the relevant triggers and conditions with a little more experience

So the easy one is the off automation
Trigger
if above D temp
If at E1 time
if at E2 time
Action
switch heating off

Then the more complex On automation
Trigger
If below B temp
if at time A1
if at time A2
Condition
temp is below B temp
AND
(time is between A1 and E1
OR
time is between A2 and E2)
Action
switch heating on

Yep

Yes you do for it to do the test at 05:00:00 ( not sure why the 01 second after, it won’t conflict with the after below in the condition )

Yeah don’t use that - the thermal inertia of any room should give you sufficient hysteresis, Unless you have a blast furnace or freezer in there and randomly switch opening doors

The point is that you have multiple triggers but you then have to evaluate if all required conditions are true

Thanks mutt - very detailed food for thought there. Im pondering this half sleepy and think I understand it… except for your A2 and E2 variables … what are they portraying? (Edit: oh i get it, a second time range?)

And re the homeassistant ‘start’ trigger - you say i need that. Can i trouble you to elaborate? Is it something about initialising the state at startup?

And finally, it seems i need to have a top-level trigger to test at the boundary of each time range?

1 Like

Having a crappy night sleep, but plus side is I just checked in and automation didn’t fire. Even stripped back as basic as it is. What the hell. (And yes I hit reload automations before I went to bed). Is it something about starting state as a few eluded to above. Thanks all very grateful for assistance.

I stand corrected. It DID later fire last night based on my way stripped-back code (that JUST tests for it falling below 19c with a single trigger as per the last ‘configurator’ screenshot I posted 10hrs ago).

BUT it fired at an inexplicable time: 410am, when the temp was waaaaaaay lower than 19c:

Checking in on the states I can see confirmation of that automation was indeed invoked (hmm learnt that ‘T’ time is GMT?):

And confirmation in my slack alert / debugging that automation was indeed triggered (called) and the feedback loop debugging that the state on the heating unit actually cycled through to heat immediately after:

So all good there… BUT why on earth would it not fire when I asked it to?

Is ‘reload automations’ enough as a side point, or do people generally prefer the full ‘reload server’?

I’m a coder from way back, so I should have cracked this a long time ago, but this just seems buggy to me at this point.

As always, most grateful for any leads to follow next.
Thanks!
K.

EDIT: after I turned it off (manually) at 619am, ive just noticed it turned on again! Again no where near falling beneath the 19c threshold (current temp > 22c). I might have the opposite problem now with it firing too much hahah. What the…!?

Just so you know that I haven’t abandoned you: “I got nothing.” :man_shrugging:

The results you reported are puzzling. The sensor’s chart clearly shows the temperature fell below the threshold value well before the automation triggered at 4:10 AM.

1 Like

Okay, How about we create two automations as I proposed for the two time slots and for temperatures between say 18 and 20 degrees.
But we just use it to switch an input_boolean so you can monitor it against actual times and temperatures

When / if you get that to work you’ll know its not the automation

1 Like

Just for fun, you can try a Template Trigger. It behaves the same way with regards to the threshold value. However, we might learn something by observing how it handles this situation.

- alias: 'climate test'
  trigger:
    - platform: template
      value_template: "{{ states('sensor.aeon_labs_zw100_multisensor_6_temperature') | float < 19 }}"
  action:
    - add your stuff here
1 Like

Thanks taras and mutt, just wanted to update you both that im inching along to my working solution… Had some time over the weekend to debug and things are much better. Ill loop back with my final yaml when im 100% happy in case it helps anyone in the future.

ever get this working?

Yes and no. I love my A/C automation but its not how it started in this thread. Often the case i guess as you realise what you really need.

For me, it was about
1/ realising my driver was cost/energy efficiency- not leaving it on for days at a time (forgetting about it).
2/ not trying to reinvent the wheel with an AC thermostat that the AC does perfectly fine itself. Ie not get to clever with turning on/off via automation, as for instance if you set the unit to cool 22c on the wall panel, and the temp starts and 25,24,23,22… it will switch off the cooling mode on the unit anyway and just be fan.

So what i ended up with was quite simple automation that matches anytime it goes into an ‘expensive’ mode, then auto-switch that mode to fan after X hours (where X is an input_number / slider) in the GUI. Heres the idea:

I also have this automation but TBH i dont use it (its disabled) since i did the above. It works though, if you are looking for example.

(Sorry for the screenshots- im on my mobile).

1 Like