From 57b5e2f2f56a4a98d2ec0da516963bf94c9375e2 Mon Sep 17 00:00:00 2001 From: Ignace Date: Sun, 6 Sep 2026 15:57:14 +0200 Subject: [PATCH] install instructions --- .gitignore | 1 + README.md | 31 ++++++++++++++++++------------- hue-collector.service | 4 ++-- requirements.txt | 2 +- 4 files changed, 22 insertions(+), 16 deletions(-) diff --git a/.gitignore b/.gitignore index 5a74c64..21351b2 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ .env +.venv/ __pycache__/ .pytest_cache/ *.py[cod] diff --git a/README.md b/README.md index 8137b64..1882e20 100644 --- a/README.md +++ b/README.md @@ -15,11 +15,16 @@ approximately five-minute averages for 90 days, and hourly averages for two year ## Install on Raspberry Pi OS or Debian -Install the native RRDtool binding and Python dependencies: +Install Python's virtual-environment support and the native headers needed to build +the RRDtool package, then install every Python dependency into `.venv`: ```bash sudo apt update -sudo apt install python3 python3-flask python3-requests python3-rrdtool fonts-dejavu-core +sudo apt install python3 python3-venv python3-dev build-essential librrd-dev fonts-dejavu-core +python3 -m venv .venv +. .venv/bin/activate +python -m pip install --upgrade pip +python -m pip install -r requirements.txt ``` Create the Hue application key if you do not have one yet. Press the bridge link @@ -41,7 +46,7 @@ cp .env.example .env set -a . ./.env set +a -python3 -m hue_collector +python -m hue_collector ``` Open `http://PI_ADDRESS:8000`. The RRD files are written to `DATA_DIR`, which defaults @@ -49,13 +54,11 @@ to the project's `data/` directory. ## Run continuously with systemd -Install the project and environment file: +The included unit expects this repository at `/srv/service_hue_collector`, including +its `.venv` and `.env` files: ```bash -sudo install -d /opt/hue-collector -sudo cp -r hue_collector /opt/hue-collector/ -sudo cp .env /etc/hue-collector -sudo chmod 600 /etc/hue-collector +sudo chmod 600 /srv/service_hue_collector/.env sudo cp hue-collector.service /etc/systemd/system/ sudo systemctl daemon-reload sudo systemctl enable --now hue-collector @@ -93,11 +96,13 @@ trusted. ## Development -On a Debian-based machine, install `python3-rrdtool` through apt. Flask and Requests -can alternatively be installed from `requirements.txt`. When using a virtual -environment, create it with `--system-site-packages` so it can see the apt-installed -RRDtool module. +Create the virtual environment and install all application dependencies from the +requirements file: ```bash -python3 -m unittest discover -s tests +sudo apt install python3-venv python3-dev build-essential librrd-dev fonts-dejavu-core +python3 -m venv .venv +. .venv/bin/activate +python -m pip install -r requirements.txt +python -m unittest discover -s tests ``` diff --git a/hue-collector.service b/hue-collector.service index 874ad4c..20ee14a 100644 --- a/hue-collector.service +++ b/hue-collector.service @@ -8,9 +8,9 @@ Type=simple DynamicUser=yes StateDirectory=hue-collector WorkingDirectory=/srv/service_hue_collector -EnvironmentFile=/srv/service_hue_collector +EnvironmentFile=/srv/service_hue_collector/.env Environment=DATA_DIR=/var/lib/hue-collector -ExecStart=/var/lib/hue-collector/.venv/bin/python3 -m hue_collector +ExecStart=/srv/service_hue_collector/.venv/bin/python -m hue_collector Restart=on-failure RestartSec=5 PrivateTmp=yes diff --git a/requirements.txt b/requirements.txt index 7dedeaa..c16a580 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,3 +1,3 @@ -# Install the native RRDtool binding with: apt install python3-rrdtool Flask>=2.2,<4 requests>=2,<3 +rrdtool>=0.1,<1