Notification - Repeat if Condition Not Met

I have this automation to notify me when my Litter Robot throws an error. Looking for some ideas, what’s the best way to have it notify me again after 4 hours the error has not been cleared?

alias: "Litter Robot Error Notification "
description: ""
triggers:
  - entity_id:
      - sensor.virlr401_status_code
    to:
      - csf
      - df1
      - df2
      - dfs
      - dhf
      - dpf
      - hpf
      - offline
      - otf
      - pd
      - scf
      - sdf
      - spf
      - p
    trigger: state
conditions: []
actions:
  - variables:
      status_code_mapping: |
        {{
          {
            "br": "Bonnet Removed",
            "ccc": "Clean Cycle Complete",
            "ccp": "Clean Cycle In Progress",
            "cd": "Cat Detected",
            "csf": "Cat Sensor Fault",
            "csi": "Cat Sensor Interrupted",
            "cst": "Cat Sensor Timing",
            "df1": "Drawer Almost Full - 2 Cycles Left",
            "df2": "Drawer Almost Full - 1 Cycle Left",
            "dfs": "Drawer Full",
            "dhf": "Dump + Home Position Fault",
            "dpf": "Dump Position Fault",
            "ec": "Empty Cycle",
            "hpf": "Home Position Fault",
            "off": "Off",
            "offline": "Offline",
            "otf": "Over Torque Fault",
            "p": "Paused, Possible Pinch",
            "pd": "Pinch Detect",
            "pwrd": "Powering Down",
            "pwru": "Powering Up",
            "rdy": "Ready",
            "scf": "Cat Sensor Fault At Startup",
            "sdf": "Drawer Full At Startup",
            "spf": "Pinch Detect At Startup"
          }
        }}
  - metadata: {}
    data:
      message: Litter Robot {{ status_code_mapping[trigger.to_state.state] }}
    action: notify.notify
mode: single

You can create another trigger that adds a “for” option and set that for 4 hours. That has some limitations, though: it won’t survive a reboot or a restart of HA, and I think (I’d have to test this to be sure) that the state would have to hold for the full 4 hours. That is, if you are in ‘csf’ for 2 hours and then in ‘df1’ for 2 hours, it won’t fire the trigger.

Another option is to start a timer when you send the first notification. Then create another automation that triggers when the timer fires, checks the state of the status_code sensor in the conditions, and, if the status_code is one of the ones you want to be notified above, have that new automation send another notification.

The way I’ve solved the generic “keep telling me about something” is to:

  1. Create a To Do list item for it.
  2. Send myself an actionable notification for each incomplete To Do list item.
  3. In the action I can say “complete” in which case it completes that To Do list item.
  4. Every 4 hours do step 2.

Your requirement is a variation of this where step 3 sounds like an automated test rather than something you action. However you can still use the same pattern, as it also has the benefit that you can see the list of current To Do items. I actually have a few lists - one for reminders every x hours and another for every x days and another for birthdays.

1 Like

Use the alert integration