Simple automation didn't complete

Hi all,

I’m still a bit new to HA and Automations. I’m using the UI to make automations.

Yesterday, the automation was triggered (IAQ sensor picked up CO2 above 800 ppm), turned on the switch (boost mode), but encountered an error and did not complete the actions, which resulted in a switch (Boost Mode) staying on for multiple hours.

Here is the UI:

And the .yaml that it created:

id: '1701648360247'
alias: Upstairs ERV Boost
description: ''
trigger:
  - platform: numeric_state
    entity_id:
      - sensor.aranet4_1acad_carbon_dioxide
    above: 800
condition:
  - condition: device
    type: is_off
    device_id: 8bd2a38ebf19f31422d5b381759c51a6
    entity_id: 7117bb90a578d1b59f31e4a3c9e081ad
    domain: switch
    for:
      hours: 1
      minutes: 0
      seconds: 0
  - condition: numeric_state
    entity_id: sensor.st_louis_addison_pm2_5
    below: 30
action:
  - type: turn_on
    device_id: 8bd2a38ebf19f31422d5b381759c51a6
    entity_id: 7117bb90a578d1b59f31e4a3c9e081ad
    domain: switch
  - delay:
      hours: 1
      minutes: 0
      seconds: 0
      milliseconds: 0
  - type: turn_off
    device_id: 8bd2a38ebf19f31422d5b381759c51a6
    entity_id: 7117bb90a578d1b59f31e4a3c9e081ad
    domain: switch
mode: single

Is there some sort of sequencing issue that I am overlooking? I thought the actions are pretty straight forward: turn on switch, wait 1 hour, turn off switch.

Any thoughts?

It never started the actions. The error is related to the Device condition.

1 Like

The condition checks to see if the switch is off for an hour. If it is on, like you said, it failed the condition and the automation stopped.

1 Like

What I was trying to do with that condition is ensure the automation doesn’t run if the boost switch is already ON. Does that logic not pan out?

The switch was turned on though, I have a record of the switch (from the Shelly App) being turned on at 15:43:19.

Is this automation the only way boost can be turned on?

Is there a previous trace? The one shown is from 16:45.

It is generally a bad idea to used prolonged delays since they do not survive reloading or restarts. Also, be aware that the for configuration variable is based off the last_changed property which also does not survive restart.

The automation ran an hour later at 16:45. What else is turning on the boost?

1 Like

This is the only automation for Boost currently.

Here is the trace from 15:43:19!

Looks like the turn off action never executed.

Would it simply if I removed 1 hr for from the condition? I guess I don’t need that as part of the condition. I simply don’t want the boost automation to run if the boost switch is already on.

Is the 1 hour delay in the actions section frowned upon as well? If so, what is the recommended alternative? Should I be using the timer function instead?

Thanks!
Scott

These are the following traces after the above 15:43:19, which did seem to run (or at least start) appropriately.

I’m guessing the automation from 15:43:19 never completed because it got triggered a handful of times afterwards because the triggered numeric state was happening? But these 3 traces show the automation not running because it failed the test condition.

Weird. Automation ran this morning at 9:30:59 AM through completion.

I added in a 1s delay, not sure if this helped execute the device OFF action.

I also removed the “for” 1 hr on the device off condition, but can’t remember if I did that before or after this automation was triggered.

alias: Upstairs ERV Boost
description: ""
trigger:
  - platform: numeric_state
    entity_id:
      - sensor.aranet4_1acad_carbon_dioxide
    above: 800
condition:
  - condition: device
    type: is_off
    device_id: 8bd2a38ebf19f31422d5b381759c51a6
    entity_id: 7117bb90a578d1b59f31e4a3c9e081ad
    domain: switch
    for:
      hours: 0
      minutes: 0
      seconds: 0
  - condition: numeric_state
    entity_id: sensor.st_louis_addison_pm2_5
    below: 30
  - condition: time
    after: "09:00:00"
    before: "18:00:00"
action:
  - type: turn_on
    device_id: 8bd2a38ebf19f31422d5b381759c51a6
    entity_id: 7117bb90a578d1b59f31e4a3c9e081ad
    domain: switch
  - delay:
      hours: 1
      minutes: 0
      seconds: 0
      milliseconds: 0
  - type: turn_off
    device_id: 8bd2a38ebf19f31422d5b381759c51a6
    entity_id: 7117bb90a578d1b59f31e4a3c9e081ad
    domain: switch
  - delay:
      hours: 0
      minutes: 0
      seconds: 1
      milliseconds: 0
mode: single