Lora MQTT Bridge

Hi,

I am currently trying to build a Lora-MQTT bridge between two raspberrys.
(well initially two ESP32 were planned, but dropped because of additional features needed)

see JPTs-Homeassist-Addons/LoraMqttBridge at main · JPT77/JPTs-Homeassist-Addons · GitHub

I want to use the same code in the HA-App@HAOS and on RaspiOS@Z2W.
I already got a proof of concept that validates hardware, libraries etc on RaspiOS.

Now I try to make it work in HA.

I use the LoraRF Python library.
Problem is: LoraRF uses RPi.GPIO which is not available on HA.
My Solution was to use the drop in replacement called rpi-lgpio
While I was able to build it during app installation, it is missing the lgpio binary.
This does not seem to be available through apk?

Should I try building liblgpio myself?
Or is there another way?

thank you very much

Type this into a search engine. Lots of things to pick from here starting with the HA GPIO integration…

site:home-assistant.io gpio app add-on

I solved it after a lot of trial and error.

This is my Dockerfile

# cannot install adafruit-lgpio on Python 3.12
FROM ghcr.io/home-assistant/aarch64-base-python:3.13-alpine3.22

WORKDIR /app

# needed so it opens correct devices?
ENV RPI_LGPIO_REVISION=e04171

RUN apk add --no-cache \
      python3 \
      py3-pip \
      linux-headers \
      gcc \
      musl-dev \
      swig \
      libgpiod

# this lgpio implementation also delivers the binary which lgpio doesn't
RUN python3 -m pip install --no-cache-dir \
      adafruit-lgpio

# do not install dependencies automatically 
RUN python3 -m pip install --no-cache-dir --break-system-packages \
      rpi-lgpio --no-deps

# install LoRaRF dependencies manually
RUN python3 -m pip install --no-cache-dir --break-system-packages \
      paho-mqtt \
      PyYAML \
      gpiod \
      spidev

# do not install dependencies automatically so RPi.GPIO isn't installed
RUN python3 -m pip install --no-cache-dir --break-system-packages \
      --no-deps LoRaRF

[...]

on RaspiOS i simply install dependencies like this

pip install LoRaRF paho-mqtt PyYAML spidev gpiod