removed grafana and victoria

This commit is contained in:
2026-09-06 15:31:57 +02:00
parent 2da3685ad2
commit b7f98c2ccf
15 changed files with 407 additions and 379 deletions
+61 -51
View File
@@ -1,68 +1,78 @@
# Hue collector
# Lightweight Hue history
A local-only monitoring stack for a Philips Hue bridge. The Python service reads the
Hue v2 API, exposes Prometheus metrics, VictoriaMetrics stores them, and Grafana ships
with a provisioned dashboard.
A small service for Raspberry Pi that reads the Philips Hue v2 API, stores history in
fixed-size [RRDtool](https://oss.oetiker.ch/rrdtool/) databases, and serves its own web
dashboard. It does not require Grafana, VictoriaMetrics, Node.js, or a browser-side
charting library.
## Metrics
The dashboard contains:
- For every room and zone: available, shining, off, and unavailable light counts;
percentages shining, off, and unavailable; plus average brightness of the shining
lights.
- For every temperature and illuminance sensor: availability and its latest reading,
labelled with its room and zones.
- One graph for every room and zone. Unavailable, off, and on lights form a stacked
percentage area, with average intensity of shining lights drawn as a line.
- Temperature and illuminance graphs for every available Hue sensor.
- 6-hour, 24-hour, 7-day, and 30-day time ranges.
A device is available when its Hue `zigbee_connectivity` resource is connected. A
light is shining when it is available and reports `on=true`. If a device has no
connectivity resource (for example some bridge-owned resources), it is considered
available.
RRD storage is bounded automatically: raw samples are retained for 7 days,
approximately five-minute averages for 90 days, and hourly averages for two years.
## Setup
## Configure Hue
1. Find your bridge IP in the Hue app under **Settings → My Hue system → System
information**.
2. Create an application key while physically near the bridge:
Find the bridge IP in the Hue app under **Settings → My Hue system → System
information**. Then create an application key while physically near the bridge:
```bash
curl -k -X POST https://BRIDGE_IP/api \
-H 'Content-Type: application/json' \
-d '{"devicetype":"local-hue-collector"}'
```
```bash
curl -k -X POST https://BRIDGE_IP/api \
-H 'Content-Type: application/json' \
-d '{"devicetype":"local-hue-collector"}'
```
Press the bridge link button immediately before running the command. Copy the
returned `username`; that is the application key.
3. Configure and start the stack:
Press the bridge link button immediately before running the command. The returned
`username` is the application key.
```bash
cp .env.example .env
# Edit .env with the bridge IP and application key.
docker compose up --build -d
```
4. Open Grafana at `http://HOST_LAN_IP:3000` and sign in with `admin` / `admin`. The
dashboard is in the **Hue** folder. Change this development password if the port
is reachable by anyone else on your network.
## Run with Docker Compose
Useful local endpoints:
```bash
cp .env.example .env
# Edit .env with the bridge IP and application key.
docker compose up --build -d --remove-orphans
```
- Collector metrics: <http://localhost:8000/metrics>
- VictoriaMetrics UI: <http://localhost:8428/vmui/>
- Grafana: <http://localhost:3000>
Open `http://PI_ADDRESS:8000`. RRD data persists in the `hue-rrd-data` Docker volume.
The `--remove-orphans` option removes containers from the previous
VictoriaMetrics/Grafana version; their old named volumes are not deleted.
By default, published ports bind to `0.0.0.0`, making them reachable through the
host's `192.168.178.x` address. Docker cannot bind to a wildcard subnet such as
`192.168.178.*`; to listen only on the LAN interface, set `PUBLISH_ADDRESS` in `.env`
to the host's exact address, for example `192.168.178.42`. Ensure your host firewall
permits access only from trusted networks. Named Docker volumes retain metrics and
Grafana state across restarts. TLS verification is off by default because Hue bridges
normally use a self-signed certificate; set `HUE_VERIFY_TLS=true` if yours has a
trusted certificate.
By default, port 8000 binds to all interfaces. To bind only to the Pi's LAN interface,
put its exact address in `.env`, for example:
```env
PUBLISH_ADDRESS=192.168.178.42
```
## Run directly on Raspberry Pi OS/Debian
This avoids Docker overhead entirely:
```bash
sudo apt update
sudo apt install python3 python3-requests python3-rrdtool fonts-dejavu-core
mkdir -p "$HOME/.local/share/hue-collector"
export HUE_BRIDGE_HOST=192.168.178.2
export HUE_APPLICATION_KEY=your-key
export DATA_DIR="$HOME/.local/share/hue-collector"
python3 -m hue_collector
```
The page is served on port 8000. For continuous operation, run it with systemd or use
the Compose setup with `restart: unless-stopped`.
TLS verification is disabled by default because Hue bridges normally use a
self-signed certificate. Set `HUE_VERIFY_TLS=true` if the bridge has a trusted
certificate. The health check is available at `/healthz`.
## Development
The collector tests do not require RRDtool:
```bash
python -m venv .venv
. .venv/bin/activate
pip install -r requirements.txt
python -m unittest discover -s tests
HUE_BRIDGE_HOST=... HUE_APPLICATION_KEY=... python -m hue_collector
python3 -m unittest discover -s tests
```