From 3f7b6d5cdc62c7e3b75420a0f55b2f1c620bb89e Mon Sep 17 00:00:00 2001 From: Joshua Mesilane Date: Wed, 13 May 2026 11:54:32 +1000 Subject: [PATCH] fix: add smbus2 dependency, i2c-tools, and use hex I2C addresses in docs - Add smbus2>=0.4.0 to pyproject.toml core dependencies so it is always present in the venv rather than relying on runtime auto-install - Add i2c-tools to apt-get installs in both install and upgrade paths so /dev/i2c-* devices are accessible and i2cdetect is available for diagnostics (service user was already being added to the i2c group) - Switch ENS210 config examples to hex I2C address notation (0x43) to match datasheets and i2cdetect output; update contributor docs guidance accordingly Co-Authored-By: Claude Sonnet 4.6 --- config.yaml.example | 2 +- docs/adding_sensors.md | 2 +- manage.sh | 4 ++-- pyproject.toml | 1 + 4 files changed, 5 insertions(+), 4 deletions(-) diff --git a/config.yaml.example b/config.yaml.example index e8c86a2..2776f59 100644 --- a/config.yaml.example +++ b/config.yaml.example @@ -242,7 +242,7 @@ sensors: # enabled: true # auto_install_packages: true # settings: - # i2c_address: 67 # 0x43 in decimal (default ENS210 address) + # i2c_address: 0x43 # Default ENS210 address # bus_number: 1 # I2C bus number (1 for Raspberry Pi default) # read_timeout_seconds: 1.0 # Max seconds to wait for valid data (polls every 50 ms) diff --git a/docs/adding_sensors.md b/docs/adding_sensors.md index e16de4b..ca3ed65 100644 --- a/docs/adding_sensors.md +++ b/docs/adding_sensors.md @@ -107,7 +107,7 @@ Find the `sensors.definitions` block and add your sensor alongside the existing # some_option: value ``` -Use decimal for numeric config values that would naturally be written in hex (e.g. I2C addresses: `0x43` = `67`). Add a comment showing both forms if the value is commonly written in hex. +Use hex notation for I2C addresses (e.g. `0x43`) as this matches how addresses are listed in datasheets and tools like `i2cdetect`. ### 3. Test locally diff --git a/manage.sh b/manage.sh index aa8dcde..7d5b2fa 100755 --- a/manage.sh +++ b/manage.sh @@ -341,7 +341,7 @@ install_repeater() { echo "25"; echo "# Installing system dependencies..." apt-get update -qq - DEBIAN_FRONTEND=noninteractive apt-get install -y libffi-dev libusb-1.0-0 sudo jq pip python3-venv python3-rrdtool wget swig build-essential python3-dev + DEBIAN_FRONTEND=noninteractive apt-get install -y libffi-dev libusb-1.0-0 sudo jq pip python3-venv python3-rrdtool wget swig build-essential python3-dev i2c-tools # Install polkit (package name varies by distro version) DEBIAN_FRONTEND=noninteractive apt-get install -y policykit-1 2>/dev/null \ || DEBIAN_FRONTEND=noninteractive apt-get install -y polkitd pkexec 2>/dev/null \ @@ -746,7 +746,7 @@ upgrade_repeater() { echo "[3/9] Updating system dependencies..." apt-get update -qq - apt-get install -y libffi-dev libusb-1.0-0 sudo jq pip python3-venv python3-rrdtool wget swig build-essential python3-dev + apt-get install -y libffi-dev libusb-1.0-0 sudo jq pip python3-venv python3-rrdtool wget swig build-essential python3-dev i2c-tools # Install polkit (package name varies by distro version) apt-get install -y policykit-1 2>/dev/null \ || apt-get install -y polkitd pkexec 2>/dev/null \ diff --git a/pyproject.toml b/pyproject.toml index b189948..aa08873 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -39,6 +39,7 @@ dependencies = [ "pyserial>=3.5", "pyjwt>=2.8.0", "ws4py>=0.6.0", + "smbus2>=0.4.0", ]