# dummylabs/thewatchman architecture

> Architecture diagram of the GitHub repository dummylabs/thewatchman, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-12-01). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/dummylabs/thewatchman
- Repository: https://github.com/dummylabs/thewatchman

## Overview

Watchman is a Home Assistant integration and companion CLI that finds entity and service/action references in configuration files, checks them against Home Assistant, and presents missing or unavailable items. The main workflow configures the integration, scans YAML using heuristic parsing with persistent scan data, validates discovered references, then exposes diagnostics and reports. The graph also preserves configuration, notification, and CLI capabilities. Evidence is limited to the supplied excerpts, SOURCE INDEX references, and README; some internal wiring is therefore omitted rather than inferred.

Main entry points: [`custom_components/watchman/coordinator.py`](https://github.com/dummylabs/thewatchman/blob/main/custom_components/watchman/coordinator.py) (Coordinator), [`custom_components/watchman/utils/parser_core.py`](https://github.com/dummylabs/thewatchman/blob/main/custom_components/watchman/utils/parser_core.py) (Reference parser), [`custom_components/watchman/__init__.py`](https://github.com/dummylabs/thewatchman/blob/main/custom_components/watchman/__init__.py) (Integration lifecycle), [`custom_components/watchman/services.py`](https://github.com/dummylabs/thewatchman/blob/main/custom_components/watchman/services.py) (Report actions)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_setup["Integration setup"]
  node_config["Integration options<br/>[config_flow.py]"]
  node_entry["Integration lifecycle<br/>[__init__.py]"]
  node_constants["Integration settings<br/>[const.py]"]
  node_logger["Integration logger<br/>[logger.py]"]
end

subgraph group_scan["Configuration scanning"]
  node_hub["Parser adapter<br/>[hub.py]"]
  node_parser["Reference parser<br/>[parser_core.py]"]
  node_parser_constants["Parser rules<br/>[parser_const.py]"]
  node_yaml["YAML loader<br/>[yaml_loader.py]"]
  node_db[("Scan database<br/>[parser_core.py]")]
  node_cli["Parser CLI<br/>[parser.py]"]
end

subgraph group_validate["Validation and status"]
  node_coordinator["Coordinator<br/>[coordinator.py]"]
  node_utils["Configuration utilities<br/>[utils.py]"]
end

subgraph group_output["Reports and interfaces"]
  node_sensors["Diagnostic sensors<br/>[sensor.py]"]
  node_entity_base["Entity base<br/>[entity.py]"]
  node_entity_utils["Entity registry helpers<br/>[entity.py]"]
  node_services["Report actions<br/>[services.py]"]
  node_report["Report rendering<br/>[report.py]"]
  node_text_button["Text and button entities<br/>[text.py]"]
  node_button["Refresh button<br/>[button.py]"]
end

node_user(("Home Assistant user"))
node_ha{{"Home Assistant"}}
node_config_files["HA configuration files"]
node_ha_registry[("HA states and registries")]
node_notification{{"HA notification action"}}
node_report_file["Report text file"]

node_user -->|"configures"| node_config
node_config -.->|"sets options"| node_entry
node_entry -->|"creates"| node_hub
node_entry -->|"creates"| node_coordinator
node_entry -->|"registers"| node_services
node_hub -->|"invokes"| node_parser
node_parser -->|"uses rules"| node_parser_constants
node_parser -->|"loads YAML"| node_yaml
node_parser -->|"scans"| node_config_files
node_parser -->|"stores scan data"| node_db
node_hub -->|"supplies parsed items"| node_coordinator
node_coordinator -.->|"checks references"| node_ha_registry
node_coordinator -->|"gets parsed items"| node_hub
node_coordinator -->|"uses helpers"| node_utils
node_coordinator -->|"provides status"| node_sensors
node_sensors -->|"extends"| node_entity_base
node_sensors -->|"uses"| node_entity_utils
node_services -->|"requests parsing"| node_coordinator
node_services -->|"renders report"| node_report
node_report -->|"writes"| node_report_file
node_report -->|"calls action"| node_notification
node_services -->|"registers actions"| node_ha
node_text_button -->|"reads status"| node_coordinator
node_button -.->|"triggers refresh"| node_coordinator
node_cli -->|"uses parser"| node_parser

click node_config "https://github.com/dummylabs/thewatchman/blob/main/custom_components/watchman/config_flow.py"
click node_entry "https://github.com/dummylabs/thewatchman/blob/main/custom_components/watchman/__init__.py"
click node_constants "https://github.com/dummylabs/thewatchman/blob/main/custom_components/watchman/const.py"
click node_coordinator "https://github.com/dummylabs/thewatchman/blob/main/custom_components/watchman/coordinator.py"
click node_hub "https://github.com/dummylabs/thewatchman/blob/main/custom_components/watchman/hub.py"
click node_parser "https://github.com/dummylabs/thewatchman/blob/main/custom_components/watchman/utils/parser_core.py"
click node_parser_constants "https://github.com/dummylabs/thewatchman/blob/main/custom_components/watchman/utils/parser_const.py"
click node_yaml "https://github.com/dummylabs/thewatchman/blob/main/custom_components/watchman/utils/yaml_loader.py"
click node_db "https://github.com/dummylabs/thewatchman/blob/main/custom_components/watchman/utils/parser_core.py"
click node_utils "https://github.com/dummylabs/thewatchman/blob/main/custom_components/watchman/utils/utils.py"
click node_logger "https://github.com/dummylabs/thewatchman/blob/main/custom_components/watchman/utils/logger.py"
click node_sensors "https://github.com/dummylabs/thewatchman/blob/main/custom_components/watchman/sensor.py"
click node_entity_base "https://github.com/dummylabs/thewatchman/blob/main/custom_components/watchman/entity.py"
click node_entity_utils "https://github.com/dummylabs/thewatchman/blob/main/custom_components/watchman/utils/entity.py"
click node_services "https://github.com/dummylabs/thewatchman/blob/main/custom_components/watchman/services.py"
click node_report "https://github.com/dummylabs/thewatchman/blob/main/custom_components/watchman/utils/report.py"
click node_text_button "https://github.com/dummylabs/thewatchman/blob/main/custom_components/watchman/text.py"
click node_button "https://github.com/dummylabs/thewatchman/blob/main/custom_components/watchman/button.py"
click node_cli "https://github.com/dummylabs/thewatchman/blob/main/cli/parser.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_config,node_entry,node_constants,node_logger,node_user toneBlue
class node_hub,node_parser,node_parser_constants,node_yaml,node_db,node_cli,node_ha_registry toneAmber
class node_coordinator,node_utils toneMint
class node_sensors,node_entity_base,node_entity_utils,node_services,node_report,node_text_button,node_button toneRose
class node_ha,node_config_files,node_notification,node_report_file toneIndigo
```

## Components

### Integration setup

- [Integration options](https://github.com/dummylabs/thewatchman/blob/main/custom_components/watchman/config_flow.py): `custom_components/watchman/config_flow.py`
- [Integration lifecycle](https://github.com/dummylabs/thewatchman/blob/main/custom_components/watchman/__init__.py): `custom_components/watchman/__init__.py`
- [Integration settings](https://github.com/dummylabs/thewatchman/blob/main/custom_components/watchman/const.py): `custom_components/watchman/const.py`
- [Integration logger](https://github.com/dummylabs/thewatchman/blob/main/custom_components/watchman/utils/logger.py): `custom_components/watchman/utils/logger.py`

### Configuration scanning

- [Parser adapter](https://github.com/dummylabs/thewatchman/blob/main/custom_components/watchman/hub.py): `custom_components/watchman/hub.py`
- [Reference parser](https://github.com/dummylabs/thewatchman/blob/main/custom_components/watchman/utils/parser_core.py): `custom_components/watchman/utils/parser_core.py`
- [Parser rules](https://github.com/dummylabs/thewatchman/blob/main/custom_components/watchman/utils/parser_const.py): `custom_components/watchman/utils/parser_const.py`
- [YAML loader](https://github.com/dummylabs/thewatchman/blob/main/custom_components/watchman/utils/yaml_loader.py): `custom_components/watchman/utils/yaml_loader.py`
- [Scan database](https://github.com/dummylabs/thewatchman/blob/main/custom_components/watchman/utils/parser_core.py): `custom_components/watchman/utils/parser_core.py`
- [Parser CLI](https://github.com/dummylabs/thewatchman/blob/main/cli/parser.py): `cli/parser.py`

### Validation and status

- [Coordinator](https://github.com/dummylabs/thewatchman/blob/main/custom_components/watchman/coordinator.py): `custom_components/watchman/coordinator.py`
- [Configuration utilities](https://github.com/dummylabs/thewatchman/blob/main/custom_components/watchman/utils/utils.py): `custom_components/watchman/utils/utils.py`

### Reports and interfaces

- [Diagnostic sensors](https://github.com/dummylabs/thewatchman/blob/main/custom_components/watchman/sensor.py): `custom_components/watchman/sensor.py`
- [Entity base](https://github.com/dummylabs/thewatchman/blob/main/custom_components/watchman/entity.py): `custom_components/watchman/entity.py`
- [Entity registry helpers](https://github.com/dummylabs/thewatchman/blob/main/custom_components/watchman/utils/entity.py): `custom_components/watchman/utils/entity.py`
- [Report actions](https://github.com/dummylabs/thewatchman/blob/main/custom_components/watchman/services.py): `custom_components/watchman/services.py`
- [Report rendering](https://github.com/dummylabs/thewatchman/blob/main/custom_components/watchman/utils/report.py): `custom_components/watchman/utils/report.py`
- [Text and button entities](https://github.com/dummylabs/thewatchman/blob/main/custom_components/watchman/text.py): `custom_components/watchman/text.py`
- [Refresh button](https://github.com/dummylabs/thewatchman/blob/main/custom_components/watchman/button.py): `custom_components/watchman/button.py`

### Other components

- **Home Assistant user**
- **Home Assistant**
- **HA configuration files**
- **HA states and registries**
- **HA notification action**
- **Report text file**

## Connections

- Home Assistant user → Integration options: configures (evidence: `README.md`)
- Integration options → Integration lifecycle: sets options
- Integration lifecycle → Parser adapter: creates (evidence: `custom_components/watchman/__init__.py`)
- Integration lifecycle → Coordinator: creates (evidence: `custom_components/watchman/__init__.py`)
- Integration lifecycle → Report actions: registers (evidence: `custom_components/watchman/__init__.py`)
- Parser adapter → Reference parser: invokes (evidence: `custom_components/watchman/utils/parser_core.py`)
- Reference parser → Parser rules: uses rules (evidence: `custom_components/watchman/utils/parser_core.py`)
- Reference parser → YAML loader: loads YAML (evidence: `custom_components/watchman/utils/parser_core.py`)
- Reference parser → HA configuration files: scans (evidence: `README.md`)
- Reference parser → Scan database: stores scan data (evidence: `custom_components/watchman/utils/parser_core.py`)
- Parser adapter → Coordinator: supplies parsed items (evidence: `custom_components/watchman/coordinator.py`)
- Coordinator → HA states and registries: checks references
- Coordinator → Parser adapter: gets parsed items (evidence: `custom_components/watchman/coordinator.py`)
- Coordinator → Configuration utilities: uses helpers (evidence: `custom_components/watchman/coordinator.py`)
- Coordinator → Diagnostic sensors: provides status (evidence: `custom_components/watchman/sensor.py`)
- Diagnostic sensors → Entity base: extends (evidence: `custom_components/watchman/sensor.py`)
- Diagnostic sensors → Entity registry helpers: uses (evidence: `custom_components/watchman/sensor.py`)
- Report actions → Coordinator: requests parsing (evidence: `custom_components/watchman/services.py`)
- Report actions → Report rendering: renders report (evidence: `custom_components/watchman/services.py`)
- Report rendering → Report text file: writes (evidence: `custom_components/watchman/utils/report.py`)
- Report rendering → HA notification action: calls action (evidence: `custom_components/watchman/utils/report.py`)
- Report actions → Home Assistant: registers actions (evidence: `custom_components/watchman/services.py`)
- Text and button entities → Coordinator: reads status (evidence: `custom_components/watchman/text.py`)
- Refresh button → Coordinator: triggers refresh
- Parser CLI → Reference parser: uses parser (evidence: `cli/parser.py`)
