Sending notifications from a custom entity

Summary

I created an entity to gather “warning” events in the logbook, but that entity never sends a notification.

Overview

The current alerting and notification methods I have found are are “if thing A happens, show devices X, Y, and Z an alert”. Thus I see the event on my devices, and swipe/dismiss it. However I can’t see logbook entries for the alert events, e.g. what caused them, or when they were dismissed.

Steps

  • Create a new entity date_logger to receive automation actions
  • Create automations when existing entities cross a warning or critical threshold
  • Write the warning/critical event to date_logger
  • Trigger alert/notification based on the state of date_logger

Questions

  • Is this approach reasonable, or should I be using a different method?
  • What entity type is most suitable for use as a logbook warning logger?

Details

Helper

I created a helper input_datetime.date_logger. As you can see from the name, I used entity type input_datetime.

Automation - works

I also created an automation:

alias: test persistent notification on
description: ""
trigger:
  - platform: state
    entity_id:
      - switch.front_door_dual_smart_plug_entry_left_plug
    for:
      hours: 0
      minutes: 0
      seconds: 0
condition: []
action:
  - service: logbook.log
    data:
      name: test log
      message: this is a test log message for entry left plug
      entity_id: input_datetime.date_logger
mode: single

As expected, the automation creates logbook entries, for example:

test log  this is a test log message for entry left plug triggered by automation test persistent notification on  triggered by state of Entry left plug
1:25:06 PM - 19 seconds ago

Notification - does not work

Next is to trigger a notification on changes to input_datetime.date_logger. For this I created another automation:

alias: test date logger notification
description: ""
trigger:
  - platform: state
    entity_id:
      - input_datetime.date_logger
condition: []
action:
  - service: notify.mobile_app_my_mobile
    metadata: {}
    data:
      message: logged a thing
mode: single

However this currently never triggers!

Adding a log does not change the state object of the entity, so the State trigger will not work there.