Three HA automations worth stealing — update tracking, feature discovery, and post-reboot health checks

If you’re running Aqara gear through Home Assistant (M2/M3 hub via Matter, HACS integrations, etc.), here’s a small pipeline I built that’s saved me a lot of manual checking. Sharing in case others find the pattern useful.

1. Update/new-component reminder
Instead of manually checking Settings → Updates or scrolling HACS, I built an automation that watches the entire update.* entity domain — every Core/OS/Supervisor update plus every HACS-tracked integration and Matter device firmware. Whenever something finishes updating, or a brand-new component gets added, it batches everything that changed into one push notification a few minutes later (so a day with 5 updates landing together = one notification, not five). It’s just a reminder to go look — doesn’t do anything on its own — but nothing update-related slips by unnoticed.

2. Feature-discovery pass
The reminder above is only half the story — it tells you something changed, not what’s actually useful about it. So the second piece is a research pass I run off that reminder: it goes through what changed (installed integrations, HACS components, add-ons) and checks changelogs/release notes for capabilities that could simplify or replace something I’ve hand-built. A concrete example of the kind of thing it catches: “you wrote a custom template sensor to do X, but the integration shipped a native helper for that a few versions back.” It’s read-only — produces a short candidate list for me to review, never changes anything on its own. Genuinely useful for catching feature creep in fast-moving integrations you don’t have time to read every release note for.

3. Post-reboot / post-update health check
This one’s more directly relevant to Aqara/Matter users: I kept running into a specific problem where my M3-hub-bridged locks would spawn duplicate “ghost” entities after certain reboots or Matter re-pairing events — one live entity, one stale unavailable twin, sometimes with duplicated diagnostic sensors too. Chasing these down manually got old fast.

So I built a health-check that runs automatically after every HA restart (and weekly as a backstop) and checks for:

  • Duplicate entities (the ghost-twin pattern above)
  • Entities stuck unavailable/unknown
  • Missing entities/actions (via the Watchman integration)
  • Config validation errors
  • Automations/scripts that look dead/unused

For my specific recurring lock-duplication case, I even added a narrow auto-clean step — but everything else is report-only by design; I wanted visibility, not a tool silently deleting things I hadn’t looked at.

Big lesson for anyone dealing with Matter node duplication after a hub re-pair: the “obvious” original entity isn’t always the live one — I had cases where the base entity was actually the stale ghost and the _2 suffix was the current live node. Worth verifying via the entity’s underlying node ID rather than assuming by naming convention.

Happy to go into more detail on any of these three if people are interested — #1 is a pretty short/portable YAML pattern, #2 and #3 are more involved (run external to HA) but I can share the general approach.

Github code links:

13 Likes

Thanks for sharing!

3 Likes

Thank you very much for this post.
I’d be interested to know more about the health check in point 3.

So far, I have been using the Home Assistant Global Health Score (HAGHS) integration.

3 Likes

You bet. Below is a generated summary from Claude. I’ve also edited my initial topic to include a link to the HA health check code on github.

What it is: A Python tool that runs on your NAS and talks directly to Home Assistant’s REST/WebSocket API. It doesn’t live inside HA — it’s an outside watcher that checks HA’s own state after something disruptive happens.

Three separate triggers, not one:

  1. Weekly — a plain cron job, Sunday 5am, just a baseline liveness check.
  2. Post-update — an HA automation watches the four update.* entities (Core, OS, Supervisor, Matter Server addon) for the on→off transition that means “update just installed,” then waits 8 minutes (lets mDNS/Matter re-discovery settle) before firing the check.
  3. Post-reboot — this one’s the interesting gotcha. Originally I only had the update-entity trigger, and it silently failed for full Core updates — those force a restart, and a state trigger literally can’t observe an on→off transition that straddles its own automation’s restart (the automation isn’t “listening” yet when the transition completes during boot). Not a timing fluke — structurally impossible for a plain state trigger. Fix was adding a second trigger type, homeassistant: event: start, alongside the state trigger — that one fires on any restart, update-driven or not, so a manual reboot with no pending update still gets checked.

Why this matters for Aqara specifically: the whole project exists because Matter-bridged Aqara devices (via M2/M3 hubs) kept spawning duplicate entity registrations after restarts — same physical device, two device_id records, one usually going stale/unavailable. It happened to me repeatedly on three Aqara-bridged locks specifically. The checker flags:

  • Duplicate entities — numeric-suffix entity_ids sharing a device_id, one twin dead
  • Stuck unavailable/unknown entities
  • Config validation, missing entity references, a few other housekeeping checks

One narrow auto-fix, everything else is flag-only: after that same duplicate pattern recurred on the same three locks five separate times, I added one scoped exception that auto-deletes only those three devices’ known-stale duplicate entities — matched by device_id, not name, and cross-checked against the actual Matter node ID embedded in the entity’s unique_id (learned the hard way that “the _2 suffix is the stale one” is not a safe assumption for every entity category — disabled diagnostic sensors and identify-buttons follow the opposite pattern). Every other finding across the whole house just gets reported, never auto-deleted.

Delivery: writes a dated Markdown report, pushes one phone notification per run (silent-when-clean on the weekly path, always-notify on post-update/reboot runs so you get positive confirmation nothing broke), and updates a small dashboard card in HA showing the latest run’s summary.

3 Likes

Great set — #3 hits home. I just went through exactly the failure mode your health check is built for: a re-pairing silently changed my FP2’s entity set, and the automation pointing at the old IDs died without a single error for two days (wrote it up here: Why My FP2 Automation Silently Died: The Matter vs. HomeKit Pairing Trap). Your point about the base entity sometimes being the stale ghost is an important addition I hadn’t considered. Definitely interested in the Watchman setup and the YAML for #1 if you’re up for sharing.

1 Like

Watchman: HACS > search “Watchman” > install > restart HA, then Settings > Devices & Services > Add Integration > “Watchman” — it’s config-flow, no YAML to write. Turn on exclude_disabled_automation right away or it’ll flag every automation you’ve deliberately disabled as “missing.” ignored_items lets you silence specific entities you’ve already checked and confirmed are fine.

#1 (update tracker) YAML is up now: GitHub - BDBURNS30/homeassistant-update-tracker: HA automation that batches update/new-component notifications, plus an optional Claude Code discovery-agent that researches whether they're worth acting on. Companion to homeassistant-health-check. · GitHub — the automation + the input_text helper it needs, just swap in your own notify service. Same repo has #2 (the discovery-agent research pass) if you’re running Claude Code — separate folder, clearly marked, skip it if not.