all i every time do is googling for the error and see if someone else had it and what packages come up.
in this case i found this page
yeah it goes about installing a different program, but on the page i find 3 different solutions:
install musl-dev or
install libc-dev or
install linux-headers
all would be system packages and i dont know whit which to go
you dont want to run appdaemon as root (sudo)
yeah, the problem with this is that you try to do advanced stuff with a system developed for noob use.
so you runin to all kind of trouble that normally would be easier to repair.
it seems the AD user which is probably the same as the hass user isnt able to read or write to /dev/mem
the whole dev dir is owned by root.
you could try to see if you could find the dir dev/mem and change the access so that the user running AD can access it. or add root access to the user. both solutions probably wont be easy on hassos and you need root access. (which is possible but not easy on default)
i would see if you get any response when you ask this in the hassio section. (maybe other have tried to use gpio also)
that said i googled for homeassistant gpio hassio and i noticed that there is a default component for home assistant.
so you might have travelled the wrong way.
add the gpio to your home assistant and then you can control them with appdaemon as well.
actually, I couldn’t remember the case. Since I got other problems for controlling the relay, I have moved to venv version of the home assistant. I’m using a bottle script as a web service to trigger the relay.
Like a number of others on this forum and elsewhere, I have been trying to use
Appdaemon on a Raspberry pi to read data from GPIO pins and use it in Home Assistant.
But no luck as I keep getting this error:
File “/usr/lib/python3.8/site-packages/rpi_rf/rpi_rf.py”, line 188, in enable_rx
GPIO.setup(self.gpio, GPIO.IN)
RuntimeError: No access to /dev/mem. Try running as root!
Firstly, in my setup (Hass.io 32 bit for Raspberry pi 3b) there is no such directory as
/dev/mem
There is however this one
/sys/class/gpio
and when I enable the Raspberry PI GPIO integration in the configuration.yaml for pin 27
the folder GPIO27 appears in the above directory and events accrue in Home Assistant’s database.
It seems to be a permissions problem for AD apps accessing the GPIO pins of the pi.
So then I wondered what user Appdaemon apps run under and could I elevate that user’s permissions?
According to this little App I wrote it is actually the root user!
But root must have access to the GPIOs musn’t it?
Or is this a red herring?
And isn’t the advice not to run Appdaemon under the root user?
import appdaemon.plugins.hass.hassapi as hass
import os
import pwd
class DetectMotion(hass.Hass):
def initialize(self):
self.log("ok WE GOT THIS FAR now................")
self.listen_now()
def listen_now(self):
self.log(pwd.getpwuid( os.getuid() )[ 0 ])
By the way I do have this in my Appdaemon configuation and all appears to go well according to the
Appdeamon logs.
sorry, but i cant help with permissions on hassio.
i have never used it, and the permissions that the addon (AD docker) has is out of the reach from appdaemon.
not long ago i installed AD on a PI zero.
just a simple pip install, and i have working apps that use gpio
hassio is a very restricted area, to make sure that simple users dont come into trouble. and it also restricts the possibilities from AD.
so i see 2 ways to go:
forget about hassio, or install hassio on another device then the PI that wants to use GPIO
get in touch with frenck, and see if he can tell you how to get the needed permissions.
dont forget: AD is independant. it doesnt need to be on the same device that you run home assistant on. so its possible to have hassio on 1 PI and AD on another PI.
Thanks, all good advice. Will try contacting frenk first then, if no luck, your other suggestions. I’m a bit of a noob here so could you point me to some webpage that explains alternative suitable ways to install Home Assistant and AD on the same raspberry Pi?
I got in touch with frenck. You might be interested to read his reply. If I understand it correctly, it is not a permissions problem but instead a bug in Appdaemon.
its a bug in the addon.
and the addon has nothing to do with appdaemon.
the addon is a small piece of code written by frenck that makes it possible to run appdaemon on hassio.
thats why frenck says that he will correct it, while he cant correct anything in appdaemon, because frenck is no dev from appdaemon.
thats also why it can be used when you install AD stand alone, and get in trouble with hassio.
its like i suspected the bug in the addon makes that AD cant reach the pins.
Ok, I have followed your six steps and all seems to be working fine now. I am able to access the GPIO pins without any difficulty from an app I wrote running under AD.
Would you mind if I asked another question?
I want to switch HomeAssistant from using its default SQlite to MySQL (or Maria). Should this database be set up in the HA venv or AD venv or its own? I wish to write more AppDaemon apps that will process received 433mhz signals on the RPI GPIO pin (27) and insert a subset of these into the states (etc) tables directly of HA.
I hope this makes sense!
this question is not really related to this topic, it would have been better to call me in new topic or to come to our discord server.
but when i respond anyway ill give you an answer.
is mySQL or mariaDB a python program??
i dont think so, so its not setup in any venv, because you use python venv for AD and HA
apps that respond to a GPIO pin make sense, but you dont want to input GPIO data directly into the HA DB!!!
the only one that puts data into the DB should be HA.
the way you would need to handle it is to write apps, that give commands to HA, and HA then writes it into the DB.
if you try to write to the HA states table directly, then HA doesnt see that. so that info goes completely unknown.
if you want that just to save data, then you can, but i would advise to use a different DB for that.
if this answers your questions enough then great. if not, please PM me or come to the AD discord server: https://discord.gg/pHsjADY
Thanks. I think I see where to go next. Maybe something like the command line sensor… The reason why I’m following this approach is that HA, though it has the GPIO switch platform, doesn’t seem capable of reading varying data arriving via a GPIO pin then filtering and dealing with it. As in this page:
But my variation on the rpi-rf receive script rpi-rf_receive will be able to do this (sorting out the wanted sniffed codes from the noise arriving from the hundreds of nearby 433Mhz sensors in my neighbourhood). The idea is to put only those signals coming from a list (a sort of list of “paired sensors”) into HA. I will continue this discussion soon on Discord once I have thought it over. Thanks again.
I know this is an old thread, but I wanted to share my solution because it took forever to figure out.
I am running HA and AppDaemon in Docker containers and attempting to use RPi.GPIO through the Adafruit Neopixel library. The solution to No access to /dev/mem (at least for my case) was to allow access to the gpiomem and spidev0.0 devices from the docker container. So docker run --name=appdaemon <other arguments> --device /dev/gpiomem --device /dev/spidev0.0 when initializing the container. I don’t have enough knowledge to comment on the device security risks of this, so that’s worth looking into.