Skip to content

Home Assistant custom integration to keep track of missing entities and actions in your config files

License

Notifications You must be signed in to change notification settings

dummylabs/thewatchman

Repository files navigation

The Watchman

hacs_badge version Community Forum

Home Assistant setups evolve over time—entities can disappear, and services/actions may be renamed by integrations. Watchman helps you spot these changes early by scanning your configuration for references to missing or renamed entities, so you can fix issues before automations break.

Discussion on Home Assistant Community Forum

Quick start

  1. Go to the "Integrations" section on HACS, click "Explore and download repositories" and search for "watchman", then click "Download this repository with HACS".
  2. Restart Home Assistant, go to Settings->Devices & Services->Add Integration and select Watchman integration. If integration not found, try to empty your browser cache and reload page.
  3. Go to Developer Tools -> Actions, type watchman and select Watchman: report action then press "Perform Action" button. Check watchman_report.txt file in your configuration directory.

Refer to the Configuration section for further fine-tuning.

What does it do

Watchman is a custom integration for Home Assistant that scans your YAML configuration files and collects referenced entities (sensors, timers, input_select, etc.) and services/actions. It then checks each entity’s current state and reports those that are missing or unavailable. For services/actions, it verifies that they exist in Home Assistant’s registry. The result can be saved as a nicely formatted text table or sent via your preferred notification method (unless the notification target itself is missing 😄). See an example of a report below.

Watchman intentionally keeps the parsing logic lightweight. It doesn’t build a full model of your configuration or try to understand dependencies between files, automations, and templates. Instead, it reads YAML files line by line and uses regex-based heuristics to detect entity and service/action references. Because of this, it may produce false positives (something looks like a reference, but isn’t) and false negatives (a real reference isn’t detected). You can silence false positives using Ignored entities and actions (see the Configuration section). Reducing false negatives is an ongoing improvement area.

What is does not do

Watchman does not try to discover every missing or unavailable entity in your Home Assistant instance. It only reports entities and services/actions that it can find referenced in your YAML configuration (automations, scripts, dashboards, templates, etc.).

Configuration Options

Watchman configuration is currently split between two locations:

  • Integration Options: Used for general setup. Path: Settings > Devices & Services > Watchman > Configure (General settings marked with ⚙️ below).
  • Device Controls: Used for dynamic settings (e.g., ignored labels). Path: Settings > Devices & Services > Devices > Watchman (Dynamic settings marked with 🎛️ below).

The distinction between static and dynamic configuration is provisional and may change in future updates.

Open your Home Assistant instance and show your integrations.

Option Description Example
⚙️ Folders to watch Comma-separated list of folders to scan for entities and actions recursively. /config
⚙️ Ignored entities and actions Comma-separated list of items to ignore. The entity/action will be excluded from the report if their name matches a rule from the ignore list. Wildcards are supported, see example below. sensor.my_sensor1, sensor.my_sensor2
🎛️ Ignored labels (Device Controls) Comma-separated list of label names. Any entity carrying these labels in the entity registry will be excluded from the report. This is a configuration text entity so you can (finally) manage ignored items from your automations. ignore_watchman
⚙️ Exclude entity states Select which states will be excluded from the report Checkboxes in UI
⚙️ Ignored files Comma-separated list of files and folders to ignore. Wildcards are supported, see example below. Takes precedence over Included folders option. */blueprints/*, */custom_components/*, */esphome/*
⚙️ Startup delay By default, watchman's sensors are updated by homeassistant_started event. Some integrations may require extra time for intiialization so that their entities/actions may not yet be ready during watchman check. This is especially true for single-board computers like Raspberry PI. This option allows to postpone startup sensors update for certain amount of seconds. 0
⚙️ Exclude entities used by disabled automations If enabled, entities referenced only by disabled automations will be excluded from the report. UI flag
⚙️ Report location Report location and filename. /config/watchman_report.txt
⚙️ Custom header for the report Custom header for watchman report. -== Watchman Report ==-
⚙️ Report's column width Report's columns width. The list of column widths for the table version of the report. 30, 7, 60
⚙️ Add friendly names Add friendly name of the entity to the report whenever possible. UI flag

Ignored files option example

  • Ignore a file: */automations.yaml
  • Ignore all files in the folder: /config/esphome/*
  • Ignore several folders: /config/custom_components/*, /config/appdaemon/*, /config/www/*

Ignored entities and actions example

  • Ignore an entity: person.dummylabs
  • Ignore everything in sensor domain: sensor.*
  • Ignore any entity/action which name ends with "_ble": *.*_ble

Report Action Parameters

The text version of the report can be generated using watchman.report action from Developer Tools UI, an automation or a script. Default location is /config/thewatchman_report.txt, which can be changed in the UI configuration. A long report can be split into several messages (chunks) due to limitations imposed by some notification actions (e.g., telegram). Action behaviour can be altered with additional optional parameters:

Parameter YAML key Description Default
Force configuration parsing parse_config Forces watchman to parse Home Assistant configuration files and rebuild entity and actions list. Usually this is not required as watchman will automatically parse files once Home Assistant restarts or tries to reload its configuration. False
Send report as notification action Home assistant notification action to send report via, e.g. persistent_notification.create. See compatibility note below. ``
Notification action data data A json object with additional notification action parameters. See example below. None
Message chunk size chunk_size Maximum message size in bytes. Some notification actions, e.g., Telegram, refuse to deliver a message if its size is greater than some internal limit. If report text size exceeds chunk_size, the report will be sent in several subsequent notifications. 0 value will disable chunking. 3500

A useless example sending report as persitent notification

action: watchman.report
data:
  parse_config: true
  action: persistent_notification.create
  data:
    title: Watchman Report
  chunk_size: 3500
  create_file: true`

Sensors

Note

Versions prior to 0.6.4 had a sensor named sensor.watchman_missing_services. Latest versions use another name: sensor.watchman_missing_actions if integration was installed from scratch (new user). Existing users who upgraded from previous versions will have old sensor name to preserve compatibilty with their scripts and dashboards. They can rename sensor themselves or just remove integration and install it again.

Besides of the report, integration provides a few sensors which can be used within automations or dashboards:

  • sensor.watchman_missing_entities
  • sensor.watchman_missing_actions
  • sensor.watchman_last_updated

Example of a watchman report

Please note that the ASCII table format is only used when report is saved to a file. For notification actions watchman uses plain text list due to presentation limitations.

-== WATCHMAN REPORT ==-

-== Missing 1 action(s) from 38 found in your config:
+--------------------------------+---------+------------------------------------------+
| Action                         | State   | Location                                 |
+--------------------------------+---------+------------------------------------------+
| xiaomi_miio.vacuum_goto        | missing | automations.yaml:599,605                 |
+--------------------------------+---------+------------------------------------------+

-== Missing 3 entity(ies) from 216 found in your config:
+--------------------------------+---------+------------------------------------------+
| Entity                         | State   | Location                                 |
+--------------------------------+---------+------------------------------------------+
| sensor.stats_pm25_10_median    | unavail | customize.yaml:14                        |
| sensor.xiaomi_miio_sensor      | unavail | automations.yaml:231,1348                |
| vacuum.roborock_s5max          | unavail | automations.yaml:589,603,610,1569        |
+--------------------------------+---------+------------------------------------------+

-== Report created on 03 Feb 2022 17:18:55
-== Parsed 200 files in 0.96s., ignored 66 files
-== Generated in: 0.01s. Validated in: 0.00s.

The legend at the bottom of the report shows time consumed by 3 coherent stages: parse configuration files, validate each entity/action state and generate text version of the report.

Youtube Reviews

Everything Smart Home channel

Watch the video

mostlychris channel

Watch the video

Smart Home Australia channel

Watch the video

Smart Home Makers channel

Watch the video

Sascha Brockel channel

Watch the video

About

Home Assistant custom integration to keep track of missing entities and actions in your config files

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 15

Languages