seems I have found a related challenge:
create a sensor that counts and lists the updates/repairs in the config notification tray. Ive moved that completely out of the users area (left side menu) and have that info on a dedicated dev view.
we can count updates in Jinja, but not yet directly the repairs, for which I now use custom integration. Spook, resulting in a jinja template:
{% set issues =
states('sensor.active_issues')|int(default=0) %}
{% set updates =
states.update
| selectattr('state','eq','on')
| list | count %}
{{issues + updates}}
the sidebar does this
and you cant see there probably but it does Not count all update entities in the states. The other day my Synology needed an update, and an update entity turned ‘on’, but the notification tray didnt show the update.
Repairs do his in states:
manually creating a next repair using Spook causes another event, and the previous is no longer available (so we cant count it nor list it)
since this seems to seem somewhat consistent (…) with what persistent notifications now do, I was hoping for some help here to make our pers. not. trigger based template into a repairs template
this was my final version:
- trigger:
- platform: homeassistant
event: start
id: start
- platform: persistent_notification
update_type:
- added
- removed
sensor:
- unique_id: persistent_notifications_overview
device_class: timestamp
state: >
{{now()}}
attributes:
notifications: >
{% set msgs = this.attributes.get('notifications',[]) %}
{% if trigger.id == 'start' %}
{{[]}}
{% elif trigger.update_type == 'added' %}
{% set new =
[ {"id": trigger.notification.notification_id,
"title": trigger.notification.title,
"message": trigger.notification.message,
"created_at": trigger.notification.created_at.isoformat()} ]%}
{{msgs + new}}
{% else %}
{{msgs|rejectattr('id','eq',trigger.notification.notification_id)|list}}
{% endif %}
# unique: https://community.home-assistant.io/t/heads-up-2023-6-longer-has-persistent-notifications-in-states-what-to-do/578654/135
history: >
{%- set previous = this.attributes.history|default([]) %}
{% if trigger.update_type == 'added' %}
{% set new = [{
"id": trigger.notification.notification_id,
"title": trigger.notification.title,
"message": trigger.notification.message,
"created_at": trigger.notification.created_at.isoformat()}] %}
{{previous[-3:] + new}}
{% else %} {{previous[-4:]}}
{% endif %}
and Id appreciate some help rebuilding that.
So we can create a counter like this based on that:
{% set msgs =
state_attr('sensor.persistent_notifications','notifications') or [] %}
{{msgs|count}}
listening to these events:
event_type: repairs_issue_registry_updated
data:
action: remove
domain: spook
issue_id: user_3467327y
origin: LOCAL
time_fired: "2024-01-10T08:29:52.085411+00:00"
context:
id: 01HKS7VZ2NSB0CSQVTGXN6XG7S
parent_id: null
user_id: null
required for the trigger based template
Please have a look?