Important: this feature requires at least HASS.Agent 2022.13.0.
HASS.Agent's actionable notifications work the same way as the companion apps do. Read HA's docs for more info, found here.
It basically works as follows:
- You send a notification, combined with a few actions
- Each of those actions have a unique name, eg.
- It's even better to give them more descriptive names, eg.
- Don't worry: that's not what you see in the notification, you can set any title you want
- When the notification shows, it'll have buttons containing the actions
- As soon as you click one of the buttons, the action name will get triggered
- Every automation that has that trigger will activate
If that still sounds a bit complex, just follow the examples below and it'll start making sense (hopefully).
You need a notifier entity ready. If you use the legacy integration, check the examples for info on how to do that. Otherwise, you should have it autodetected after installing the new integration.
Let's prepare the notification. For our test, we'll create a script to handle that. In the GUI editor, configure it like this:
Or if you're into yaml:
alias: Notification - Actionable Test sequence: - service: notify.hass_agent_staging data: title: Test message: This is an actionable test message. data: actions: - action: "yes" title: "Yes" - action: "no" title: "No" mode: single icon: mdi:bell
We added two actions:
no, which will show as
No in the notification. The
action value should be descriptive, the
title value is what the user gets to see.
HA needs to know what to do with the triggered actions, so let's make automations to handle that.
Create a new automation in the GUI for our
yes action, and configure the following trigger:
device_name value helps us bind it to a specific device. Make sure you enter
hass_agent_notifications as the
Then the action, it just sends another notification:
Save your automation.
Now create another automation for our
no action, and configure the following trigger:
And the action:
Save your automation.
Restart HA (or reload scripts & automations). When you run the test script, a notification like this should show on your PC:
Yes, and another popup should show:
Done, you've now got actionable notifications!
Thanks @fillefilip8 for implementing this!