This is actually pretty easy as it turns out. One of the options in the alert integration is done_message. This is the message that gets sent to the notifier when the alert was on and is now off because its alerting condition has become false. In your case that would mean an upgrade was available and now it is complete.
So in your alerts just set the done_message
to something like so:
done_message: "Upgrade to version {{ state_attr('<ID of the matching upgrade sensor for this alert', 'newest_version') }} complete"
So this one is easy if you use mobile notifications although it kind of rules out your ability to do the “upgrade complete” notification because it uses the same field. When you send a notification with the message clear_notification
then it dismisses any existing notifications with the same tag
(see here for info on notification commands like this). So to get an alert which creates a mobile notification and then automatically dismisses it when the condition becomes false you can simply do this:
alert:
my_alert:
name: My example alert
entity_id: binary_sensor.problem_found
state: 'on'
title: "There's a problem!"
message: "It's bad, go check it out!"
done_message: 'clear_notification'
notifier: my_ios_or_android_phone
repeat: 30
data:
tag: REQUIRED_FIELD
With this when the alert turns on it will create a mobile notification with the tag REQUIRED_FIELD
and that message. But then when the alert turns back off it will send the message clear_notification
to the same tag, causing the mobile app to auto-dismiss this notification it created.
This trick works with any alert, including the upgrade notification ones shown here. It does however require that you use the mobile app for notifications. If you use some other notification service then you’ll need to look up if that service supports dismissing notifications and how/if you can leverage it from an alert.
Now I’m going to take a stab in the dark here and say that what you actually want here is not auto-dismiss but rather you want the “Upgrade complete” notification to replace the “Update available” notification once it is done. In that case, we use the first technique but now add a tag
so the new notification replaces the old one. So your alert looks like this:
alert:
my_alert:
name: My example alert
entity_id: binary_sensor.problem_found
state: 'on'
title: "There's a problem!"
message: "It's bad, go check it out!"
done_message: 'The problem has been resolved!'
notifier: my_ios_or_android_phone
repeat: 30
data:
tag: REQUIRED_FIELD
What will happen here is each notification created by this alert will replace the previous notification on your phone/mac/ipad/etc. since they all have the same tag
. So when the problem is resolved the “It’s bad, go theck it out!” notification becomes the “The problem has been resolved!” notification, you never see both.
Again though this technique only works if you use the mobile app. If you have a different notifier you’ll have to see if/how it supports notification replacement.