Hello everyone,
I got myself a Raspberry Pi 4b 2gb and first installed the 64-bit version of hassio. After some reading it turned out the 64-bit version wasn’t able to use the GPIO. So now I installed the 32-bit version (https://github.com/home-assistant/operating-system/releases/download/7.1/haos_rpi4-7.1.img.xz). For some reason I still can’t seem to figure out what is wrong with the custom addon.
Eventually I am trying to use the rpi-rf package and use the receive script. I know there are some other custom addons around here somewhere that do exactly that. However these are outdated and do not work. so I am trying to figure out how to get everything working with the current setup.
config.yaml:
name: "RPi RF Receiver"
version: "1.0.0"
slug: "rpi_rf_receiver"
description: "RPi RF Receiver"
arch:
- aarch64
- amd64
- armhf
- i386
devices:
- /dev/mem:/dev/mem:rw
privileged:
- SYS_RAWIO
gpio: true
Also tried with full_access just to be sure, but that din’t do anything either.
Dockerfile:
ARG BUILD_FROM
FROM $BUILD_FROM
COPY rpi-rf_receive.py /
# Add env
ENV LANG C.UTF-8
RUN apk add --no-cache build-base
RUN apk add --no-cache py-pip
RUN apk add --no-cache python3
RUN apk add --no-cache python3-dev
RUN apk add --no-cache py3-rpigpio
RUN pip install -U pip
RUN pip install -U virtualenv
# Copy data for add-on
COPY run.sh /
RUN chmod a+x /run.sh
CMD [ "/run.sh" ]
I am not sure what RUN apk add --no-cache py3-rpigpio does actually add because I still have to install the package with pip
run.sh:
#!/bin/bash
set -e
cat /etc/os-release
python3 -V
PYTHON=$(which python3)
rm -rf /data/venv/
if [ ! -f "/data/venv/bin/activate" ];
then
mkdir -p /data/venv/
mv rpi-rf_receive.py /data/venv/
cd /data/venv
virtualenv -p ${PYTHON} .
. bin/activate
fi
export CFLAGS=-fcommon
pip install -U RPi.GPIO
python3 rpi-rf_receive.py
I also tried without a virtual env but eventually it all ends up in the same error messages. I added export CFLAGS=-fcommon before installing the RPi.GPIO to fix some other errors. This already seems odd.
The python script itself:
#!/usr/bin/env python3
from RPi import GPIO
It doesn’t do anything yet. Just trying to get the bare minimum to work.
The logs:
[s6-init] making user provided files available at /var/run/s6/etc...exited 0.
[s6-init] ensuring user provided files have correct perms...exited 0.
[fix-attrs.d] applying ownership & permissions fixes...
[fix-attrs.d] done.
[cont-init.d] executing container initialization scripts...
[cont-init.d] done.
[services.d] starting services
[services.d] done.
NAME="Alpine Linux"
ID=alpine
VERSION_ID=3.14.3
PRETTY_NAME="Alpine Linux v3.14"
HOME_URL="https://alpinelinux.org/"
BUG_REPORT_URL="https://bugs.alpinelinux.org/"
Python 3.9.5
created virtual environment CPython3.9.5.final.0-32 in 1923ms
creator CPython3Posix(dest=/data/venv, clear=False, no_vcs_ignore=False, global=False)
seeder FromAppData(download=False, pip=bundle, setuptools=bundle, wheel=bundle, via=copy, app_data_dir=/root/.local/share/virtualenv)
added seed packages: pip==21.3.1, setuptools==60.2.0, wheel==0.37.1
activators BashActivator,CShellActivator,FishActivator,NushellActivator,PowerShellActivator,PythonActivator
Collecting RPi.GPIO
Downloading RPi.GPIO-0.7.0.tar.gz (30 kB)
Preparing metadata (setup.py): started
Preparing metadata (setup.py): finished with status 'done'
Building wheels for collected packages: RPi.GPIO
Building wheel for RPi.GPIO (setup.py): started
Building wheel for RPi.GPIO (setup.py): finished with status 'done'
Created wheel for RPi.GPIO: filename=RPi.GPIO-0.7.0-cp39-cp39-linux_armv7l.whl size=74721 sha256=b16b50d997cd47ebfd4c6e99ccd56fbacf19a137dc2000f45b80064394fae4d1
Stored in directory: /root/.cache/pip/wheels/09/be/52/39b324bfaf72ab9a47e81519994b2be5ddae1e99ddacd7a18e
Successfully built RPi.GPIO
Installing collected packages: RPi.GPIO
Successfully installed RPi.GPIO-0.7.0
Traceback (most recent call last):
File "/data/venv/rpi-rf_receive.py", line 2, in <module>
from RPi import GPIO
File "/data/venv/lib/python3.9/site-packages/RPi/GPIO/__init__.py", line 23, in <module>
from RPi._GPIO import *
RuntimeError: This module can only be run on a Raspberry Pi!
[cmd] /run.sh exited 1
[cont-finish.d] executing container finish scripts...
[cont-finish.d] done.
[s6-finish] waiting for services.
[s6-finish] sending all processes the TERM signal.
I don’t have any other hardware like an Arduino or a spare PI yet so that is why I am trying to get this to work in hassio.
Is there anyone that has RPi.GPIO working in a custom addon with a similar setup?