Automation not working, sometimes

Hoping someone can point out the user error here, as that’s what I imagine it to be based on similar posts on the forums.

I have 2 grow tents and I’m using a zwave sensor to control a heater in each tent. The automations in both tents were working swimmingly for days (with maybe a minor issue here or there) but in the last 2 days 1 of the automations fails all over the place. The automation will trigger in the logs but not update the input_boolean, the input_boolean will turn off but not turn off the heater, and safety automations I have will fail to fire too. I’m on a RP4 and just got a new SD card because my first one died on me (already moved recorder to memory on this one). Any ideas?

This is the working automation:

alias: Warm up Davon (actions)
description: ''
trigger:
  - platform: state
    entity_id: input_boolean.warm_davon_up
    to: 'on'
    from: 'off'
  - platform: state
    entity_id: input_boolean.warm_davon_up
    from: 'on'
    to: 'off'
condition: []
action:
  - choose:
      - conditions:
          - condition: state
            entity_id: input_boolean.warm_davon_up
            state: 'on'
        sequence:
          - service: input_boolean.turn_off
            data: {}
            entity_id: input_boolean.hold_davon_temp
          - service: input_boolean.turn_off
            data: {}
            entity_id: input_boolean.cool_down_davon
          - type: turn_on
            device_id: a1b62dab0cce11eb8fb87d1bb1eeeae8
            entity_id: switch.ps3_davon_heater_s
            domain: switch
          - wait_for_trigger:
              - platform: template
                value_template: >-
                  {{ states('sensor.davon_enviro_temp') | float >
                  states('input_number.davon_heat_off_temp') | float }}
          - service: input_boolean.turn_off
            data: {}
            entity_id: input_boolean.warm_davon_up
      - conditions:
          - condition: state
            entity_id: input_boolean.warm_davon_up
            state: 'off'
        sequence:
          - type: turn_off
            device_id: a1b62dab0cce11eb8fb87d1bb1eeeae8
            entity_id: switch.ps3_davon_heater_s
            domain: switch
          - service: input_boolean.turn_on
            data: {}
            entity_id: input_boolean.hold_davon_temp
    default: []
mode: restart

And the near identical one with issues:

alias: Warm up Norby (actions)
description: ''
trigger:
  - platform: state
    entity_id: input_boolean.warm_up_norby
    to: 'on'
    from: 'off'
  - platform: state
    entity_id: input_boolean.warm_up_norby
    from: 'on'
    to: 'off'
condition: []
action:
  - choose:
      - conditions:
          - condition: state
            entity_id: input_boolean.warm_up_norby
            state: 'on'
        sequence:
          - service: input_boolean.turn_off
            data: {}
            entity_id: input_boolean.hold_norby_temp
          - service: input_boolean.turn_off
            data: {}
            entity_id: input_boolean.cool_down_norby
          - type: turn_on
            device_id: 0d9eac9017d111eb82936d389b40d29f
            entity_id: switch.ps4_norby_heater_s
            domain: switch
          - wait_for_trigger:
              - platform: template
                value_template: >-
                  {{ states('sensor.norby_enviro_temp') | float >
                  states('input_number.norby_heat_off_temp') | float }}
            continue_on_timeout: false
          - service: input_boolean.turn_off
            entity_id: input_boolean.warm_up_norby
            data: {}
      - conditions:
          - condition: state
            entity_id: input_boolean.warm_up_norby
            state: 'off'
        sequence:
          - type: turn_off
            device_id: 0d9eac9017d111eb82936d389b40d29f
            entity_id: switch.ps4_norby_heater_s
            domain: switch
          - service: input_boolean.turn_on
            data: {}
            entity_id: input_boolean.hold_norby_temp
    default: []
mode: restart

Both have an automation to trigger the input_boolean on at a set temp, which seems to be working fine. I have these separated so I can manually warm up the tent or have the automation do it to the same level.

Sometimes, these both work great and then will magically fail, with Norby being the one failing all the time the last few days. Appreciate it!

Log has nothing strange in it, no errors or anything. The SD card was a cheap-o I got in the RP kit, and I swapped it 3 or so weeks ago and this 1 automation regularly failing is the only regular issue I’m seeing.

Just double checked both automations, and the two triggers are opposites on both. I want to trigger whenever the state of that input_boolean changes, so the first looks from on to off, the second from off to on. The two choose options tell it what to do in the state it ends up in.

The YAML looks like both are on to off, but the UI set them up that way.

Should I be breaking these apart into more automations? 1 for boolean on, 1 for boolean off, 1 for reaching the desired temperature…?

Edit: the strangeness comes where this is the only automation regularly failing, and it (to me) looks identical to the one that is not failing (I duplicated one to create the other).

The problem that’s being pointed out is that your trigger logic is (for want of a better word) a mess.

Your double triggers are redundant in both cases, and your wait_for_trigger continues on timeout in the one that works, but not in the other (which I suspect is why it fails sometimes, as it probably times out and stops).

1 Like

Then I’m confused how to have this work. Do I need to have 1 automation for the first tent when the boolean is turned on, and another for when it’s turned off? I still don’t get why they’re redundant when one is looking for the boolean being on and one is looking for the boolean being off.

  - platform: state
    entity_id: input_boolean.warm_davon_up
    to: 'on'
    from: 'off'
  - platform: state
    entity_id: input_boolean.warm_davon_up
    from: 'on'
    to: 'off'

Can you explain the timeout you’re referring to? I don’t have one set in either.

I’m not understanding how the triggers of the boolean are causing the issue, but I’ll break them apart I guess and have two different triggers.

Does anyone have an example automation when an input boolean is turned on it keeps a switch on till a trigger is hit and then turns the boolean off, triggering the switch to turn off?

Line 35 of the second one is continue_on_timeout: false

Each automation only requires this trigger (obviously with the appropriate entity_id for each).

  - platform: state
    entity_id: input_boolean.warm_davon_up

Ahh, now I get what you’re all referring to. I’ll make the change to the trigger (didn’t know undefined would work) and see what happens.

Still looking for more recommendations as I doubt this is the issue. Like I said, both automations work and this 1 was working as posted for many days.

It does not clarify, as I still can’t see where in my original YAML it’s NOT looking for off to on. Lines 10-11 are looking for the opposite state change as lines 6-7. I don’t understand the difference in defining each of the two valid state changes vs not defining any and capturing both.

1: alias: Warm up Davon (actions)
2: description: ''
3: trigger:
4:  - platform: state
5:    entity_id: input_boolean.warm_davon_up
6:    to: 'on'
7:    from: 'off'
8:  - platform: state
9:    entity_id: input_boolean.warm_davon_up
10:    from: 'on'
11:    to: 'off'

That said, I updated the hot mess of a trigger to look for state of input_boolean changing at all as suggested:

alias: Warm up Norby (actions)
description: ''
trigger:
  - platform: state
    entity_id: input_boolean.warm_up_norby
condition: []
action:
  - choose:
      - conditions:
          - condition: state
            entity_id: input_boolean.warm_up_norby
            state: 'on'
        sequence:
          - service: input_boolean.turn_off
            data: {}
            entity_id: input_boolean.hold_norby_temp
          - service: input_boolean.turn_off
            data: {}
            entity_id: input_boolean.cool_down_norby
          - type: turn_on
            device_id: 0d9eac9017d111eb82936d389b40d29f
            entity_id: switch.ps4_norby_heater_s
            domain: switch
          - wait_for_trigger:
              - platform: template
                value_template: >-
                  {{ states('sensor.norby_enviro_temp') | float >
                  states('input_number.norby_heat_off_temp') | float }}
            continue_on_timeout: false
          - service: input_boolean.turn_off
            entity_id: input_boolean.warm_up_norby
            data: {}
      - conditions:
          - condition: state
            entity_id: input_boolean.warm_up_norby
            state: 'off'
        sequence:
          - type: turn_off
            device_id: 0d9eac9017d111eb82936d389b40d29f
            entity_id: switch.ps4_norby_heater_s
            domain: switch
          - service: input_boolean.turn_on
            data: {}
            entity_id: input_boolean.hold_norby_temp
    default: []
mode: restart

The automation triggered correctly but did not turn off the input_boolean (and therefore didn’t time-out).

So hot mess of triggers aside, what’s not happening? I’ve been pouring over automation, template the like documentation and scraping reddit to see if someone there has something else. Are there other logs besides logbook, core and supervisor I should be checking?

The only step that can possibly prevent the boolean turning off is the wait_for_trigger.

And as long as the sensor is > than the number the input number is set to, it should trigger the wait_for_trigger to continue and turn off? How can I find out why that’s not happening?

Check the template in the template tool, check the system logs, chuck a persistent notification in immediately before so you can see what that states are…