# astroctrl-dev/ha-mbus-energy-public architecture

> Architecture diagram of the GitHub repository astroctrl-dev/ha-mbus-energy-public, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-26). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/astroctrl-dev/ha-mbus-energy-public
- Repository: https://github.com/astroctrl-dev/ha-mbus-energy-public

## Overview

This is a Home Assistant app for reading Landis+Gyr T230 meters over wired M-Bus and publishing validated measurements and diagnostics through MQTT Discovery. The primary workflow is meter selection in the Web UI, scheduled serial polling, frame validation and decoding, then Home Assistant publication. Separate user-triggered workflows retrieve monthly archives, synchronize the meter clock, and export stored analysis. The index and excerpts show the main orchestration and several internal dependencies; some unsampled feature wiring is documented only in the README, so those links cite it.

Main entry points: [`mbus_probe/mbus_service.py`](https://github.com/astroctrl-dev/ha-mbus-energy-public/blob/main/mbus_probe/mbus_service.py) (App service), [`mbus_probe/history_controller.py`](https://github.com/astroctrl-dev/ha-mbus-energy-public/blob/main/mbus_probe/history_controller.py) (History controller), [`mbus_probe/mqtt_bridge.py`](https://github.com/astroctrl-dev/ha-mbus-energy-public/blob/main/mbus_probe/mqtt_bridge.py) (MQTT bridge), [`mbus_probe/meter_ui.py`](https://github.com/astroctrl-dev/ha-mbus-energy-public/blob/main/mbus_probe/meter_ui.py) (Web UI)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app["App and UI"]
  node_service["App service<br/>[mbus_service.py]"]
  node_webui["Web UI<br/>[meter_ui.py]"]
  node_discovery["Meter discovery<br/>[meter_discovery.py]"]
  node_registry[("Meter registry<br/>[meter_registry.py]")]
  node_schedule["Poll schedule<br/>[poll_schedule.py]"]
end

subgraph group_bus["Meter communication"]
  node_probe["M-Bus probe<br/>[mbus_probe.py]"]
  node_gate["Transmission gate<br/>[bus_timing.py]"]
  node_decoder["Record decoder<br/>[mbus_records.py]"]
  node_rawlog[("Telegram log")]
end

subgraph group_history["History and maintenance"]
  node_controller["History controller"]
  node_archive["Archive acquisition"]
  node_monthly["Monthly diagnostics"]
  node_retry[("Monthly retry<br/>[monthly_retry.py]")]
  node_historymodel[("History model<br/>[history_model.py]")]
  node_clock["Clock maintenance"]
  node_dst[("DST evidence<br/>[dst_transition.py]")]
  node_diagnostics["Diagnostic runtime"]
  node_frame5["Frame-5 capture<br/>[frame5_capture.py]"]
end

subgraph group_outputs["Publishing and analysis"]
  node_projection["Measurement projection<br/>[ha_measurements.py]"]
  node_mqtt["MQTT bridge<br/>[mqtt_bridge.py]"]
  node_export["Analysis export<br/>[analysis_export.py]"]
  node_archiveview["Archive view<br/>[archive_view.py]"]
end

node_operator(("Home Assistant user"))
node_serial{{"M-Bus meter"}}
node_broker{{"MQTT broker"}}
node_analysisstore[("Local analysis data")]

node_operator -->|"uses"| node_webui
node_webui -->|"requests actions"| node_service
node_service -->|"manages selection"| node_registry
node_service -->|"schedules polling"| node_schedule
node_service -->|"reads meter"| node_probe
node_probe -->|"writes through"| node_gate
node_probe -->|"exchanges frames"| node_serial
node_gate -->|"captures transmission"| node_rawlog
node_probe -->|"validates frames"| node_decoder
node_service -->|"projects readings"| node_projection
node_projection -->|"provides measurements"| node_mqtt
node_mqtt -->|"publishes discovery"| node_broker
node_service -->|"publishes readings"| node_mqtt
node_operator -->|"requests history"| node_controller
node_webui -->|"starts retrieval"| node_controller
node_controller -->|"collects archive"| node_archive
node_archive -->|"reads monthly records"| node_monthly
node_controller -->|"stores validated history"| node_historymodel
node_controller -->|"tracks failures"| node_retry
node_controller -->|"publishes history"| node_mqtt
node_operator -->|"requests synchronization"| node_clock
node_clock -->|"gates clock writes"| node_gate
node_clock -->|"records transitions"| node_dst
node_service -->|"runs diagnostics"| node_diagnostics
node_operator -.->|"requests capture"| node_frame5
node_webui -->|"downloads analysis"| node_export
node_export -->|"reads stored data"| node_analysisstore
node_controller -->|"projects archive"| node_archiveview
node_mqtt -->|"publishes archive attributes"| node_archiveview

click node_service "https://github.com/astroctrl-dev/ha-mbus-energy-public/blob/main/mbus_probe/mbus_service.py"
click node_webui "https://github.com/astroctrl-dev/ha-mbus-energy-public/blob/main/mbus_probe/meter_ui.py"
click node_discovery "https://github.com/astroctrl-dev/ha-mbus-energy-public/blob/main/mbus_probe/meter_discovery.py"
click node_registry "https://github.com/astroctrl-dev/ha-mbus-energy-public/blob/main/mbus_probe/meter_registry.py"
click node_schedule "https://github.com/astroctrl-dev/ha-mbus-energy-public/blob/main/mbus_probe/poll_schedule.py"
click node_probe "https://github.com/astroctrl-dev/ha-mbus-energy-public/blob/main/mbus_probe/mbus_probe.py"
click node_gate "https://github.com/astroctrl-dev/ha-mbus-energy-public/blob/main/mbus_probe/bus_timing.py"
click node_decoder "https://github.com/astroctrl-dev/ha-mbus-energy-public/blob/main/mbus_probe/mbus_records.py"
click node_rawlog "https://github.com/astroctrl-dev/ha-mbus-energy-public/blob/main/mbus_probe/raw_telegram_log.py"
click node_controller "https://github.com/astroctrl-dev/ha-mbus-energy-public/blob/main/mbus_probe/history_controller.py"
click node_archive "https://github.com/astroctrl-dev/ha-mbus-energy-public/blob/main/mbus_probe/archive_acquisition.py"
click node_monthly "https://github.com/astroctrl-dev/ha-mbus-energy-public/blob/main/mbus_probe/monthly_diagnostic.py"
click node_retry "https://github.com/astroctrl-dev/ha-mbus-energy-public/blob/main/mbus_probe/monthly_retry.py"
click node_historymodel "https://github.com/astroctrl-dev/ha-mbus-energy-public/blob/main/mbus_probe/history_model.py"
click node_clock "https://github.com/astroctrl-dev/ha-mbus-energy-public/blob/main/mbus_probe/clock_maintenance.py"
click node_dst "https://github.com/astroctrl-dev/ha-mbus-energy-public/blob/main/mbus_probe/dst_transition.py"
click node_diagnostics "https://github.com/astroctrl-dev/ha-mbus-energy-public/blob/main/mbus_probe/diagnostic_runtime.py"
click node_frame5 "https://github.com/astroctrl-dev/ha-mbus-energy-public/blob/main/mbus_probe/frame5_capture.py"
click node_projection "https://github.com/astroctrl-dev/ha-mbus-energy-public/blob/main/mbus_probe/ha_measurements.py"
click node_mqtt "https://github.com/astroctrl-dev/ha-mbus-energy-public/blob/main/mbus_probe/mqtt_bridge.py"
click node_export "https://github.com/astroctrl-dev/ha-mbus-energy-public/blob/main/mbus_probe/analysis_export.py"
click node_archiveview "https://github.com/astroctrl-dev/ha-mbus-energy-public/blob/main/mbus_probe/archive_view.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_service,node_webui,node_discovery,node_registry,node_schedule,node_operator toneBlue
class node_probe,node_gate,node_decoder,node_rawlog,node_analysisstore toneAmber
class node_controller,node_archive,node_monthly,node_retry,node_historymodel,node_clock,node_dst,node_diagnostics,node_frame5 toneMint
class node_projection,node_mqtt,node_export,node_archiveview toneRose
class node_serial,node_broker toneIndigo
```

## Components

### App and UI

- [App service](https://github.com/astroctrl-dev/ha-mbus-energy-public/blob/main/mbus_probe/mbus_service.py): `mbus_probe/mbus_service.py`
- [Web UI](https://github.com/astroctrl-dev/ha-mbus-energy-public/blob/main/mbus_probe/meter_ui.py): `mbus_probe/meter_ui.py`
- [Meter discovery](https://github.com/astroctrl-dev/ha-mbus-energy-public/blob/main/mbus_probe/meter_discovery.py): `mbus_probe/meter_discovery.py`
- [Meter registry](https://github.com/astroctrl-dev/ha-mbus-energy-public/blob/main/mbus_probe/meter_registry.py): `mbus_probe/meter_registry.py`
- [Poll schedule](https://github.com/astroctrl-dev/ha-mbus-energy-public/blob/main/mbus_probe/poll_schedule.py): `mbus_probe/poll_schedule.py`

### Meter communication

- [M-Bus probe](https://github.com/astroctrl-dev/ha-mbus-energy-public/blob/main/mbus_probe/mbus_probe.py): `mbus_probe/mbus_probe.py`
- [Transmission gate](https://github.com/astroctrl-dev/ha-mbus-energy-public/blob/main/mbus_probe/bus_timing.py): `mbus_probe/bus_timing.py`
- [Record decoder](https://github.com/astroctrl-dev/ha-mbus-energy-public/blob/main/mbus_probe/mbus_records.py): `mbus_probe/mbus_records.py`
- [Telegram log](https://github.com/astroctrl-dev/ha-mbus-energy-public/blob/main/mbus_probe/raw_telegram_log.py): `mbus_probe/raw_telegram_log.py`

### History and maintenance

- [History controller](https://github.com/astroctrl-dev/ha-mbus-energy-public/blob/main/mbus_probe/history_controller.py): `mbus_probe/history_controller.py`
- [Archive acquisition](https://github.com/astroctrl-dev/ha-mbus-energy-public/blob/main/mbus_probe/archive_acquisition.py): `mbus_probe/archive_acquisition.py`
- [Monthly diagnostics](https://github.com/astroctrl-dev/ha-mbus-energy-public/blob/main/mbus_probe/monthly_diagnostic.py): `mbus_probe/monthly_diagnostic.py`
- [Monthly retry](https://github.com/astroctrl-dev/ha-mbus-energy-public/blob/main/mbus_probe/monthly_retry.py): `mbus_probe/monthly_retry.py`
- [History model](https://github.com/astroctrl-dev/ha-mbus-energy-public/blob/main/mbus_probe/history_model.py): `mbus_probe/history_model.py`
- [Clock maintenance](https://github.com/astroctrl-dev/ha-mbus-energy-public/blob/main/mbus_probe/clock_maintenance.py): `mbus_probe/clock_maintenance.py`
- [DST evidence](https://github.com/astroctrl-dev/ha-mbus-energy-public/blob/main/mbus_probe/dst_transition.py): `mbus_probe/dst_transition.py`
- [Diagnostic runtime](https://github.com/astroctrl-dev/ha-mbus-energy-public/blob/main/mbus_probe/diagnostic_runtime.py): `mbus_probe/diagnostic_runtime.py`
- [Frame-5 capture](https://github.com/astroctrl-dev/ha-mbus-energy-public/blob/main/mbus_probe/frame5_capture.py): `mbus_probe/frame5_capture.py`

### Publishing and analysis

- [Measurement projection](https://github.com/astroctrl-dev/ha-mbus-energy-public/blob/main/mbus_probe/ha_measurements.py): `mbus_probe/ha_measurements.py`
- [MQTT bridge](https://github.com/astroctrl-dev/ha-mbus-energy-public/blob/main/mbus_probe/mqtt_bridge.py): `mbus_probe/mqtt_bridge.py`
- [Analysis export](https://github.com/astroctrl-dev/ha-mbus-energy-public/blob/main/mbus_probe/analysis_export.py): `mbus_probe/analysis_export.py`
- [Archive view](https://github.com/astroctrl-dev/ha-mbus-energy-public/blob/main/mbus_probe/archive_view.py): `mbus_probe/archive_view.py`

### Other components

- **Home Assistant user**
- **M-Bus meter**
- **MQTT broker**
- **Local analysis data**

## Connections

- Home Assistant user → Web UI: uses (evidence: `README.md`)
- Web UI → App service: requests actions (evidence: `mbus_probe/meter_ui.py`)
- App service → Meter registry: manages selection (evidence: `mbus_probe/mbus_service.py`)
- App service → Poll schedule: schedules polling (evidence: `mbus_probe/mbus_service.py`)
- App service → M-Bus probe: reads meter (evidence: `mbus_probe/mbus_service.py`)
- M-Bus probe → Transmission gate: writes through (evidence: `mbus_probe/mbus_probe.py`)
- M-Bus probe → M-Bus meter: exchanges frames (evidence: `README.md`)
- Transmission gate → Telegram log: captures transmission (evidence: `mbus_probe/bus_timing.py`)
- M-Bus probe → Record decoder: validates frames (evidence: `mbus_probe/mbus_probe.py`)
- App service → Measurement projection: projects readings (evidence: `mbus_probe/mbus_service.py`)
- Measurement projection → MQTT bridge: provides measurements (evidence: `mbus_probe/mqtt_bridge.py`)
- MQTT bridge → MQTT broker: publishes discovery (evidence: `README.md`)
- App service → MQTT bridge: publishes readings (evidence: `mbus_probe/mbus_service.py`)
- Home Assistant user → History controller: requests history (evidence: `README.md`)
- Web UI → History controller: starts retrieval (evidence: `mbus_probe/meter_ui.py`)
- History controller → Archive acquisition: collects archive (evidence: `mbus_probe/history_controller.py`)
- Archive acquisition → Monthly diagnostics: reads monthly records (evidence: `mbus_probe/archive_acquisition.py`)
- History controller → History model: stores validated history (evidence: `mbus_probe/history_controller.py`)
- History controller → Monthly retry: tracks failures (evidence: `mbus_probe/history_controller.py`)
- History controller → MQTT bridge: publishes history (evidence: `mbus_probe/history_controller.py`)
- Home Assistant user → Clock maintenance: requests synchronization (evidence: `README.md`)
- Clock maintenance → Transmission gate: gates clock writes (evidence: `mbus_probe/clock_maintenance.py`)
- Clock maintenance → DST evidence: records transitions (evidence: `mbus_probe/clock_maintenance.py`)
- App service → Diagnostic runtime: runs diagnostics (evidence: `mbus_probe/mbus_service.py`)
- Home Assistant user → Frame-5 capture: requests capture (evidence: `README.md`)
- Web UI → Analysis export: downloads analysis (evidence: `mbus_probe/meter_ui.py`)
- Analysis export → Local analysis data: reads stored data (evidence: `README.md`)
- History controller → Archive view: projects archive (evidence: `mbus_probe/history_controller.py`)
- MQTT bridge → Archive view: publishes archive attributes (evidence: `mbus_probe/mqtt_bridge.py`)
