Addon to run Python Script that imports the RPi.GPIO component

All,

I’ve been working with creating an addon that will run a python script but I keep running into problems with executing the RPi-GPIO. I’m on Hass.io, running version 0.63.3 on a Raspberry Pi 3.
Key needs in that script are

  • I need to import RPi.GPIO to control the Raspberry Pi 3 GPIO pins
  • I need to import paho.mqtt so i can pub/sub in the script

Together with @DrZzs, we are hosting a booth at our local Maker Fair, where we will be showing off Home Assistant and things of home automation. I am going to make a mini demo version of a Garage Door Cover, using LEGOs. So to control, i will have a DC motor that i can use software PWM to control the motor. My end goal is the use the MQTT Cover, so that when I publish an OPEN, the script will run to drive the motor to open.

I first looked into just using the rpi-gpio component, but need the PWM. So I looked at the rpi_gpio_pwm component, and that isn’t working for some reason in Hass.io. I can get my addon to work, if i do a very simple example where the python script runs and just prints “hello world”. But when I try to add RPi.GPIO i get problems when the script runs and tries to import RPi.GPIO as GPIO.

I have my addon and simple script on github so I don’t have to post here - https://github.com/IROTRAS/hassio-addon-LEGO-garage-demo

Can anyone give me some pointers or tips? I really think there is just something specific for the GPIO component that I’m missing, or it’s just not supported.

3 Likes

I have a similar problem

I am trying to achieve the same goal here too. I need to run a python script with RPi-GPIO imports.

Did you mange to get this working?

I recommend you get on the Hassio Discord channel and seek advice from one of the core devs on Hassio