Hi, I’m looking for a way to programmatically get somehow a list of notifications, as shown in the UI. The use case is to have an audible alarm that won’t shut up until they get silenced, to make sure they’re taken care of.
Using the phone is a lost cause, it’s spammed by too many notifications.
I’ve found this documentation so the API looks very limited at the moment. Is there another way to access that information?
You would need to use a websocket connection and the HA websocket api. You can then either get the current list on request or subscribe to new notifications. There is a websocket client library for python (assume your external program is python) with examples how to use and documentation on the websocket api here.
The apis for persistent notifications can be seen from line 201 in the platform code.
This is ok if you are only running once and then closing the websocket connection but i would recommend that you keep the connection open and call get on a periodic loop basis. In which case, you need to increment the id number in your request each time and not fix it otherwise it will error.
Thanks for your comment.
The sensor works for me as the script is called by the sensors update intervall, or a persistent_notification trigger.
I think the connection is closed when the script ends?