Skip to main content

Raspberry PI to Home Assistant bridge through MQTT for wired sensors/actuators

Project description

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?

Project details


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.3.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.3-py2.py3-none-any.whl (30.2 kB view details)

Uploaded Python 2Python 3

File details

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

File metadata

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

File hashes

Hashes for rpi2home_assistant-2.3.3.tar.gz
Algorithm Hash digest
SHA256 858b45d98ce30df5fd52b5e4d92e8361b60be2943a46b9cc80788eef8ed09d3a
MD5 8b86d0a1793462ab67feb1e23dd7d427
BLAKE2b-256 c02dec2df85168f5abb0e9f10d670df0cd4d2ada5b07efba08271bc04bac99ad

See more details on using hashes here.

Provenance

The following attestation bundles were made for rpi2home_assistant-2.3.3.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.3-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for rpi2home_assistant-2.3.3-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 1dcd486149f7aef92da37dd4dbaf6cbfefe250222b7cf4c2f2542ec9b5e52145
MD5 95c4fc8b56e8de00b331e2fbc91556a5
BLAKE2b-256 282ac0949da001f616900638c7baf84ade477ad2c1e6f9c66fbb4851e763484a

See more details on using hashes here.

Provenance

The following attestation bundles were made for rpi2home_assistant-2.3.3-py2.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.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page