Hello forum!
I require some assistance with a problem I have been battling with for a few days now with no success.
In short I am trying to control my PiFace Digital II board from within HASS running on the latest version of DietPi.
First of all, I have previously installed the PiFace and Home Assistant on HASSBIAN and it worked like a charm (after changing SPI speed) so I have had this working before. I wanted to try DietPi out and I have installed Home Assistant (#157) and it is working. I have installed both the pifacecommon and pifacedigitalio requirements for PiFace and I am able to control the PiFace board (simple python scripts) outside of the Home Assistant environment (pyenv) but it does not work within it.
Last night I had an inspiration based on the description for Home Assistant “Customise Python environment:”.
If you need to install additional Python modules into this pyenv environment, update Python itself or similar, you need to open a shell as user homeassistant and activate the pyenv environment:
sudo -u homeassistant bash
. /home/homeassistant/pyenv-activate.sh
pip3 install # Or whichever install/update you need to do
I followed the procedure indicated above but when I tried
pip3 install pifacecommon
pip3 install pifacedigitalio
it returned the following
We trust you have received the usual lecture from the local System
Administrator. It usually boils down to these three things:
#1) Respect the privacy of others.
#2) Think before you type.
#3) With great power comes great responsibility.
[sudo] password for homeassistant:
Unfortunately I do not have the password for the user homeassistant as I did not create it. Note that if anyone knows the password then please let me (and others) know as that is necessary to install other python modules into pyenv?
So I just finished adding the user homeassistant into the sudo group to try and get around the issue with the password and was able to install the pifacecommon and pifacedigitalio libraries but unfortunately still, I am not able to talk to the PiFace from within HASS.
Here is a test I just ran and I think it is the same error I am getting from within HASS. Almost as if the SPI is not enabled but outside of HASS (pyenv) it works so the SPI must be enabled. Any help would be greatly appreciated and thank you in advance.
homeassistant@DietPi:/root$ . /home/homeassistant/pyenv-activate.sh
homeassistant@DietPi:~$ pip3 install pifacecommon
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
Requirement already satisfied: pifacecommon in ./.pyenv/versions/3.8.0/lib/python3.8/site-packages (4.2.2)
homeassistant@DietPi:~$ pip3 install pifacedigitalio
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
Requirement already satisfied: pifacedigitalio in ./.pyenv/versions/3.8.0/lib/python3.8/site-packages (3.0.5)
homeassistant@DietPi:~$ python3
Python 3.8.0 (default, Jan 7 2020, 18:53:06)
[GCC 8.3.0] on linux
Type “help”, “copyright”, “credits” or “license” for more information.
import pifacedigitalio
pifacedigital = pifacedigitalio.PiFaceDigital()
Traceback (most recent call last):
File “/home/homeassistant/.pyenv/versions/3.8.0/lib/python3.8/site-packages/pifacecommon/spi.py”, line 41, in open_fd
self.fd = posix.open(spi_device, posix.O_RDWR)
PermissionError: [Errno 13] Permission denied: ‘/dev/spidev0.0’
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File “”, line 1, in
File “/home/homeassistant/.pyenv/versions/3.8.0/lib/python3.8/site-packages/pifacedigitalio/core.py”, line 53, in init
super(PiFaceDigital, self).init(hardware_addr, bus, chip_select)
File “/home/homeassistant/.pyenv/versions/3.8.0/lib/python3.8/site-packages/pifacecommon/mcp23s17.py”, line 91, in init
super(MCP23S17, self).init(bus, chip_select, speed_hz=speed_hz)
File “/home/homeassistant/.pyenv/versions/3.8.0/lib/python3.8/site-packages/pifacecommon/spi.py”, line 33, in init
self.open_fd(spi_device)
File “/home/homeassistant/.pyenv/versions/3.8.0/lib/python3.8/site-packages/pifacecommon/spi.py”, line 43, in open_fd
raise SPIInitError(
pifacecommon.spi.SPIInitError: I can’t see /dev/spidev0.0. Have you enabled the SPI module? (http://piface.github.io/pifacecommon/installation.html#enable-the-spi-module)
011920: Added - config.txt file located in DietPi folder
#-------I²C-------------
dtparam=i2c_arm=on
dtparam=i2c1=on
#-------SPI-------------
#dtparam=spi=off
dtparam=spi=on
#-------Serial/UART-----
NB: Enabled for 1st run only, if you want to keep this setting, please set CONFIG_SERIAL_CONSOLE_ENABLE=1 in /DietPi/dietpi.txt.
#core_freq=400
enable_uart=1