# crazymike249/ha-addons architecture

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

- Interactive diagram: https://gitdiagram.com/crazymike249/ha-addons
- Repository: https://github.com/crazymike249/ha-addons

## Overview

This Home Assistant add-on monitors configured audio streams for now-playing metadata and can publish changes to MQTT. Its workflow loads options, polls each stream, probes and decodes format-specific metadata, suppresses unchanged titles, then logs and optionally publishes updates. The implementation is concentrated in one Python file; the config file and deployment assets are present in the tree but their behavior is not established by the excerpts.

Main entry points: [`stream_monitor/stream_monitor.py`](https://github.com/crazymike249/ha-addons/blob/main/stream_monitor/stream_monitor.py) (Metadata router)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_setup["Configuration and runtime"]
  node_options["Options loader<br/>[stream_monitor.py]"]
  node_monitor["Monitor entry point<br/>[stream_monitor.py]"]
  node_poll_loop["Polling loop<br/>[stream_monitor.py]"]
  node_poll_stream["Poll stream<br/>[stream_monitor.py]"]
end

subgraph group_metadata["Metadata extraction"]
  node_metadata_router["Metadata router<br/>[stream_monitor.py]"]
  node_mp3["MP3 metadata<br/>[stream_monitor.py]"]
  node_aac["AAC metadata<br/>[stream_monitor.py]"]
  node_ogg["OGG metadata<br/>[stream_monitor.py]"]
  node_ffprobe_runner["ffprobe runner<br/>[stream_monitor.py]"]
  node_decoder["Text decoder<br/>[stream_monitor.py]"]
end

subgraph group_delivery["Updates and integrations"]
  node_change_filter["Change filter<br/>[stream_monitor.py]"]
  node_logger["Console logger<br/>[stream_monitor.py]"]
  node_mqtt_init["MQTT setup<br/>[stream_monitor.py]"]
  node_mqtt_publish["MQTT publisher<br/>[stream_monitor.py]"]
end

node_ha_user(("Home Assistant user"))
node_stream["Audio stream"]
node_ffprobe["ffprobe"]
node_broker["MQTT broker"]

node_ha_user -.->|"configures"| node_options
node_options -->|"provides options"| node_monitor
node_monitor -->|"initializes"| node_mqtt_init
node_monitor -->|"starts"| node_poll_loop
node_poll_loop -->|"schedules"| node_poll_stream
node_poll_stream -->|"requests metadata"| node_metadata_router
node_metadata_router -->|"dispatches"| node_mp3
node_metadata_router -->|"dispatches"| node_aac
node_metadata_router -->|"dispatches"| node_ogg
node_metadata_router -->|"tries fallback"| node_mp3
node_metadata_router -->|"tries fallback"| node_aac
node_metadata_router -->|"tries fallback"| node_ogg
node_mp3 -->|"runs probes"| node_ffprobe_runner
node_aac -->|"runs probe"| node_ffprobe_runner
node_ogg -->|"runs probe"| node_ffprobe_runner
node_ffprobe_runner -->|"executes"| node_ffprobe
node_mp3 -->|"decodes tags"| node_decoder
node_aac -->|"decodes title"| node_decoder
node_ogg -->|"decodes tags"| node_decoder
node_poll_stream -->|"checks changes"| node_change_filter
node_change_filter -->|"logs title"| node_logger
node_change_filter -->|"publishes changes"| node_mqtt_publish
node_mqtt_publish -.->|"publishes MQTT"| node_broker
node_mqtt_init -.->|"connects"| node_broker
node_poll_stream -->|"probes URL"| node_stream

click node_options "https://github.com/crazymike249/ha-addons/blob/main/stream_monitor/stream_monitor.py"
click node_monitor "https://github.com/crazymike249/ha-addons/blob/main/stream_monitor/stream_monitor.py"
click node_poll_loop "https://github.com/crazymike249/ha-addons/blob/main/stream_monitor/stream_monitor.py"
click node_poll_stream "https://github.com/crazymike249/ha-addons/blob/main/stream_monitor/stream_monitor.py"
click node_metadata_router "https://github.com/crazymike249/ha-addons/blob/main/stream_monitor/stream_monitor.py"
click node_mp3 "https://github.com/crazymike249/ha-addons/blob/main/stream_monitor/stream_monitor.py"
click node_aac "https://github.com/crazymike249/ha-addons/blob/main/stream_monitor/stream_monitor.py"
click node_ogg "https://github.com/crazymike249/ha-addons/blob/main/stream_monitor/stream_monitor.py"
click node_ffprobe_runner "https://github.com/crazymike249/ha-addons/blob/main/stream_monitor/stream_monitor.py"
click node_decoder "https://github.com/crazymike249/ha-addons/blob/main/stream_monitor/stream_monitor.py"
click node_change_filter "https://github.com/crazymike249/ha-addons/blob/main/stream_monitor/stream_monitor.py"
click node_logger "https://github.com/crazymike249/ha-addons/blob/main/stream_monitor/stream_monitor.py"
click node_mqtt_init "https://github.com/crazymike249/ha-addons/blob/main/stream_monitor/stream_monitor.py"
click node_mqtt_publish "https://github.com/crazymike249/ha-addons/blob/main/stream_monitor/stream_monitor.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_options,node_monitor,node_poll_loop,node_poll_stream,node_ha_user toneBlue
class node_metadata_router,node_mp3,node_aac,node_ogg,node_ffprobe_runner,node_decoder toneAmber
class node_change_filter,node_logger,node_mqtt_init,node_mqtt_publish toneMint
class node_stream,node_ffprobe,node_broker toneIndigo
```

## Components

### Configuration and runtime

- [Options loader](https://github.com/crazymike249/ha-addons/blob/main/stream_monitor/stream_monitor.py): `stream_monitor/stream_monitor.py`
- [Monitor entry point](https://github.com/crazymike249/ha-addons/blob/main/stream_monitor/stream_monitor.py): `stream_monitor/stream_monitor.py`
- [Polling loop](https://github.com/crazymike249/ha-addons/blob/main/stream_monitor/stream_monitor.py): `stream_monitor/stream_monitor.py`
- [Poll stream](https://github.com/crazymike249/ha-addons/blob/main/stream_monitor/stream_monitor.py): `stream_monitor/stream_monitor.py`

### Metadata extraction

- [Metadata router](https://github.com/crazymike249/ha-addons/blob/main/stream_monitor/stream_monitor.py): `stream_monitor/stream_monitor.py`
- [MP3 metadata](https://github.com/crazymike249/ha-addons/blob/main/stream_monitor/stream_monitor.py): `stream_monitor/stream_monitor.py`
- [AAC metadata](https://github.com/crazymike249/ha-addons/blob/main/stream_monitor/stream_monitor.py): `stream_monitor/stream_monitor.py`
- [OGG metadata](https://github.com/crazymike249/ha-addons/blob/main/stream_monitor/stream_monitor.py): `stream_monitor/stream_monitor.py`
- [ffprobe runner](https://github.com/crazymike249/ha-addons/blob/main/stream_monitor/stream_monitor.py): `stream_monitor/stream_monitor.py`
- [Text decoder](https://github.com/crazymike249/ha-addons/blob/main/stream_monitor/stream_monitor.py): `stream_monitor/stream_monitor.py`

### Updates and integrations

- [Change filter](https://github.com/crazymike249/ha-addons/blob/main/stream_monitor/stream_monitor.py): `stream_monitor/stream_monitor.py`
- [Console logger](https://github.com/crazymike249/ha-addons/blob/main/stream_monitor/stream_monitor.py): `stream_monitor/stream_monitor.py`
- [MQTT setup](https://github.com/crazymike249/ha-addons/blob/main/stream_monitor/stream_monitor.py): `stream_monitor/stream_monitor.py`
- [MQTT publisher](https://github.com/crazymike249/ha-addons/blob/main/stream_monitor/stream_monitor.py): `stream_monitor/stream_monitor.py`

### Other components

- **Home Assistant user**
- **Audio stream**
- **ffprobe**
- **MQTT broker**

## Connections

- Home Assistant user → Options loader: configures
- Options loader → Monitor entry point: provides options (evidence: `stream_monitor/stream_monitor.py`)
- Monitor entry point → MQTT setup: initializes (evidence: `stream_monitor/stream_monitor.py`)
- Monitor entry point → Polling loop: starts (evidence: `stream_monitor/stream_monitor.py`)
- Polling loop → Poll stream: schedules (evidence: `stream_monitor/stream_monitor.py`)
- Poll stream → Metadata router: requests metadata (evidence: `stream_monitor/stream_monitor.py`)
- Metadata router → MP3 metadata: dispatches (evidence: `stream_monitor/stream_monitor.py`)
- Metadata router → AAC metadata: dispatches (evidence: `stream_monitor/stream_monitor.py`)
- Metadata router → OGG metadata: dispatches (evidence: `stream_monitor/stream_monitor.py`)
- Metadata router → MP3 metadata: tries fallback (evidence: `stream_monitor/stream_monitor.py`)
- Metadata router → AAC metadata: tries fallback (evidence: `stream_monitor/stream_monitor.py`)
- Metadata router → OGG metadata: tries fallback (evidence: `stream_monitor/stream_monitor.py`)
- MP3 metadata → ffprobe runner: runs probes (evidence: `stream_monitor/stream_monitor.py`)
- AAC metadata → ffprobe runner: runs probe (evidence: `stream_monitor/stream_monitor.py`)
- OGG metadata → ffprobe runner: runs probe (evidence: `stream_monitor/stream_monitor.py`)
- ffprobe runner → ffprobe: executes (evidence: `stream_monitor/stream_monitor.py`)
- MP3 metadata → Text decoder: decodes tags (evidence: `stream_monitor/stream_monitor.py`)
- AAC metadata → Text decoder: decodes title (evidence: `stream_monitor/stream_monitor.py`)
- OGG metadata → Text decoder: decodes tags (evidence: `stream_monitor/stream_monitor.py`)
- Poll stream → Change filter: checks changes (evidence: `stream_monitor/stream_monitor.py`)
- Change filter → Console logger: logs title (evidence: `stream_monitor/stream_monitor.py`)
- Change filter → MQTT publisher: publishes changes (evidence: `stream_monitor/stream_monitor.py`)
- MQTT publisher → MQTT broker: publishes MQTT (evidence: `stream_monitor/stream_monitor.py`)
- MQTT setup → MQTT broker: connects (evidence: `stream_monitor/stream_monitor.py`)
- Poll stream → Audio stream: probes URL (evidence: `stream_monitor/stream_monitor.py`)
