Skip to main content

rpi2home-assistant

GitHub Actions Workflow Status PyPI - Version

This project provides a Python daemon to transform a Raspberry PI into a bridge between GPIO inputs/outputs and Home Assistant, through MQTT.

In particular this software allows to:

  • sample low-voltage inputs from Raspberry GPIO pins directly (with no isolation/protection/HAT), publish them on MQTT and get them exposed to Home Assistant as binary sensors;
  • sample a wide range of electrical signals (voltages) from 3V-48V AC or DC, using a dedicated Raspberry HAT, publish them on MQTT and get them exposed to Home Assistant as binary sensors;
  • expose Raspberry GPIO output pins in Home Assistant as switches or as buttons to e.g. activate relays, using a dedicated Raspberry HAT / relay board or just drive low-voltage electrical devices;

All these features are implemented in an Home Assistant-friendly fashion. For example, this utility requires no configuration on Home Assistant-side thanks to MQTT discovery messages that are automatically published and let Home Assistant automatically discover the devices. In other words you will just need to prepare 1 configuration file (the rpi2home-assistant config file) and that's it. All properties of the exposed devices (names, icons, descriptions, etc) can be provided/customized in the rpi2home-assistant config file.

An example of a panel of sensors/actuators created using rpi2home-assistant in Home Assistant 2024.5 (sensor/switch/button names have been blurred for privacy reasons; binary sensor status is shown in Italian language):

Home Assistant screenshot

Prerequisites

See prerequisites.md.

Documentation

Installation

See install.md.

Configuration file

The configuration file of rpi2home-assistant is of course /etc/rpi2home-assistant.yaml. During the installation the default config file with dummy options is installed. It is useful to showcase the syntax. See config.yaml for the full documentation of the configuration options.

Permissions

This python code needs to run as root due to ensure access to the Raspberry I2C and GPIO peripherals.

Logs

After starting the application you can verify from the logs whether it's running successfully:

journalctl -u rpi2home-assistant --since="5min ago"

Development

See development.md.

Useful links

Very similar project, more flexible and much bigger, targeting specific sensor boards:

TODO

  • Eventually get rid of GPIOZERO + PIGPIOD which consume CPU and also force use of e.g. the queue.Queue due to the multithreading issues; replace these 2 parts with direct Raspberry PI GPIO access?

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

rpi2home_assistant-2.3.4.tar.gz (1.8 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

rpi2home_assistant-2.3.4-py3-none-any.whl (30.8 kB view details)

Uploaded Python 3

File details

Details for the file rpi2home_assistant-2.3.4.tar.gz.

File metadata

  • Download URL: rpi2home_assistant-2.3.4.tar.gz
  • Upload date:
  • Size: 1.8 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for rpi2home_assistant-2.3.4.tar.gz
Algorithm Hash digest
SHA256 a311f0e53072b4595cc65e79b7fc8eb5db5703bec469e2f916ea362af8a17975
MD5 bf874954410eb5240eff077af19cdc64
BLAKE2b-256 19eeeef4191835052ab542e9cc5fef3b273ee6dbd42bf5bee55ce64c401e2a35

See more details on using hashes here.

Provenance

The following attestation bundles were made for rpi2home_assistant-2.3.4.tar.gz:

Publisher: pypi-release.yml on f18m/rpi2home-assistant

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file rpi2home_assistant-2.3.4-py3-none-any.whl.

File metadata

File hashes

Hashes for rpi2home_assistant-2.3.4-py3-none-any.whl
Algorithm Hash digest
SHA256 53137c72561e1645916d5c66635c143bf6a55b739a328b3fa8cccc824753abf0
MD5 525a708c39f4fb1cbcce0177e1a6b2c6
BLAKE2b-256 2fb0db8b7a81b092de7bcd0a88d27ce5e87392551992c964082214fd3bd63470

See more details on using hashes here.

Provenance

The following attestation bundles were made for rpi2home_assistant-2.3.4-py3-none-any.whl:

Publisher: pypi-release.yml on f18m/rpi2home-assistant

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

This release

2.3.4 This release

2 files

2.3.3

2 files

2.3.2

2 files

2.3.1

2 files

2.3.0

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page