From db4c46666bfc8ba7b68da94386b74401f4253ae8 Mon Sep 17 00:00:00 2001 From: orren5 Date: Sun, 26 Jul 2026 20:06:28 +0300 Subject: [PATCH 1/8] add mqtt config on addon directly --- Home Assistant/addon/pi_somfy/DOCS.md | 34 ++++++++++++------ Home Assistant/addon/pi_somfy/Dockerfile | 30 +++++++++++++--- Home Assistant/addon/pi_somfy/config.yaml | 7 ++++ Home Assistant/addon/pi_somfy/run.sh | 42 ++++++++++++++++++++--- 4 files changed, 94 insertions(+), 19 deletions(-) diff --git a/Home Assistant/addon/pi_somfy/DOCS.md b/Home Assistant/addon/pi_somfy/DOCS.md index 4c33f1c..c75af05 100644 --- a/Home Assistant/addon/pi_somfy/DOCS.md +++ b/Home Assistant/addon/pi_somfy/DOCS.md @@ -19,14 +19,19 @@ This add-on runs [Pi-Somfy](https://github.com/Nickduino/Pi-Somfy) directly on y ## Configuration -| Option | Default | Description | -|---------------|---------|---------------------------------------------------------------------------| -| `gpio_pin` | `4` | GPIO pin number for the 433.42 MHz transmitter | -| `rx_gpio_pin` | (none) | GPIO wired to a CC1101 receiver's data output. Leave blank to disable the physical-remote receiver entirely. | -| `spi_sck` | `21` | CC1101 bit-banged SPI clock GPIO (only used when `rx_gpio_pin` is set) | -| `spi_mosi` | `20` | CC1101 bit-banged SPI MOSI GPIO (only used when `rx_gpio_pin` is set) | -| `spi_miso` | `19` | CC1101 bit-banged SPI MISO GPIO (only used when `rx_gpio_pin` is set) | -| `spi_csn` | `16` | CC1101 bit-banged SPI chip-select GPIO (only used when `rx_gpio_pin` is set) | +| Option | Default | Description | +|------------------|-------------------------|---------------------------------------------------------------------------| +| `gpio_pin` | `4` | GPIO pin number for the 433.42 MHz transmitter | +| `rx_gpio_pin` | (none) | GPIO wired to a CC1101 receiver's data output. Leave blank to disable the physical-remote receiver entirely. | +| `spi_sck` | `21` | CC1101 bit-banged SPI clock GPIO (only used when `rx_gpio_pin` is set) | +| `spi_mosi` | `20` | CC1101 bit-banged SPI MOSI GPIO (only used when `rx_gpio_pin` is set) | +| `spi_miso` | `19` | CC1101 bit-banged SPI MISO GPIO (only used when `rx_gpio_pin` is set) | +| `spi_csn` | `16` | CC1101 bit-banged SPI chip-select GPIO (only used when `rx_gpio_pin` is set) | +| `mqtt_server` | (none) | MQTT broker host/IP. Leave blank to disable MQTT entirely. | +| `mqtt_port` | `1883` | MQTT broker port (only used when `mqtt_server` is set) | +| `mqtt_user` | (none) | MQTT broker username, if the broker requires auth | +| `mqtt_password` | (none) | MQTT broker password, if the broker requires auth | +| `mqtt_client_id` | `somfy-mqtt-bridge` | MQTT client ID — must be unique if you run more than one Pi-Somfy instance against the same broker | ### Physical remote receiver (optional) @@ -44,6 +49,15 @@ on another computer (it mounts as a normal FAT32 `boot`/`bootfs` drive), add `dtparam=spi=on` to the bottom of `config.txt`, then reinsert the card and power the Pi back on. +### MQTT (optional) + +Setting `mqtt_server` enables the MQTT bridge alongside the web UI, publishing +Home Assistant MQTT auto-discovery for every shutter (cover entities with +live position and open/closing state) to the broker at `mqtt_server`. Useful +if you already run a broker for other devices and want push-based updates +instead of the custom integration's REST polling. Leave `mqtt_server` blank +to run without MQTT, exactly as before. + ## Web UI The add-on provides a web interface accessible in two ways: @@ -69,8 +83,8 @@ Shutter configuration and rolling codes are stored in `/data/operateShutters.con ## Notes -- This add-on runs Pi-Somfy with the web interface and scheduler only (no MQTT, no Alexa emulation) -- For MQTT or Alexa integration, run Pi-Somfy standalone on a dedicated Raspberry Pi +- This add-on runs Pi-Somfy with the web interface, scheduler, and (if `mqtt_server` is set) MQTT — no Alexa emulation +- For Alexa integration, run Pi-Somfy standalone on a dedicated Raspberry Pi - Shutter position is estimated based on movement timing, but persists across restarts (saved to `/data/operateShutters.conf`'s `[ShutterPositions]` section as it changes) ## Support diff --git a/Home Assistant/addon/pi_somfy/Dockerfile b/Home Assistant/addon/pi_somfy/Dockerfile index 28e0c71..bef2dfb 100644 --- a/Home Assistant/addon/pi_somfy/Dockerfile +++ b/Home Assistant/addon/pi_somfy/Dockerfile @@ -34,18 +34,40 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ && apt-get purge -y --auto-remove make gcc g++ libc6-dev swig python3-dev \ && rm -rf /var/lib/apt/lists/* -# Clone Pi-Somfy source at build time +# Cache-busting for the clone below: Docker caches `RUN git clone` by the +# command's literal text, not by checking whether the remote branch has new +# commits — without this, a rebuild can silently reuse a stale clone from +# before your latest push (and finish suspiciously fast). ADD-from-URL is +# different: Docker re-checks the URL's ETag/Last-Modified on every build, so +# using GitHub's commit API here invalidates the cache below whenever the +# branch actually moves. Testing-only — remove this block alongside +# REPO_URL/GIT_REF once this merges upstream. +# IMPORTANT: the branch name in this URL must always match GIT_REF below — +# if you switch testing branches, update BOTH or this silently stops +# busting the cache (confirmed: this has drifted out of sync before, and +# every rebuild kept re-serving a stale clone from before the branch switch +# with no visible error). +ADD https://api.github.com/repos/orren5/Pi-Somfy/commits/feature/add_mqtt_option /tmp/branch_head.json + +# Clone Pi-Somfy source at build time. Defaults below point at this fork's +# testing branch — revert REPO_URL to https://github.com/Nickduino/Pi-Somfy.git +# and GIT_REF to v${BUILD_VERSION} once this merges upstream and a release +# tag exists. Override either at build time with: +# docker build --build-arg REPO_URL=... --build-arg GIT_REF=... ... ARG BUILD_VERSION -RUN git clone --branch v${BUILD_VERSION} --depth 1 https://github.com/Nickduino/Pi-Somfy.git /somfy +ARG REPO_URL=https://github.com/orren5/Pi-Somfy.git +ARG GIT_REF=feature/add_mqtt_option +RUN git clone --branch ${GIT_REF} --depth 1 ${REPO_URL} /somfy WORKDIR /somfy -# Install Python dependencies (excluding paho-mqtt — not needed without -m flag) +# Install Python dependencies RUN pip3 install --no-cache-dir --break-system-packages \ ephem \ configparser \ Flask \ - requests + requests \ + paho-mqtt # Copy run script COPY run.sh / diff --git a/Home Assistant/addon/pi_somfy/config.yaml b/Home Assistant/addon/pi_somfy/config.yaml index b08c084..90a7ab3 100644 --- a/Home Assistant/addon/pi_somfy/config.yaml +++ b/Home Assistant/addon/pi_somfy/config.yaml @@ -37,6 +37,8 @@ options: spi_mosi: 20 spi_miso: 19 spi_csn: 16 + mqtt_port: 1883 + mqtt_client_id: "somfy-mqtt-bridge" schema: gpio_pin: "int(0,27)" rx_gpio_pin: "int(0,27)?" @@ -44,5 +46,10 @@ schema: spi_mosi: "int(0,27)" spi_miso: "int(0,27)" spi_csn: "int(0,27)" + mqtt_server: "str?" + mqtt_port: "int(1,65535)" + mqtt_user: "str?" + mqtt_password: "password?" + mqtt_client_id: "str" discovery: - pi_somfy diff --git a/Home Assistant/addon/pi_somfy/run.sh b/Home Assistant/addon/pi_somfy/run.sh index 6f4e03b..988ef44 100644 --- a/Home Assistant/addon/pi_somfy/run.sh +++ b/Home Assistant/addon/pi_somfy/run.sh @@ -44,6 +44,37 @@ else bashio::log.info "RX receiver disabled (set rx_gpio_pin in add-on options to enable)" fi +# MQTT (Home Assistant auto-discovery via a broker) is optional — only +# write the [MQTT] section and pass -m to operateShutters.py if the user +# set mqtt_server, mirroring the rx_gpio_pin pattern above. +MQTT_ARGS="" +if bashio::config.has_value 'mqtt_server'; then + MQTT_SERVER=$(bashio::config 'mqtt_server') + MQTT_PORT=$(bashio::config 'mqtt_port') + MQTT_CLIENT_ID=$(bashio::config 'mqtt_client_id') + # mqtt_user/mqtt_password stay optional even with mqtt_server set (a + # broker without auth) — read defensively rather than trusting + # bashio::config's return value for a genuinely-absent optional key. + MQTT_USER="" + if bashio::config.has_value 'mqtt_user'; then + MQTT_USER=$(bashio::config 'mqtt_user') + fi + MQTT_PASSWORD="" + if bashio::config.has_value 'mqtt_password'; then + MQTT_PASSWORD=$(bashio::config 'mqtt_password') + fi + bashio::log.info "MQTT enabled: broker ${MQTT_SERVER}:${MQTT_PORT}" + + sed -i "s|^MQTT_Server.*|MQTT_Server = ${MQTT_SERVER}|" "${CONFIG_FILE}" + sed -i "s|^MQTT_Port.*|MQTT_Port = ${MQTT_PORT}|" "${CONFIG_FILE}" + sed -i "s|^MQTT_User.*|MQTT_User = ${MQTT_USER}|" "${CONFIG_FILE}" + sed -i "s|^MQTT_Password.*|MQTT_Password = ${MQTT_PASSWORD}|" "${CONFIG_FILE}" + sed -i "s|^MQTT_ClientID.*|MQTT_ClientID = ${MQTT_CLIENT_ID}|" "${CONFIG_FILE}" + MQTT_ARGS="-m" +else + bashio::log.info "MQTT disabled (set mqtt_server in add-on options to enable)" +fi + # Ensure log location exists and is writable sed -i "s|^LogLocation.*|LogLocation = /data/|" "${CONFIG_FILE}" @@ -74,9 +105,10 @@ if [ "${IS_PI5}" = true ]; then bashio::log.info "Pi 5 detected — using lgpio (no pigpiod needed)" else bashio::log.info "Starting pigpiod..." - # Deliberately not passing -m (disable alerts): -m silently prevents - # pi.callback() from ever delivering edge notifications, which the RX - # receiver needs when rx_gpio_pin is set. + # Deliberately not passing pigpiod's own -m flag (disable alerts) here — + # unrelated to operateShutters.py's -m/MQTT_ARGS above. pigpiod's -m + # silently prevents pi.callback() from ever delivering edge + # notifications, which the RX receiver needs when rx_gpio_pin is set. pigpiod -l sleep 1 @@ -88,7 +120,7 @@ else bashio::log.info "pigpiod started successfully" fi -# Launch Pi-Somfy with web interface only (no MQTT, no Alexa) +# Launch Pi-Somfy with the web interface (no Alexa), MQTT if configured above cd /somfy bashio::log.info "Starting Pi-Somfy..." -exec python3 operateShutters.py -c "${CONFIG_FILE}" -a +exec python3 operateShutters.py -c "${CONFIG_FILE}" -a ${MQTT_ARGS} From 61ac6f276b45cd82fe5604d3fc2955651d253e07 Mon Sep 17 00:00:00 2001 From: orren5 Date: Sat, 1 Aug 2026 14:39:11 +0300 Subject: [PATCH 2/8] Remove testing-only fork/branch clone override from Dockerfile The cache-busting ADD and REPO_URL/GIT_REF overrides were only needed while testing against this fork's branch; revert to cloning the upstream Nickduino release tag ahead of pushing this branch upstream. --- Home Assistant/addon/pi_somfy/Dockerfile | 25 ++---------------------- 1 file changed, 2 insertions(+), 23 deletions(-) diff --git a/Home Assistant/addon/pi_somfy/Dockerfile b/Home Assistant/addon/pi_somfy/Dockerfile index bef2dfb..c6fd40e 100644 --- a/Home Assistant/addon/pi_somfy/Dockerfile +++ b/Home Assistant/addon/pi_somfy/Dockerfile @@ -34,30 +34,9 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ && apt-get purge -y --auto-remove make gcc g++ libc6-dev swig python3-dev \ && rm -rf /var/lib/apt/lists/* -# Cache-busting for the clone below: Docker caches `RUN git clone` by the -# command's literal text, not by checking whether the remote branch has new -# commits — without this, a rebuild can silently reuse a stale clone from -# before your latest push (and finish suspiciously fast). ADD-from-URL is -# different: Docker re-checks the URL's ETag/Last-Modified on every build, so -# using GitHub's commit API here invalidates the cache below whenever the -# branch actually moves. Testing-only — remove this block alongside -# REPO_URL/GIT_REF once this merges upstream. -# IMPORTANT: the branch name in this URL must always match GIT_REF below — -# if you switch testing branches, update BOTH or this silently stops -# busting the cache (confirmed: this has drifted out of sync before, and -# every rebuild kept re-serving a stale clone from before the branch switch -# with no visible error). -ADD https://api.github.com/repos/orren5/Pi-Somfy/commits/feature/add_mqtt_option /tmp/branch_head.json - -# Clone Pi-Somfy source at build time. Defaults below point at this fork's -# testing branch — revert REPO_URL to https://github.com/Nickduino/Pi-Somfy.git -# and GIT_REF to v${BUILD_VERSION} once this merges upstream and a release -# tag exists. Override either at build time with: -# docker build --build-arg REPO_URL=... --build-arg GIT_REF=... ... +# Clone Pi-Somfy source at build time ARG BUILD_VERSION -ARG REPO_URL=https://github.com/orren5/Pi-Somfy.git -ARG GIT_REF=feature/add_mqtt_option -RUN git clone --branch ${GIT_REF} --depth 1 ${REPO_URL} /somfy +RUN git clone --branch v${BUILD_VERSION} --depth 1 https://github.com/Nickduino/Pi-Somfy.git /somfy WORKDIR /somfy From 0a5b23fc424ddcd713acbc00c1d775648bcf841c Mon Sep 17 00:00:00 2001 From: orren5 Date: Sat, 15 Aug 2026 00:52:55 +0300 Subject: [PATCH 3/8] sed fix --- Home Assistant/addon/pi_somfy/run.sh | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/Home Assistant/addon/pi_somfy/run.sh b/Home Assistant/addon/pi_somfy/run.sh index 988ef44..d7fd946 100644 --- a/Home Assistant/addon/pi_somfy/run.sh +++ b/Home Assistant/addon/pi_somfy/run.sh @@ -65,11 +65,15 @@ if bashio::config.has_value 'mqtt_server'; then fi bashio::log.info "MQTT enabled: broker ${MQTT_SERVER}:${MQTT_PORT}" - sed -i "s|^MQTT_Server.*|MQTT_Server = ${MQTT_SERVER}|" "${CONFIG_FILE}" - sed -i "s|^MQTT_Port.*|MQTT_Port = ${MQTT_PORT}|" "${CONFIG_FILE}" - sed -i "s|^MQTT_User.*|MQTT_User = ${MQTT_USER}|" "${CONFIG_FILE}" - sed -i "s|^MQTT_Password.*|MQTT_Password = ${MQTT_PASSWORD}|" "${CONFIG_FILE}" - sed -i "s|^MQTT_ClientID.*|MQTT_ClientID = ${MQTT_CLIENT_ID}|" "${CONFIG_FILE}" + for entry in "MQTT_Server:${MQTT_SERVER}" "MQTT_Port:${MQTT_PORT}" "MQTT_User:${MQTT_USER}" "MQTT_Password:${MQTT_PASSWORD}" "MQTT_ClientID:${MQTT_CLIENT_ID}"; do + key="${entry%%:*}" + value="${entry#*:}" + if grep -q "^${key}" "${CONFIG_FILE}"; then + sed -i "s|^${key}.*|${key} = ${value}|" "${CONFIG_FILE}" + else + sed -i "/^\[MQTT\]/a ${key} = ${value}" "${CONFIG_FILE}" + fi + done MQTT_ARGS="-m" else bashio::log.info "MQTT disabled (set mqtt_server in add-on options to enable)" From a9335192515a4e59dab18f2d2e9390ec481fad89 Mon Sep 17 00:00:00 2001 From: orren5 Date: Sat, 15 Aug 2026 00:58:22 +0300 Subject: [PATCH 4/8] use mqtt want service --- Home Assistant/addon/pi_somfy/DOCS.md | 19 ++++---- Home Assistant/addon/pi_somfy/config.yaml | 11 ++--- Home Assistant/addon/pi_somfy/run.sh | 54 ++++++++++------------- 3 files changed, 36 insertions(+), 48 deletions(-) diff --git a/Home Assistant/addon/pi_somfy/DOCS.md b/Home Assistant/addon/pi_somfy/DOCS.md index c75af05..ab2992e 100644 --- a/Home Assistant/addon/pi_somfy/DOCS.md +++ b/Home Assistant/addon/pi_somfy/DOCS.md @@ -27,11 +27,7 @@ This add-on runs [Pi-Somfy](https://github.com/Nickduino/Pi-Somfy) directly on y | `spi_mosi` | `20` | CC1101 bit-banged SPI MOSI GPIO (only used when `rx_gpio_pin` is set) | | `spi_miso` | `19` | CC1101 bit-banged SPI MISO GPIO (only used when `rx_gpio_pin` is set) | | `spi_csn` | `16` | CC1101 bit-banged SPI chip-select GPIO (only used when `rx_gpio_pin` is set) | -| `mqtt_server` | (none) | MQTT broker host/IP. Leave blank to disable MQTT entirely. | -| `mqtt_port` | `1883` | MQTT broker port (only used when `mqtt_server` is set) | -| `mqtt_user` | (none) | MQTT broker username, if the broker requires auth | -| `mqtt_password` | (none) | MQTT broker password, if the broker requires auth | -| `mqtt_client_id` | `somfy-mqtt-bridge` | MQTT client ID — must be unique if you run more than one Pi-Somfy instance against the same broker | +| `enable_mqtt` | `false` | Enable the MQTT bridge, using the broker connected via the Supervisor (e.g. the Mosquitto add-on) | ### Physical remote receiver (optional) @@ -51,12 +47,13 @@ and power the Pi back on. ### MQTT (optional) -Setting `mqtt_server` enables the MQTT bridge alongside the web UI, publishing +Setting `enable_mqtt` enables the MQTT bridge alongside the web UI, publishing Home Assistant MQTT auto-discovery for every shutter (cover entities with -live position and open/closing state) to the broker at `mqtt_server`. Useful -if you already run a broker for other devices and want push-based updates -instead of the custom integration's REST polling. Leave `mqtt_server` blank -to run without MQTT, exactly as before. +live position and open/closing state) to whichever broker is connected via +the Supervisor — install and start the official Mosquitto broker add-on and +Pi-Somfy will find it automatically, no broker details to enter. Useful if +you want push-based updates instead of the custom integration's REST polling. +Leave `enable_mqtt` off to run without MQTT, exactly as before. ## Web UI @@ -83,7 +80,7 @@ Shutter configuration and rolling codes are stored in `/data/operateShutters.con ## Notes -- This add-on runs Pi-Somfy with the web interface, scheduler, and (if `mqtt_server` is set) MQTT — no Alexa emulation +- This add-on runs Pi-Somfy with the web interface, scheduler, and (if `enable_mqtt` is set) MQTT — no Alexa emulation - For Alexa integration, run Pi-Somfy standalone on a dedicated Raspberry Pi - Shutter position is estimated based on movement timing, but persists across restarts (saved to `/data/operateShutters.conf`'s `[ShutterPositions]` section as it changes) diff --git a/Home Assistant/addon/pi_somfy/config.yaml b/Home Assistant/addon/pi_somfy/config.yaml index 90a7ab3..03e3ffe 100644 --- a/Home Assistant/addon/pi_somfy/config.yaml +++ b/Home Assistant/addon/pi_somfy/config.yaml @@ -31,14 +31,15 @@ ports: ports_description: 80/tcp: "Pi-Somfy Web UI" watchdog: "http://[HOST]:[PORT:80]/cmd/getConfig" +services: + - mqtt:want options: gpio_pin: 4 spi_sck: 21 spi_mosi: 20 spi_miso: 19 spi_csn: 16 - mqtt_port: 1883 - mqtt_client_id: "somfy-mqtt-bridge" + enable_mqtt: false schema: gpio_pin: "int(0,27)" rx_gpio_pin: "int(0,27)?" @@ -46,10 +47,6 @@ schema: spi_mosi: "int(0,27)" spi_miso: "int(0,27)" spi_csn: "int(0,27)" - mqtt_server: "str?" - mqtt_port: "int(1,65535)" - mqtt_user: "str?" - mqtt_password: "password?" - mqtt_client_id: "str" + enable_mqtt: "bool" discovery: - pi_somfy diff --git a/Home Assistant/addon/pi_somfy/run.sh b/Home Assistant/addon/pi_somfy/run.sh index d7fd946..4e57609 100644 --- a/Home Assistant/addon/pi_somfy/run.sh +++ b/Home Assistant/addon/pi_somfy/run.sh @@ -44,39 +44,33 @@ else bashio::log.info "RX receiver disabled (set rx_gpio_pin in add-on options to enable)" fi -# MQTT (Home Assistant auto-discovery via a broker) is optional — only -# write the [MQTT] section and pass -m to operateShutters.py if the user -# set mqtt_server, mirroring the rx_gpio_pin pattern above. +# MQTT (Home Assistant auto-discovery via a broker) is optional — pulled +# from the Supervisor's mqtt service (e.g. the Mosquitto add-on) rather +# than asking the user to re-enter broker details already known to HA. MQTT_ARGS="" -if bashio::config.has_value 'mqtt_server'; then - MQTT_SERVER=$(bashio::config 'mqtt_server') - MQTT_PORT=$(bashio::config 'mqtt_port') - MQTT_CLIENT_ID=$(bashio::config 'mqtt_client_id') - # mqtt_user/mqtt_password stay optional even with mqtt_server set (a - # broker without auth) — read defensively rather than trusting - # bashio::config's return value for a genuinely-absent optional key. - MQTT_USER="" - if bashio::config.has_value 'mqtt_user'; then - MQTT_USER=$(bashio::config 'mqtt_user') +if bashio::config.true 'enable_mqtt'; then + if bashio::services.available 'mqtt'; then + MQTT_HOST=$(bashio::services mqtt "host") + MQTT_PORT=$(bashio::services mqtt "port") + MQTT_USER=$(bashio::services mqtt "username") + MQTT_PASSWORD=$(bashio::services mqtt "password") + bashio::log.info "MQTT enabled: broker ${MQTT_HOST}:${MQTT_PORT}" + + for entry in "MQTT_Server:${MQTT_HOST}" "MQTT_Port:${MQTT_PORT}" "MQTT_User:${MQTT_USER}" "MQTT_Password:${MQTT_PASSWORD}" "MQTT_ClientID:somfy-mqtt-bridge"; do + key="${entry%%:*}" + value="${entry#*:}" + if grep -q "^${key}" "${CONFIG_FILE}"; then + sed -i "s|^${key}.*|${key} = ${value}|" "${CONFIG_FILE}" + else + sed -i "/^\[MQTT\]/a ${key} = ${value}" "${CONFIG_FILE}" + fi + done + MQTT_ARGS="-m" + else + bashio::log.warning "enable_mqtt is on but no MQTT broker add-on was found — MQTT disabled" fi - MQTT_PASSWORD="" - if bashio::config.has_value 'mqtt_password'; then - MQTT_PASSWORD=$(bashio::config 'mqtt_password') - fi - bashio::log.info "MQTT enabled: broker ${MQTT_SERVER}:${MQTT_PORT}" - - for entry in "MQTT_Server:${MQTT_SERVER}" "MQTT_Port:${MQTT_PORT}" "MQTT_User:${MQTT_USER}" "MQTT_Password:${MQTT_PASSWORD}" "MQTT_ClientID:${MQTT_CLIENT_ID}"; do - key="${entry%%:*}" - value="${entry#*:}" - if grep -q "^${key}" "${CONFIG_FILE}"; then - sed -i "s|^${key}.*|${key} = ${value}|" "${CONFIG_FILE}" - else - sed -i "/^\[MQTT\]/a ${key} = ${value}" "${CONFIG_FILE}" - fi - done - MQTT_ARGS="-m" else - bashio::log.info "MQTT disabled (set mqtt_server in add-on options to enable)" + bashio::log.info "MQTT disabled (set enable_mqtt in add-on options to enable)" fi # Ensure log location exists and is writable From ab0b6bdab99d68adad919a6bbd44f9d02bbbf2a9 Mon Sep 17 00:00:00 2001 From: orren5 Date: Sat, 15 Aug 2026 23:21:12 +0300 Subject: [PATCH 5/8] Address review: EnableDiscovery, missing [MQTT] guard, translations, docs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Four fixes requested in PR review: 1. Write EnableDiscovery = true alongside the other MQTT keys — without it, an existing operateShutters.conf where EnableDiscovery is false or missing gets MQTT with no auto-discovery, defeating the point of the enable_mqtt toggle. 2. Guard against a missing [MQTT] section before the key-writing loop. The loop's `sed -i "/^\[MQTT\]/a ..."` silently no-ops if [MQTT] isn't in the file at all (e.g. a pre-existing config from before MQTT support existed). 3. Flesh out translations/en.yaml so every add-on option shows a real name/description on the Configuration tab instead of the raw key. 4. DOCS.md: note that the enable_mqtt toggle only finds a broker running as a Home Assistant add-on — an external broker needs Pi-Somfy run standalone with -m instead. --- Home Assistant/addon/pi_somfy/DOCS.md | 4 +++ Home Assistant/addon/pi_somfy/run.sh | 11 +++++++- .../addon/pi_somfy/translations/en.yaml | 28 +++++++++++++++++-- 3 files changed, 39 insertions(+), 4 deletions(-) diff --git a/Home Assistant/addon/pi_somfy/DOCS.md b/Home Assistant/addon/pi_somfy/DOCS.md index ab2992e..ee113cc 100644 --- a/Home Assistant/addon/pi_somfy/DOCS.md +++ b/Home Assistant/addon/pi_somfy/DOCS.md @@ -55,6 +55,10 @@ Pi-Somfy will find it automatically, no broker details to enter. Useful if you want push-based updates instead of the custom integration's REST polling. Leave `enable_mqtt` off to run without MQTT, exactly as before. +If your broker is not running as a Home Assistant add-on, this toggle will not +find it. Run Pi-Somfy standalone with `-m` and set the broker details in +`operateShutters.conf` instead. + ## Web UI The add-on provides a web interface accessible in two ways: diff --git a/Home Assistant/addon/pi_somfy/run.sh b/Home Assistant/addon/pi_somfy/run.sh index 4e57609..a607b6e 100644 --- a/Home Assistant/addon/pi_somfy/run.sh +++ b/Home Assistant/addon/pi_somfy/run.sh @@ -56,7 +56,16 @@ if bashio::config.true 'enable_mqtt'; then MQTT_PASSWORD=$(bashio::services mqtt "password") bashio::log.info "MQTT enabled: broker ${MQTT_HOST}:${MQTT_PORT}" - for entry in "MQTT_Server:${MQTT_HOST}" "MQTT_Port:${MQTT_PORT}" "MQTT_User:${MQTT_USER}" "MQTT_Password:${MQTT_PASSWORD}" "MQTT_ClientID:somfy-mqtt-bridge"; do + if ! grep -q "^\[MQTT\]" "${CONFIG_FILE}"; then + printf '\n[MQTT]\n' >> "${CONFIG_FILE}" + fi + + for entry in "MQTT_Server:${MQTT_HOST}" \ + "MQTT_Port:${MQTT_PORT}" \ + "MQTT_User:${MQTT_USER}" \ + "MQTT_Password:${MQTT_PASSWORD}" \ + "MQTT_ClientID:somfy-mqtt-bridge" \ + "EnableDiscovery:true"; do key="${entry%%:*}" value="${entry#*:}" if grep -q "^${key}" "${CONFIG_FILE}"; then diff --git a/Home Assistant/addon/pi_somfy/translations/en.yaml b/Home Assistant/addon/pi_somfy/translations/en.yaml index a758f4f..68bf966 100644 --- a/Home Assistant/addon/pi_somfy/translations/en.yaml +++ b/Home Assistant/addon/pi_somfy/translations/en.yaml @@ -1,7 +1,29 @@ --- configuration: gpio_pin: - name: GPIO Pin + name: Transmitter GPIO pin + description: GPIO pin the 433.42 MHz transmitter is wired to. + rx_gpio_pin: + name: Receiver GPIO pin (optional) description: >- - The GPIO pin number where the 433.42 MHz RF transmitter is connected. - Default is GPIO 4. + GPIO wired to a CC1101 receiver's data output, for tracking physical + remote button presses. Leave blank to disable the receiver. + spi_sck: + name: CC1101 SPI clock GPIO + description: Only used when a receiver GPIO pin is set. + spi_mosi: + name: CC1101 SPI MOSI GPIO + description: Only used when a receiver GPIO pin is set. + spi_miso: + name: CC1101 SPI MISO GPIO + description: Only used when a receiver GPIO pin is set. + spi_csn: + name: CC1101 SPI chip-select GPIO + description: Only used when a receiver GPIO pin is set. + enable_mqtt: + name: Enable MQTT + description: >- + Publish shutters to Home Assistant using MQTT auto-discovery, so cover + entities appear automatically with push-based updates instead of REST + polling. Requires the Mosquitto broker add-on to be installed and + running. Leave off to use the web UI and custom integration only. From 737e26fa83bbf7058c671d647ab8acc2dc4000fa Mon Sep 17 00:00:00 2001 From: orren5 Date: Sun, 16 Aug 2026 18:44:30 +0300 Subject: [PATCH 6/8] fix the version --- Home Assistant/addon/pi_somfy/config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Home Assistant/addon/pi_somfy/config.yaml b/Home Assistant/addon/pi_somfy/config.yaml index 03e3ffe..9f7d3b4 100644 --- a/Home Assistant/addon/pi_somfy/config.yaml +++ b/Home Assistant/addon/pi_somfy/config.yaml @@ -1,6 +1,6 @@ name: "Pi-Somfy" description: "Operate Somfy RTS shutters via 433.42 MHz RF on Raspberry Pi GPIO" -version: "3.0.0" +version: "3.2" slug: "pi_somfy" url: "https://github.com/Nickduino/Pi-Somfy" arch: From e64ac20adbd12477b29a99f6e53b05c33e8ec388 Mon Sep 17 00:00:00 2001 From: orren5 Date: Sun, 16 Aug 2026 18:57:15 +0300 Subject: [PATCH 7/8] fix the build version hardcoded value, now it fetching from the config.yaml version dynamically --- Home Assistant/addon/pi_somfy/build.sh | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/Home Assistant/addon/pi_somfy/build.sh b/Home Assistant/addon/pi_somfy/build.sh index 933d142..43f5ae9 100644 --- a/Home Assistant/addon/pi_somfy/build.sh +++ b/Home Assistant/addon/pi_somfy/build.sh @@ -12,11 +12,15 @@ set -euo pipefail SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" -echo "Building Pi-Somfy add-on locally..." +# Read from config.yaml rather than hardcoding, so this can't drift out of +# sync with the tag Supervisor actually builds against. +BUILD_VERSION="$(grep -m1 '^version:' "${SCRIPT_DIR}/config.yaml" | sed -E 's/version: *"?([^"]+)"?/\1/')" + +echo "Building Pi-Somfy add-on locally (version ${BUILD_VERSION})..." docker build \ --build-arg BUILD_FROM=ghcr.io/home-assistant/aarch64-base:latest \ - --build-arg BUILD_VERSION=3.0.0 \ - -t local/pi_somfy:3.0.0 \ + --build-arg BUILD_VERSION="${BUILD_VERSION}" \ + -t "local/pi_somfy:${BUILD_VERSION}" \ "${SCRIPT_DIR}" -echo "Done. Run with: docker run --rm -it local/pi_somfy:3.0.0" +echo "Done. Run with: docker run --rm -it local/pi_somfy:${BUILD_VERSION}" From 94e35287a4fb220d2b1321ce6efacb6c9b71b9ff Mon Sep 17 00:00:00 2001 From: orren5 Date: Sun, 16 Aug 2026 20:52:38 +0300 Subject: [PATCH 8/8] update changelog --- Home Assistant/addon/pi_somfy/CHANGELOG.md | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/Home Assistant/addon/pi_somfy/CHANGELOG.md b/Home Assistant/addon/pi_somfy/CHANGELOG.md index 6f30f4b..7698788 100644 --- a/Home Assistant/addon/pi_somfy/CHANGELOG.md +++ b/Home Assistant/addon/pi_somfy/CHANGELOG.md @@ -1,6 +1,25 @@ # Changelog -## 3.0.0 +This add-on's version always matches the [Pi-Somfy](https://github.com/Nickduino/Pi-Somfy) +release it's built on, so each entry below is what's new in that release. + +## 3.2 + +- Fixed the add-on showing an incorrect version number, which could cause the add-on to fail + to install or update properly. +- Add support for a CC1101 RF receiver, so button presses on a physical Somfy remote are + tracked and stay in sync with the app and Home Assistant. +- Added an optional CC1101 transmitter as an alternative to the built-in one. +- Redesigned the schedule editor and the manual-operation remote control in the web UI. + +## 3.1 + +- Added native Home Assistant integration: Pi-Somfy shutters now show up as proper cover + entities in Home Assistant, with position control, instead of needing a separate setup. +- Added support for running on a Raspberry Pi 5, detected automatically. +- Made the optional MQTT integration easier to set up. + +## 3.0 - Initial release as Home Assistant add-on - Web UI with ingress and external port access