Skip to content

Repository files navigation

Phone Notifications Logger

Persistent Android notification history for Home Assistant, with a Lovelace card to browse it.

Platform HACS Version License

🇮🇹 Leggi in italiano

A Home Assistant custom component that listens to the notification sensor exposed by the Home Assistant Companion app on Android and keeps a persistent, on-disk history of every notification it sees — so the log survives Home Assistant restarts. A bundled Lovelace card lets you browse recent notifications straight from your dashboard.


Contents


What it does

  • Listens for state changes on an Android notification sensor entity (the android.title / android.text attributes reported by the Companion app)
  • Persists the notification history to Home Assistant's storage (.storage), so it is not lost on restart
  • Creates a sensor entity whose:
    • state is the title or text of the most recent notification
    • attributes are history_count, last_notification and notifications
  • Ships a Lovelace card (custom:phone-notifications-card) that renders the history as a scrollable list

Requirements

  • A working Home Assistant instance
  • The Home Assistant Companion app on the Android phone whose notifications you want to log, with its notification sensor enabled (an entity such as sensor.<phone>_active_notification_count)

Installation

Via HACS (recommended)

  1. Add this repository to HACS as a custom Integration repository
  2. Install Phone Notifications Logger and restart Home Assistant

Manual

Copy the custom_components/phone_notifications_logger folder into your Home Assistant config/custom_components/ directory, then restart Home Assistant.

Configuration

Add a sensor platform entry to configuration.yaml:

sensor:
  - platform: phone_notifications_logger
    sensor_entity_id: sensor.samsung_s21_active_notification_count_2
    name: "Phone Notifications"
    max_history: 1000
Option Required Default Description
sensor_entity_id Yes — The phone's Android notification sensor to listen to
name No Phone Notifications Friendly name of the sensor created by this integration
max_history No 1000 Maximum number of notifications kept in history (oldest are trimmed first)

Restart Home Assistant afterwards: a sensor entity (for example sensor.phone_notifications, following the name you chose) is created and starts logging.

Lovelace card

When installed through HACS, the card resource is served at:

/hacsfiles/phone_notifications_logger/phone_notifications_card.js

Add it as a resource (HACS registers it automatically for most setups) and then add a manual card to your dashboard:

type: custom:phone-notifications-card
entity: sensor.phone_notifications
max_items: 10
title: "Notification History"
Option Description
entity The sensor entity created by this integration
max_items How many notifications to display
title The card's title

The card shows the last max_items notifications with timestamp, title and text.

Sensor attributes

Attribute Contents
history_count Number of notifications currently stored
last_notification The most recent notification, as { timestamp, title, text }
notifications The full stored history

How it works

The integration subscribes to state-change events on the configured sensor_entity_id using Home Assistant's async_track_state_change_event helper. Every time the source sensor updates and carries android.title or android.text attributes, a {timestamp, title, text} record is appended to an in-memory list, the sensor's state is updated to the notification title (or text), and the list is trimmed to max_history entries before being written to Home Assistant's Store — a per-entity JSON file under .storage/. On startup the stored history is loaded back so nothing is lost across restarts.

License

MIT © 2025 Antonio Di Stefano

About

Home Assistant component that logs the history of Android notifications, with a Lovelace card to browse them

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages