I tried to make an add-on to run that script and it looks like it’s working… at least at the end it says it’s listening on the pin 27.
Make a directory in the add-on share and call it “rpi-rf_receiver” and copy the 3 files:
- Dockerfile
- config.json
- run.sh
You can find here: https://drive.google.com/folderview?id=1XiXGIPcWoF5gRuos1HLoR_1-tQ7hzFOE
ARG BUILD_FROM
FROM $BUILD_FROM
ENV LANG C.UTF-8
RUN apk add --no-cache jq
RUN apk add --no-cache py2-pip
RUN apk add --no-cache clang
RUN apk add --no-cache libgcc
RUN apk add --no-cache gcc-gnat
RUN apk add --no-cache libgc++
RUN apk add --no-cache g++
RUN apk add --no-cache make
RUN apk add --no-cache libffi-dev
RUN apk add --no-cache openssl-dev
RUN apk add --no-cache python2-dev
RUN apk add --no-cache mosquitto
RUN apk add --no-cache mosquitto-dev
RUN apk add --no-cache mosquitto-clients
RUN apk add --no-cache mosquitto-libs
RUN pip install pyaes
RUN pip install pycrypto
RUN apk add --no-cache \
jq \
py-pip \
python \
python-dev \
python3 \
python3-dev\
&& pip install -U pip \
&& pip3 install -U pip \
&& pip install -U virtualenv
COPY run.sh /
RUN chmod a+x /run.sh
CMD [ "/run.sh" ]
{
"name": "RPi RF Receiver",
"version": "1.0",
"slug": "rfreceiver",
"description": "RPi RF Receiver Script",
"startup": "application",
"boot": "auto",
"devices": ["/dev/mem:/dev/mem:rw"],
"privileged": ["SYS_RAWIO"],
"gpio": "true",
"ports": {"5055/tcp": null},
"options": {
"code": "/share/rpi-rf_receive.py",
"requirements": [
"rpi-rf"
],
"clean": true
},
"schema": {"code": "str",
"requirements": ["str"],
"clean": "bool?"},
"map": ["share"]
}
#!/bin/bash
set -e
requirements=$(cat /data/options.json | jq -r 'if .requirements then .requirements | join(" ") else "" end')
code=$(cat /data/options.json | jq -r '.code')
clean=$(cat /data/options.json | jq -r '.clean //empty')
py2=$(cat /data/options.json | jq -r '.python2 // empty')
PYTHON=$(which python3)
if [ "${py2}" == "true" ];
then
PYTHON=$(which python2)
fi
if [ -n "$requirements" ];
then
if [ "$clean" == "true" ];
then
rm -rf /data/venv/
fi
if [ ! -f "/data/venv/bin/activate" ];
then
mkdir -p /data/venv/
cd /data/venv
virtualenv -p ${PYTHON} .
. bin/activate
fi
pip install -U ${requirements}
fi
python ${code}
If I’m not wrong you should make the run.sh executable going inside the directory /addon/rpi-rf_receiver and using the command “chmod +x run.sh”.
Then copy rpi-rf_receive.py in the “share” share of your hassio.
Now, install the add-on going inside the Hass.io add-on section and refreshing the list. After installing it, in the option section you should see this:
{
"code": "/share/rpi-rf_receive.py",
"requirements": [
"rpi-rf",
"clean": true
]
}
Now start the add-on and refreshing the logs this is what you should see:
starting version 3.2.2
Running virtualenv with interpreter /usr/bin/python3
Using base prefix '/usr'
New python executable in /data/venv/bin/python3
Also creating executable in /data/venv/bin/python
Installing setuptools, pip, wheel...done.
Collecting rpi-rf
Downloading rpi-rf-0.9.6.tar.gz
Collecting RPi.GPIO (from rpi-rf)
Downloading RPi.GPIO-0.6.3.tar.gz
Building wheels for collected packages: rpi-rf, RPi.GPIO
Running setup.py bdist_wheel for rpi-rf: started
Running setup.py bdist_wheel for rpi-rf: finished with status 'done'
Stored in directory: /root/.cache/pip/wheels/16/e2/54/205bfe1826862c70b36a59d02c340d06726cdbd82f5b88dfdb
Running setup.py bdist_wheel for RPi.GPIO: started
Running setup.py bdist_wheel for RPi.GPIO: finished with status 'done'
Stored in directory: /root/.cache/pip/wheels/ae/4d/3b/e924997dbf06810adf3b2e37f1d9627b2327eb9cbb285949c9
Successfully built rpi-rf RPi.GPIO
Installing collected packages: RPi.GPIO, rpi-rf
Successfully installed RPi.GPIO-0.6.3 rpi-rf-0.9.6
2017-11-08 19:43:08 - [INFO] rpi-rf_receive: Listening for codes on GPIO 27
I’m not really a coder, so I made it just copying and pasting other projects, let me know if it works guys