Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 0 additions & 10 deletions Home Assistant/addon/pi_somfy/CHANGELOG.md

This file was deleted.

7 changes: 0 additions & 7 deletions Home Assistant/addon/pi_somfy/translations/en.yaml

This file was deleted.

16 changes: 13 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -403,19 +403,29 @@ Pi-Somfy can integrate directly with [Home Assistant](https://www.home-assistant

1. In Home Assistant, go to **HACS → Integrations**.
2. Click the three-dot menu (top right) and select **Custom repositories**.
3. Add `https://github.com/Nickduino/Pi-Somfy` with category **Integration** and click **Add**.
3. Add `https://github.com/Nickduino/Pi-Somfy` with category **Integration** and click **Add** — or use the button below:

[![Open your Home Assistant instance and open a repository inside the Home Assistant Community Store.](https://my.home-assistant.io/badges/hacs_repository.svg)](https://my.home-assistant.io/redirect/hacs_repository/?owner=Nickduino&repository=Pi-Somfy&category=integration)
4. Search for "Pi-Somfy" in HACS, click **Download**, and restart Home Assistant.
5. Go to **Settings → Devices & Services → Add Integration**, search for "Pi-Somfy", and enter the IP address and port of your Pi-Somfy instance (default port: 80).

#### Option B: Manual install

1. Copy the `Home Assistant/custom_components/pi_somfy` folder into your Home Assistant `config/custom_components/` directory.
1. Copy the `custom_components/pi_somfy` folder into your Home Assistant `config/custom_components/` directory.
2. Restart Home Assistant.
3. Go to **Settings → Devices & Services → Add Integration**, search for "Pi-Somfy", and enter the IP address and port of your Pi-Somfy instance (default port: 80).

### Installing the Add-on

1. Copy the `Home Assistant/addon/pi_somfy` folder to your Home Assistant `addons/pi_somfy` directory.
#### Option A: Add-on repository (recommended)

1. Go to **Settings → Add-ons → Add-on Store**, click the three-dot menu (top right) and select **Repositories**.
2. Add `https://github.com/Nickduino/Pi-Somfy` and click **Add**.
3. Find "Pi-Somfy" under the new repository and install it.

#### Option B: Manual install

1. Copy the `somfy-ha-addon` folder to your Home Assistant `addons/somfy-ha-addon` directory.
2. Go to **Settings → Add-ons → Add-on Store** and click the refresh button.
3. Find "Pi-Somfy" under "Local add-ons" and install it.
4. Configure the GPIO pin in the add-on settings (default: GPIO 4).
Expand Down
3 changes: 3 additions & 0 deletions repository.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
name: "Pi-Somfy"
url: "https://github.com/Nickduino/Pi-Somfy"
maintainer: "Nickduino"
29 changes: 29 additions & 0 deletions somfy-ha-addon/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Changelog

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
- Auto-discovery for Pi-Somfy custom integration
- Debian-based container with pigpiod for GPIO access
- Persistent configuration across updates
- Watchdog health monitoring
35 changes: 25 additions & 10 deletions Home Assistant/addon/pi_somfy/DOCS.md → somfy-ha-addon/DOCS.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,15 @@ 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) |
| `enable_mqtt` | `false` | Enable the MQTT bridge, using the broker connected via the Supervisor (e.g. the Mosquitto add-on) |

### Physical remote receiver (optional)

Expand All @@ -44,6 +45,20 @@ 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 `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 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.

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:
Expand All @@ -69,8 +84,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 `enable_mqtt` is set) MQTTno 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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,13 @@ RUN git clone --branch v${BUILD_VERSION} --depth 1 https://github.com/Nickduino/

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 /
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -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:
Expand Down Expand Up @@ -31,18 +31,22 @@ 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
enable_mqtt: false
schema:
gpio_pin: "int(0,27)"
rx_gpio_pin: "int(0,27)?"
spi_sck: "int(0,27)"
spi_mosi: "int(0,27)"
spi_miso: "int(0,27)"
spi_csn: "int(0,27)"
enable_mqtt: "bool"
discovery:
- pi_somfy
File renamed without changes
File renamed without changes
49 changes: 44 additions & 5 deletions Home Assistant/addon/pi_somfy/run.sh → somfy-ha-addon/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,44 @@ 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 — 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.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}"

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
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
else
bashio::log.info "MQTT disabled (set enable_mqtt in add-on options to enable)"
fi

# Ensure log location exists and is writable
sed -i "s|^LogLocation.*|LogLocation = /data/|" "${CONFIG_FILE}"

Expand Down Expand Up @@ -74,9 +112,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

Expand All @@ -88,7 +127,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}
29 changes: 29 additions & 0 deletions somfy-ha-addon/translations/en.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
---
configuration:
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: >-
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.