main
Shelly RGBW2 Animator
Leichter Python-Dienst, der Animationen direkt am Shelly RGBW2 (Gen1) abspielt. openHAB sendet nur noch den gewünschten Modus per MQTT – der Pi wird dadurch deutlich entlastet.
Features
- Direkte HTTP-Ansteuerung des Shelly (kein openHAB-Event-Bus)
- Steuerung per MQTT (
shelly-animator/set) - Einfach neue Animationen hinzufügen
- Läuft als Docker-Container oder systemd-Service
Schnellstart (Docker – empfohlen)
cd shelly-animator
docker compose up -d --build
Logs:
docker logs -f shelly-animator
Alternative: systemd (ohne Docker)
sudo mkdir -p /opt/shelly-animator
sudo cp -r app requirements.txt /opt/shelly-animator/
cd /opt/shelly-animator
python3 -m venv venv
./venv/bin/pip install -r requirements.txt
sudo cp systemd/shelly-animator.service /etc/systemd/system/
sudo systemctl daemon-reload
sudo systemctl enable --now shelly-animator
MQTT-Steuerung
| Topic | Richtung | Payload |
|---|---|---|
shelly-animator/set |
write | chill / party / gaming / stop |
shelly-animator/state |
read | aktueller Modus oder off |
Beispiele:
mosquitto_pub -h localhost -p 1884 -t shelly-animator/set -m "party"
mosquitto_pub -h localhost -p 1884 -t shelly-animator/set -m "stop"
openHAB Anbindung
Ersetze die drei JS-Animation-Rules durch eine einfache Rule:
// Rule: Status → Shelly Animator (MQTT)
const { items, actions } = require('openhab');
const status = items.getItem('Status').state.toString();
const mqtt = actions.get('mqtt', 'mqtt:broker:72a3b87ef9'); // ggf. anpassen
const map = {
'Chillmode': 'chill',
'Partymode': 'party',
'Gamingmode': 'gaming',
};
const anim = map[status] || 'stop';
mqtt.publishMQTT('shelly-animator/set', anim);
Trigger: Status Item State Change.
Neue Animation hinzufügen
- Datei anlegen:
app/animations/meine_anim.py
from .base import Animation
import colorsys
class MeineAnimation(Animation):
name = "meine"
interval = 0.15 # Sekunden zwischen Ticks
def on_start(self):
super().on_start()
self._t = 0
def tick(self):
self._t += 0.05
# ... Farbe berechnen ...
r, g, b = 255, 0, 128
self.shelly.set_color(r, g, b, gain=60)
- In
app/animations/__init__.pyregistrieren:
from .meine_anim import MeineAnimation
REGISTRY = {
...
"meine": MeineAnimation,
}
- Container neu bauen / Service neu starten.
Umgebungsvariablen
| Variable | Default | Beschreibung |
|---|---|---|
SHELLY_HOST |
192.168.178.151 |
IP des Shelly |
SHELLY_USER |
shelly@till.immers.ch |
Digest-Auth User |
SHELLY_PASS |
... |
Digest-Auth Passwort |
MQTT_HOST |
localhost |
MQTT Broker |
MQTT_PORT |
1884 |
MQTT Port |
MQTT_PREFIX |
shelly-animator |
Topic-Prefix |
LOG_LEVEL |
INFO |
DEBUG / INFO / WARNING |
Description
AN expendable lightweight docker or systemctl service how send effects to a shelly rgbw2 using mqtt. See the readme
44 KiB
0 Stars
1 Watchers
0 Forks
Languages
Python
97.7%
Dockerfile
2.3%