Automation for after a time does not fire

Hi,

i am starting to automate some things around the house and I want my heat pump for the pool to use excessive PV power.
The heat pump is controlled by a shelly that provide a circuit breaker, circuit open will get the heat pump to power off.
In order not to have the heat pump power on and off I use the PV production rather than the real excessive value. I only use the pool during spring to autumn and the battery of the PV system can tolerate, if I use some of the capacity during late afternoon hours.
I also want the trigger to only fire after 8 am not to disturb the neighbours.

Here is the code, that I did with the automation assistant (not enough in yaml yet).


alias: Test Shelly Wärmepumpe ein
description: ""
triggers:
  - trigger: numeric_state
    entity_id:
      - sensor.deye_pv_power_gesamt_12kw_8kw
    for:
      hours: 0
      minutes: 5
      seconds: 0
    enabled: true
    above: 1500
conditions:
  - condition: time
    after: "08:00:00"
actions:
  - type: turn_on
    device_id: d8b269c430985f1642d7e486b604d145
    entity_id: 27eb25418a946978625f11f355a40346
    domain: switch
mode: single

That is the code for switching on (I have a separate one for switching off, that i might merge in another step, but I want to start it easy):

Problem is that it does not fire. My suspicion is that, if the sun is up providing enough power before 8, the trigger does not fire because it does not get triggered after 8.
I tried the other way around that the trigger is 8 óclock but then it only checks at a certain time, but during cloudy days I want it start start then as soon as the 1500W PV power are crossed.

Can you help?

Like you said yourself, this will only trigger when it gets past that point. It will not trigger again. At least not in the spring/summer time.
You will want to add another trigger that is time based at 8:00 and then check if the power is above 1500W
If its not the first trigger will eventually go above 1500W and start the automation (keeping the 8:00 check ofc)

Look at the history timeline of the sensor.

Got it - can I combine in one automation? I guess I need two separate as doing in one would be an ‘AND’ rather than an ‘OR’, wouldn’t it?

That doesn’t help (me) - it just confirms that since installation at 0800 it was alwys above 1500W power.

yes you can do as one automation

for triggers, leave the one you have and add another for at 0800
for conditions, leave the one you have and add another for PV Generation > 1500W

(conditions in automations are AND by default, see here Automation conditions - Home Assistant)

1 Like

Then that’s your answer why the automation doesn’t trigger and why this :arrow_down: is good advice

That would bring it to the following Code:

alias: Shelly Wärmepumpe ein
description: ""
triggers:
  - trigger: numeric_state
    entity_id:
      - sensor.deye_pv_power_gesamt_12kw_8kw
    for:
      hours: 0
      minutes: 5
      seconds: 0
    enabled: true
    above: 1500
  - trigger: time
    at: "08:00:00"
conditions:
  - condition: numeric_state
    entity_id: sensor.deye_pv_power_gesamt_12kw_8kw
    above: 1500
  - condition: time
    after: "08:00:00"
actions:
  - type: turn_on
    device_id: d8b269c430985f1642d7e486b604d145
    entity_id: 27eb25418a946978625f11f355a40346
    domain: switch
mode: single

But wouldn’t it need the triggers to be combined with OR?
We will see tomorrow…

but you want AND don’t you…

so trigger when 0800, and separately trigger when generation > 1500W
then check if it’s later than 0800 AND generation is > 1500W and if so then execute

trigger will execute when one or other triggers are true…with both triggers replicated as conditions one of them is immediately true so you are only actually checking the second one (eg when time is 0800 then automation triggers and by default the condition of 0800 is true so you are only checking the > 1500W one)…does that make sense?

1 Like

Ok, so the trigger fires when one turns true - that would make them linked OR, wouldn’t it?

The way you explained makes sense, just that my understanding of the two triggers is different - but as said I’m a newbie in automation so I’ll have a lot to learn on triggers and combinations…

yeah…triggers are independent of each other and fire when any one is true (so OR)…conditions default to AND

There may be a better way to do it and there are plenty on here who know more than I do, but that should work fine…I’ve a few setup similarly at my end and they do the job…

1 Like

I am not overly dogmatic on neat and clean coding - especially at my level of experience and skill :wink:

So whatever does the job I am fine and in my experience its better to start easy and get more complicated step by step rather than failing with a too complex setup instantly…

Thanks a lot for the advice!

I’ll let you know if it’s working as expected.

1 Like

@Gav_in that solved it, thanks a lot.

Works now as expected!

1 Like