Ubuntu gpio home assistant

I am having trouble with HA, I have a raspberry pi 4 that runs Ubuntu 20.04 LTS using snap to run the HA server. I am very new to home assistant, I am hoping that there is a better way to run it other than virtually. Wit that being said I am trying to figure out a way, so that I can read the state of gpio pin to trigger a script to run. I know that I can install a mqtt broker server and use node red to send the change to home assistant, but is there a better way, where I don’t have to rely on a mqtt server?

There is this, that being said some people have reliability issues with this integration (missing changes in gpio state), it works fine for me ATM, YMMV:

Are you doing anything on the RPi that you need to be running Ubuntu? You can’t quite do everything you would on Ubuntu, but you can still do quite a bit. The only limitations I ran into in running my own docker containers outside of the officially supported HA was was some hardware passthrough limitations (BT), aside from that I have been able to run HAOS with no reprecussions.

Home Assistant OS is probably your best bet starting out here. Then you can access this.

I don’t think it will work for the HA gpio integration, but if you need to be on Ubuntu you probably want to be on 21.xx branch on RPi4, quite a few improvements over the LTS branch for ARM and the Pi, both from the newer kernels (5.13 now) and Ubuntu updates.

Does this work with Ubuntu? I was under the impression it required Rpi.Gpio which Ubuntu doesn’t use on 21.xx, it uses LGPIO. 20.xx doesn’t have GPIO access on the rpi

I understand he is on 20.04, not 21.xx, so RPi.GPIO and wiringpi should work AFIK. From some reading there seems to be an issue with 20.04, but some sources say it works. I don’t remember which Ubuntu I was on when I ran this, but I can’t test it now. Note from my experience the biggest issue with making this work is the GPIO access is from the kernel level and needs root access to /dev/gpiomem. So any group using the gpio needs to be root, or commands run as sudo, which in Raspian the user Pi is. There are some concerns security wise in doing that, depending on your set-up. There is an explanation buried in here: raspberry-gpio-python / Tickets / #171 "Not running on a RPi" message from GPIO.setup(id, GPIO.IN) on new RPi4B

I run a tp-link omada controller(does not work on ubuntu 21, I tried), samba, node red, plex server(just for fun). I run the omada controller as a 24/7 controller to monitor my access points and switches, also for management of omada devices. I tried wiring pi, I was wondering if I should change my config file to something like this

binary_sensor:
  - platform: rpi_gpio
    ports:
      11: PIR Office
      12: PIR Bedroom

When I do this I get an error in the log saying that the configuration did not work because a file coul not be found. This is the pi4 model B 8gb ram. @Kdem @zimmra

what is AFIK?

but now I get an error
The system cannot restart because the configuration is not valid: Platform error binary_sensor.rpi_gpio - Requirements for rpi_gpio not found: ['RPi.GPIO==0.7.1a4'].

and this

Logger: homeassistant.util.package
Source: util/package.py:99
First occurred: 5:35:31 PM (1 occurrences)
Last logged: 5:35:31 PM

Unable to install package RPi.GPIO==0.7.1a4: ERROR: Command errored out with exit status 1: command: /snap/home-assistant-snap/424/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-wralblbx/rpi-gpio/setup.py'"'"'; __file__='"'"'/tmp/pip-install-wralblbx/rpi-gpio/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d /tmp/pip-wheel-1co2lems cwd: /tmp/pip-install-wralblbx/rpi-gpio/ Complete output (16 lines): running bdist_wheel running build running build_py creating build creating build/lib.linux-aarch64-3.8 creating build/lib.linux-aarch64-3.8/RPi copying RPi/__init__.py -> build/lib.linux-aarch64-3.8/RPi creating build/lib.linux-aarch64-3.8/RPi/GPIO copying RPi/GPIO/__init__.py -> build/lib.linux-aarch64-3.8/RPi/GPIO running build_ext building 'RPi._GPIO' extension creating build/temp.linux-aarch64-3.8 creating build/temp.linux-aarch64-3.8/source aarch64-linux-gnu-gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -g -fwrapv -O2 -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -I/snap/home-assistant-snap/424/include -I/usr/include/python3.8 -c source/py_gpio.c -o build/temp.linux-aarch64-3.8/source/py_gpio.o unable to execute 'aarch64-linux-gnu-gcc': No such file or directory error: command 'aarch64-linux-gnu-gcc' failed with exit status 1 ---------------------------------------- ERROR: Failed building wheel for RPi.GPIO ERROR: Command errored out with exit status 1: command: /snap/home-assistant-snap/424/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-wralblbx/rpi-gpio/setup.py'"'"'; __file__='"'"'/tmp/pip-install-wralblbx/rpi-gpio/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-oxloeq4o/install-record.txt --single-version-externally-managed --user --prefix= --compile --install-headers include/site/python3.8/RPi.GPIO cwd: /tmp/pip-install-wralblbx/rpi-gpio/ Complete output (16 lines): running install running build running build_py creating build creating build/lib.linux-aarch64-3.8 creating build/lib.linux-aarch64-3.8/RPi copying RPi/__init__.py -> build/lib.linux-aarch64-3.8/RPi creating build/lib.linux-aarch64-3.8/RPi/GPIO copying RPi/GPIO/__init__.py -> build/lib.linux-aarch64-3.8/RPi/GPIO running build_ext building 'RPi._GPIO' extension creating build/temp.linux-aarch64-3.8 creating build/temp.linux-aarch64-3.8/source aarch64-linux-gnu-gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -g -fwrapv -O2 -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -I/snap/home-assistant-snap/424/include -I/usr/include/python3.8 -c source/py_gpio.c -o build/temp.linux-aarch64-3.8/source/py_gpio.o unable to execute 'aarch64-linux-gnu-gcc': No such file or directory error: command 'aarch64-linux-gnu-gcc' failed with exit status 1 ---------------------------------------- ERROR: Command errored out with exit status 1: /snap/home-assistant-snap/424/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-wralblbx/rpi-gpio/setup.py'"'"'; __file__='"'"'/tmp/pip-install-wralblbx/rpi-gpio/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-oxloeq4o/install-record.txt --single-version-externally-managed --user --prefix= --compile --install-headers include/site/python3.8/RPi.GPIO Check the logs for full command output. WARNING: You are using pip version 20.2.4; however, version 21.3.1 is available. You should consider upgrading via the '/snap/home-assistant-snap/424/bin/python3 -m pip install --upgrade pip' command.

As far as I know

Do you have gcc installed in the environment? It seems like that’s where it failed, but it may have to do with the snap. I doubt the warnings about the pip version matter, but out of my depth there, sorry, hopefully someone with more knowledge will jump in.