Zum Hauptinhalt springen

pigpio (Raspberry Pi GPIO) Smart-Home-Integration, kostenlos und Open Source

pigpio (Raspberry Pi GPIO)-Integration für Gladys Assistant

GPIO of a Raspberry Pi through pigpiod: inputs as triggers, outputs and PWM.

Info

Die Dokumentation dieser Integration wird von ihrem Autor geschrieben und ist bisher nur auf Englisch verfügbar.

External integration for Gladys Assistant (5.1.0 or later): the GPIO pins of a Raspberry Pi on your local network, through the pigpiod service and its documented socket interface (TCP port 8888), without any account. Unofficial, not affiliated with the pigpio project nor with Raspberry Pi Ltd. It was never tested with a real device: it was written from the official pigpio documentation and tested against a fake pigpiod.

What it does​

  • Inputs: each listed GPIO becomes a binary sensor (1 = high level). Its changes reach Gladys at once (pigpiod notifications) and can start scenes. Inputs are only read: the integration writes neither their mode nor their pull.
  • On/off outputs: switches (a light, a fan).
  • PWM outputs: dimmers from 0 to 100 % (duty cycle, at the frequency and range set in pigpiod).
  • Pulse outputs (gate, garage door): a "pulse" button (output active for the chosen length, then turned off by the integration), an "off" button and the state of the output. Never a switch: a scene "turn everything on" cannot reach them.
  • Every GPIO is also read again at the chosen interval (30 s by default).

Safety​

  • pigpiod has no password: anyone who reaches its port can drive the GPIO. Keep it on your local network, never exposed to the Internet, and limit it to the address of Gladys (pigpiod option -n <address>). The pigpiod option -x also limits the GPIO that may be changed.
  • A GPIO you never listed is never written, not even to turn it off. An off still owed from before (a pulse cut by a restart) goes out even if you removed that GPIO from the lists since. It follows the configuration as it is now: a GPIO now listed as an input is no longer written (that off is dropped), an output gets the off level of its current "active low" setting. At start, before the configuration is read, it goes as it was kept. Before writing an off, the integration reads the mode of the GPIO: in ALT mode (UART, I2C, SPI...) the off is dropped without writing anything (the log and the status say so, /data is updated); in input mode it is dropped without writing only when the GPIO is no longer in the outputs list (a configured output back to input after a Pi restart gets its off level); if the mode reading fails, the off is written anyway.
  • Outputs are off by default: while "Allow the outputs" is unchecked, turning on, PWM and pulses are refused and nothing is sent. The option is read again right before sending.
  • Before every "on", the integration reads the hardware revision of the Pi again on the same connection: if another Raspberry Pi answers at the address, nothing is sent. It also reads the mode of the GPIO: an "on" is never sent to a GPIO held by a function of the system (UART 14/15, I2C 2/3, SPI 7 to 11 when these functions are enabled on the Pi: ALT mode).
  • Off (switch to 0, PWM to 0, "off" button, end of a pulse) depends neither on the option, nor on the identity, nor on a reading, nor even on the configuration (the address and the active-low outputs are also kept in the device, used while the saved address is empty or invalid). It is refused only when the GPIO is no longer listed with that role (in the configuration, else in the device), when the device is unknown or when the value is invalid. It goes on its own connection, is read back, tried again within 250 ms, then kept (in memory and in /data) and sent again (1 s, 2 s, 5 s, 10 s, 30 s, then every minute) until the read back confirms it, as well as at every reading and at every start, before the configuration is even read. A newer "on" of the same GPIO, once sent, replaces it. When an "on" that left just before got no answer, its connection is cut at once (reset) and the confirmed off is read again 5 s, 20 s then 60 s later, and written again if the output came back on. An off owed to an old address (changed since) is still sent every minute until confirmed, and counted in the status.
  • A pulse writes its off in /data before leaving: if it could not be written, nothing is sent. A restart during a pulse sends the off at the next start. A pulse is refused when the output is already active or when an off of that GPIO is still waiting for its confirmation.
  • When the integration stops, every pulse under way is turned off (2 s at most).
  • Many relay boards are active low: list those outputs in "Active-low outputs", their off is then the high level.

Preparing the Raspberry Pi​

  1. Install pigpio and enable the pigpiod service (pigpio package of Raspberry Pi OS).
  2. Limit it to Gladys: for example pigpiod -n 192.168.1.10 (the address of Gladys) in the service command.
  3. Give the Pi a fixed address (DHCP reservation): the address is its identity in Gladys.
  4. Set the pull of the inputs in /boot/firmware/config.txt (for example gpio=17=ip,pu).

The Raspberry Pi 5 is not supported by pigpio.

Configuration​

FieldRole
Raspberry Pi addressIP address or name; :port only if pigpiod does not listen on 8888
InputsBCM numbers (2 to 27) separated by commas
Reading interval5 to 3600 s (30 by default)
Allow the outputsunchecked by default
On/off, pulse, PWM outputsBCM numbers; a GPIO has one role only
Active-low outputsoutputs that are on at the low level
Pulse length100 to 10000 ms (500 by default)

Save, run a Discovery and add the device. The "Test the connection" button reads the Pi again (at most once every 5 s). After changing the GPIO lists, run a Discovery again and save the device again.

Limits​

  • One Raspberry Pi per installation of the integration.
  • Notifications for GPIO 0 to 31 only (every one of the header); a bouncing sensor is published at most every 250 ms per GPIO, its last level always included.

Konfigurationseinstellungen​

Diese Einstellungen fragt pigpio (Raspberry Pi GPIO) in seinem Konfigurationsbildschirm in Gladys ab.

EinstellungTypPflichtfeldBeschreibung
Raspberry Pi with pigpiodsectionNeinThe integration talks to the pigpiod service of a Raspberry Pi on your local network (TCP port 8888), without any account. pigpiod has no password: anyone who reaches its port can drive the GPIO, so keep it on your local network and limit it to the Gladys address (pigpiod option -n). The Raspberry Pi 5 is not supported by pigpio. Give the Pi a fixed address: the address is its identity in Gladys. GPIO are given by their BCM number (2 to 27); a GPIO you do not list is never written.
Raspberry Pi addressstringJaIP address or host name; add ":port" only if pigpiod does not listen on 8888.
Inputs (BCM numbers)stringNeinGPIO read as inputs, separated by commas: their changes reach Gladys at once and can start scenes. They are only read: set their pull-up or pull-down on the Pi (config.txt).
Reading interval (s)numberNeinEvery GPIO is also read at this interval, in seconds (5 to 3600), in case a notification was lost.
OutputssectionNeinAn output may drive a relay, a pump, a gate. Nothing is ever written to a GPIO you never listed below, and nothing but "off" is written while the option "Allow the outputs" is unchecked. A gate or a garage door goes in "Pulse outputs": a push button, never an on/off switch, so a scene "turn everything on" never opens it.
Allow the outputsbooleanNeinUnchecked: turning on, PWM and pulses are refused; turning off stays possible.
On/off outputs (BCM numbers)stringNeinGPIO shown as switches (a light, a fan). Never a gate: use the pulse outputs.
Pulse outputs (BCM numbers)stringNeinGPIO with a "pulse" button (active for the pulse length, then off) and an "off" button: a gate, a garage door.
PWM outputs (BCM numbers)stringNeinGPIO shown as dimmers, 0 to 100 % duty cycle (pigpiod frequency and range).
Active-low outputsstringNeinOutputs that are on when the GPIO is low (many relay boards): their off is the high level.
Pulse length (ms)numberNeinHow long a pulse keeps the output active, in milliseconds (100 to 10000).
Language of the namesselectNeinLanguage of the device and feature names shown by Discovery.

So installierst du pigpio (Raspberry Pi GPIO) in Gladys​

  1. Öffne in Gladys Integrationen: pigpio (Raspberry Pi GPIO) erscheint im Katalog neben den nativen Integrationen, mit einem Community-Badge.
  2. Klicke auf Installieren. Gladys lädt das Docker-Image (ghcr.io/lm1lc3n7/gladys-pigpio:0.1.1) herunter, startet es in einer vom Kern isolierten Sandbox und erzeugt die Oberfläche der Integration (Geräte, Erkennung und Konfiguration).
  3. Öffne den Bildschirm Konfiguration der Integration, fülle die Einstellungen aus und speichere.
  4. Du kannst sie auch direkt über die URL ihres Repositorys installieren: https://github.com/LM1LC3N7/gladys-pigpio.

pigpio (Raspberry Pi GPIO) benötigt Gladys >=5.1.0. Der Katalog in Gladys wird stündlich aktualisiert, eine neue Version ist also spätestens eine Stunde nach ihrer Veröffentlichung verfügbar.

Du nutzt Gladys noch nicht? Es ist kostenlos und Open Source: folge der Installationsanleitung, um loszulegen.

Über externe Integrationen​

pigpio (Raspberry Pi GPIO) ist eine externe Integration: eine Community-Integration, die als Docker-Container verpackt und auf GitHub veröffentlicht wird. Gladys installiert sie mit einem Klick und führt sie in einer vom Kern isolierten Sandbox aus. Sie wird von LM1LC3N7 veröffentlicht und gepflegt, nicht vom Gladys-Kernteam.

Abonniere den Newsletter von Gladys Assistant

Ein paar E-Mails im Monat zu neuen Releases und Neuigkeiten aus dem Projekt. Verschickt von Pierre-Gilles Leymarie, dem Gründer des Projekts. Jederzeit abbestellbar 🙂