Automation not triggering timer

I recently setup an automation to remind me to fill our dumb cat feeder. It essentially 5 bowls and one is always open to the cat, at 5:15ish every morning it rotates to the next bowl. I setup a counter to keep track of how many un-eaten bowls are left which decrements at 5:15AM when the bowl rotates. When the count reaches 0 I need to add more food. I setup a timer to delay the notification from 5:15AM to 6PM. When the timer is up it sends an actionable notifcation to my phone, if I press the button on the notification it resets the counter. If I fail to do this before 5:15AM the next morning it will notify me then and there without the delay (the cat is really annoying when his feeder rotates to an empty bowl). I also setup an NFC tag so if I’m feeling proactive I can re-fill the feeder whenever and just scan the tag to reset the counter.

The problem is this morning the counter reached 0 for the first time and it never started the timer, I can’t figure out why it didn’t.

The counter is max of 4, min of 0. Timer is 12 hour 45 minutes.

Edit to add that the log for the automation shows that it triggered for the time of day and it did decrement the feeder to 0m, but never got the 0 trigger apparently.

The YAML is as follows:

alias: Cat Feeder
description: Maintains cat food counter helper, alerts me when I need to refill the feeder.
trigger:
  - platform: time
    at: "05:15:00"
    id: Feeder_Decrement
  - platform: state
    entity_id:
      - timer.cat_food_notification_offset
    from: active
    to: idle
    id: Notify_1
  - platform: tag
    tag_id: 0f256ebe-435e-4616-9329-f030282f5838
    id: refill
  - platform: state
    entity_id:
      - counter.cat_food
    to: "0"
    id: Food_0
  - platform: event
    event_type: mobile_app_notification_action
    event_data:
      action: FED_CAT
    id: Refill_2
condition: []
action:
  - if:
      - condition: trigger
        id: Feeder_Decrement
    then:
      - if:
          - condition: state
            entity_id: counter.cat_food
            attribute: minimum
            state: ""
        then:
          - service: timer.start
            data: {}
            target:
              entity_id: timer.cat_food_notification_offset
          - delay:
              hours: 0
              minutes: 0
              seconds: 30
              milliseconds: 0
          - service: timer.finish
            data: {}
            target:
              entity_id: timer.cat_food_notification_offset
        else:
          - service: counter.decrement
            data: {}
            target:
              entity_id: counter.cat_food
  - if:
      - condition: trigger
        id: Food_0
    then:
      - service: timer.start
        data: {}
        target:
          entity_id: timer.cat_food_notification_offset
  - if:
      - condition: trigger
        id: Notify_1
    then:
      - service: notify.mobile_app_name_phone
        data:
          message: Feed The Damn Cat
          title: Cat Feeder
          data:
            actions:
              - action: FED_CAT
                title: Fed the cat
  - if:
      - condition: or
        conditions:
          - condition: trigger
            id: refill
          - condition: trigger
            id: Refill_2
    then:
      - service: counter.reset
        data: {}
        target:
          entity_id: counter.cat_food
mode: single

So I’ve been doing some testing and the trigger does seem to work. I think the fact that its happening at the same time as the automation is already running is preventing it to trigger again. I changed it to add a 30 second delay on the trigger (so when the counter reaches minimum for 30 seconds) it doesn’t seem to trigger at all with the delay, so I’m thinking to do a second time trigger 1 minute after the first to then check if the counter =0 to trigger the timer.

EDIT: I added the second time based trigger and will need to wait for tomorrow to know if it works.

Just change that to mode: queued so it processes the trigger that happened while the automation was running as soon as the first trigger actions have finished.

This is clearly what I needed, TIL that was a thing.

FYI:

1 Like