Why is this HVAC automation not firing?

Hello and be gentle, this is my first post and it’s taken weeks of learning and late nights (lots of arguments with her in doors) to get here :slight_smile:

I have read the Automations page in the docs and I am still stuck. This automation is not firing at all, there is no Trace in ‘Traces’ in the GUI for the automation and I cannot see anything in homeassistant.log relating to this , be it info, warning or error. When I “run actions”, nothing happens.
The automation is intended to switch on / off a climate device that has HVAC modes ‘off’ and ‘heat’ and a single sensor entity for an offset. The HVAC modes and entity are valid as they are used elsewhere and in the dashboards.
As i say, no action is ever executed and traces show nothing triggered.
System date and time is correct !

Here is the code:

alias: Heating - Night
description: >-
  Control Heat Pump, maintain GF max 19c at night allowing floor value of 18.5.  Works around the Madoka 2c
  hysteresis, sun hitting it etc by using switchbot thermostats. 
triggers:
  - alias: First-run
    at: "22:05:00"
    id: First-run
    enabled: true
    trigger: time
  - alias: Above-temp
    entity_id:
      - sensor.meter_plus_da53_lounge
    for:
      hours: 0
      minutes: 5
      seconds: 0
    above: 19.0
    id: Above-temp
    enabled: true
    trigger: numeric_state
  - alias: Below-temp
    entity_id:
      - sensor.meter_plus_da53_lounge
    for:
      hours: 0
      minutes: 5
      seconds: 0
    id: Below-temp
    below: 18.5
    enabled: true
    trigger: numeric_state
conditions: []
actions:
  - alias: Heating ON
    continue_on_error: true
    if:
      - condition: trigger
        id:
          - Below-temp
    then:
      - alias: Turn on heating with repeat
        repeat:
          sequence:
            - alias: Turn on Heating
              action: climate.set_hvac_mode
              continue_on_error: true
              target:
                entity_id: climate.heating_leaving_water_offset
              data:
                hvac_mode: heat
            - delay:
                hours: 0
                minutes: 10
                seconds: 0
                milliseconds: 0
          until:
            - condition: state
              entity_id: climate.heating_leaving_water_offset
              state: heat
              for:
                hours: 0
                minutes: 0
                seconds: 0
  - alias: Heating OFF
    continue_on_error: true
    if:
      - condition: trigger
        id:
          - Above-temp
          - First-run
    then:
      - alias: Turn off heating with repeat
        repeat:
          sequence:
            - alias: Turn off Heating
              action: climate.set_hvac_mode
              continue_on_error: true
              data:
                hvac_mode: "off"
              target:
                entity_id: climate.heating_leaving_water_offset
            - delay:
                hours: 0
                minutes: 10
                seconds: 0
                milliseconds: 0
          until:
            - condition: state
              entity_id: climate.heating_leaving_water_offset
              state: "off"
              for:
                hours: 0
                minutes: 0
                seconds: 0
mode: single

What is supposed to happen is that:

  • At 22:05 each night, the automation turns off the heating.
  • If sensor meter_plus_da53_lounge reports a value > 19.0 for more than 5 mins then the heating is turned off (this sensor is working and used in the dashboard). This sensor is updated every 10 minutes via the Onecta integration.
  • If the same sensor reports a value > 18.5 for more than 5 mins then the heating is turned on.
    I turn the automation on/off in the dashboard each night around 9pm/6am - I will eventually automate this but one thing at a time.

To me this is complex and my head hurts so if you are clever and can spot the problem, please explain. I could probably help myself a lot more by working through this step by step using features in HA to debug this but I need help please

EDIT:
Having read more, I think I may know root-cause.

Could it be that the sensor values need to transition over the ‘above’ and ‘below’ values in order for the triggers to activate.

For example. the Above-temp trigger requires that the sensor value is read at a value lower than 19 then transitions to a value higher than 19. If so then consider the case where the sensor value is currently 21C say - at the end of the day - then that value would need to drop below 19 then above 19 for the Above-temp` to trigger, which it will not because the temp is going to slowly decrease from 21 down to about 17 without ever fluctuating to a higher value. So Above-temp`` is never triggered.

Similarly, the Below-temp trigger requires that the sensor is read at a value higher than 18.5 then transitions to a lower than 18.5 value. I think this would/should work as the sensor is going to descend down from 21 to 17 and at the 18.5 threshold, turn on the heating?

Could this be the reason? If so how might I improve this automation such that - at any given sensor value at any time this automation becomes enabled - the heating is turned off whenever the sensor reads any value above 19 for 5mins, and, turns on whenever it reads any value lower than 18.5 for 5mins.
The 5mins makes sure that any oscillation around 19 and 18.5 is ignored and we require a static value for 5 mins.

Well, yes, obviously. You have encased all of your actions within a choose whose conditions all depend on a trigger being present and having a certain id, but there is a no trigger when you run actions manually.

Why are you attempting to automate any of this manually, does your HVAC not have a built-in thermostat? If so still do not try to reinvent the wheel, use a Generic Thermostat:

If you look again and carefully underline carefully, examine the automation you’ll see that it uses a series of offsets to gradually throttle up or down the heating

This is an air source heat pump It doesn’t like being cycled rapidly… switched on and off… which is what generic thermostat will do

The automation therefore applies a more smoother curve The idea being to keep the pump running longer but at lower temperature and to get it to modulate around the desired setpoint . occasional tweets are required to the offset values depending on the season of year but generally these figures work well well in dislled into the controller unit however that’s a faff and that’s why I’m trying to automate it through HA.

If you could share your valued experience and solve the actual question asked that would be great

apology accepted😀

I believe the min_cycle_duration option is meant to control that behavior.

min_cycle_duration time | integer (Optional)

Set a minimum amount of time that the switch specified in the heater option must be in its current state prior to being switched either off or on. This option will be ignored if the keep_alive option is set.

It would be set low for something like a resistive heater and higher for any heating source that should not be short-cycled.

Correct; that’s how a Numeric State Trigger behaves.

It triggers when the entity’s value crosses the threshold value. So if the threshold is above: 19, the value must increase from below 19 to above 19 (cross the threshold) in order to trigger.

The inclusion of “for 5 minutes” means that after the value crosses the threshold, it must remain above the threshold for at least 5 minutes for triggering to occur. If the value decreases below the threshold during those 5 minutes, the trigger is reset (i.e. any elapsed time is lost and the trigger waits for the value to, once again, cross the threshold).

Okay that’s great confirmation thankyou.

I gave up. For now.
It’s too cold to be messing about and testing.
So for now I’ll just run the system under influence of the madoka thermostat Is not ideal because it’s less responsive which induces periods of extended heating or cooling. I’ve read few tips on this and implemented them so will leave it now for 24 hrs and assess.

Incidentally the min_cycle_dutation_time Is unlikely to help because it does exactly what the madoka does and that is to be less responsive in that it holds a particular value for a particular period of time thus causing extended periods of heating or extending periods of cooling , i.e. on / off which is exactly the original problem. The answer is to have some kind of throttling where as the set point is reached the leaving water temperature is reduced incrementally in the nonlinear fashion, and increased in a nonlinear fashion as the room cools, with some hysteresis around it…that’s what I was trying to do with home assistant.

I will revisit this when the ambient gets a bit milder but the moment I just need the house to be warm which is not happening because as I’m modifying the system it requires a reboot every time and then a lead time for the pump to start up which is causing long periods of cooling and increase energy costs each time the system ramps up. This will give me more time to learn home assisting an automation as well.

thanks anyway

No, I cannot see that at all, to be honest. I do not at all understand the point of the loops, to prevent someone from manually turning on/off the heat again during the delay or what?

Your automation logic seems very very very prone to errors to be honest. The state triggers only fire when the state changes. If the temperature rises/lowers more rapidly than perhaps you have expected, those triggers may attempt to fire while the delay is in progress, but then they can’t and won’t ever fire again, leaving the heat permanently on/off.

Again, use a Generic Thermostat. Whatever automation logic you think you can possibly come up with, just forget about it because will never ever be anywhere remotely as foolproof.

Look again then🤗

Try it yourself, over time.

Thankyou anyway and best wishes. TTFN

Fixed!!

unsubscribing