Hi All, I was going to turn some attention to staged alerting. Let me know what you think of the following:
Staged alerts proposal
I propose adding a new alert config field supersedes
, that specifies that one alert entity takes precedence over another.
So for example:
- domain: basement
name: temperature_hot
condition: "{{ states('sensor.b_temp') > 80 }}"
- domain: basement
name: temperature_very_hot
condition: "{{ states('sensor.b_temp') > 90 }}"
supersedes: { domain: basement, name: temperature_hot }
notifier: something_noisy
And hereās a first take on the effect of supersedes
:
When the superseding alert is firing, no notifications are send for the superseded alert. So while temperature_very_hot
is firing, itās as if it implicitly snoozes temperature_hot
.
In the overview UI card, the superseding alert is shown, and the superseded alerts are ācollapsedā underneath it. So temperature_very_hot
would show, but temperature_hot
would be visible only by expanding a UI carot or something.
I propose making generators work with supersedes by introducing a new generator variable genPreviousDomainName
to let you chain supersedes (example below).
supersedes
applies transitively. So if A supersedes B, and B supersedes C, then that means A supersedes C.
supersedes
could also cause the alert to inherits settings from the alert it is superseding. This may reduce repetitive typing. [ Iām unsure if inheritance is a good idea ].
Lastly, I imagine we could separately add features like priority or something to affect how the alerts render in the UI.
Example: āgood to knowā alerts
- domain: basement
name: door_open
condition: "{{ states('sensor.door_open') }}"
notifier: null
- domain: basement
name: door_open_too_long
condition: "{{ states('sensor.door_open') }}"
delay_on_secs: 300
supersedes: { domain: basement, name: door_open }
notifier: telegram
So an door_open alert appears in the UI, but sends no notifications and disappears if itās superseded by the door being open too long. You could imagine adding a priority field or something so the āgood to knowā alert to convey that itās not as urgent as other alerts in the UI.
Example: door open and it gets cold
- domain: basement
name: door_open_too_long
condition: "{{ states('sensor.door_open') }}"
delay_on_secs: 300
- domain: basement
name: door_open_too_long_cold
condition: "{{ states('sensor.door_open') and states('sensor.temp')|float < 60 }}"
delay_on_secs: 300
supersedes: { domain: basement, name: door_open_too_long }
Example: low disk space
- domain: haserver
name: diskspace_low_{{genElem}}
condition: "{{ states('sensor.disk_free_mb') | float < genElem }}"
supersedes: {{ genPreviousDomainName }}
generator_name: g1
generator: [ 500, 400, 300, 100 ]
notifier: "{% if genElem|float <= 300 %} noisy_notifier {% else %} normal_notifier {% endif %}"
The above generates four alerts that turn on at progressively lower disk-free amounts, and the alert shown in the UI (and notifying) will be the alert triggering on the lowest disk-free space. The second two alerts use a noisier notifier than the first two.
What I like about this proposal is that a staged alert is a normal alert with an extra annotation. So a staged alert is just as powerful and expressive as a normal alert.
Thoughts?
-Josh