Sweet. Great release! I’m home alone for the next week couple of days so I’ll have a some extra time to dedicate to alerting.
In regards to the suggestion of using the data field that’s exactly what I’m doing currently and it absolutely works. The suggestion is specifically to try to be “DRY” when writing alerts. For example, I have a bin which I store 3D printer filament that is to be humidity controlled. I have an alert that fires after the humidity rises above 20% for 5 minutes.
- domain: humidity
name: ams_humidity
friendly_name: "AMS Humidity"
condition: "sensor.filament_humidity"
title: "AMS Filament Humidity Alert"
message: "AMS humidity has gone above 15% humidity. It's at {{ states('sensor.filament_humidity')}}%."
delay_on_secs: 600
done_message: "AMS humidity has gone below the threshold. At, {{states('sensor.filament_humidity')}}"
data:
group: "GroupTag.ams_humdity_group"
tag: "NotificationTag.ams_humditiy_tag"
url: "/dashboard-home/management"
actions:
- action: "ACK_AMS_HUMIDITY"
title: "Ack"
- action: "SNOOZE_AMS_1_HOUR"
title: "Snooze for 1 Hour"
- action: "SNOOZE_FOR_1_DAY"
title: "Snooze for 1 day"
threshold:
value: "sensor.filament_humidity"
maximum: 15
hysteresis: 5
notifier: rich
When this alert fires I’m sent a notification that allows me to acknowledge the alert or snooze to it for 1 hour. Focusing only on an action being clicked, an event is sent into the event stream where the event is mobile_app_notification_action with the action equal to whatever you set and then the alert has to be read from the event stream and then actioned. A quick example of a pyscript notification action handlers:
@event_trigger("mobile_app_notification_action", "action =='ACK_AMS_HUMIDITY'")
def ack_ams_humidity(**kwargs):
alert2.ack(entity_id="alert2.humidity_ams_humidity")
@event_trigger("mobile_app_notification_action", "action =='SNOOZE_AMS_1_HOUR'")
def snooze_1_hour_ams_humidity(**kwargs):
...
@event_trigger("mobile_app_notification_action", "action ==''SNOOZE_AMS_1_DAY")
def snooze_1_day_ams_humidity(**kwargs):
...
Ideally, for every alert I create that I want to be able to ack or snooze from a notification I have to include details in alert configuration which will largely be the same for all alerts as well as implement the handling logic for them. I mind implementing the event handlers less as I’m not sure this is something the integration can do but being able to have actions automatically be added would be ideal. I figure something like the following:
alert2:
defaults:
actions:
- action: "SNOOZE_{{alert_name}}_1_hour"
title: Snooze for 1 hour
...
alerts:
...
data:
group: "GroupTag.ams_humdity_group"
tag: "NotificationTag.ams_humditiy_tag"
url: "/dashboard-home/management"
Where the “actions” are not overridden so the default would be added. Ideally, if alert2 could listen for and handle these that’d also be awesome but that may not be feasible as I’m not familiar with that side of Home Assistant.
Another “nice to have” feature would be to show alerts where the condition has passed but we are waiting on the length of time to pass before the alert is actually triggered. IE: “Pending alerts”.
Some other thoughts on what has been mentioned in this post:
- I really am excited for UI. Instant feedback is great and hopefully will open alerting to more people
- I like the idea of an staged alerting/escalation policy for alerts to increase severity.
- Making the alerts more UI friendly is also pretty exciting!
As always, I appreciate the work you’re doing!
EDIT:
I had a thought about how to handle the snoozing and acking of alerts. I’ll update here with the result of that. Likely to be some time later this week.