I am merging my home automation setup from Domoticz to Home Assistant, so I am still new to it. I recently used the Hassbian image to setup Home Assistant.
One of the steps is to get my relay board to work, using the pylibftdi library.
However, when I run my old python script it yields an error. The following python test-script, also returns an error.
import sys, pylibftdi as ftdi
print(ftdi.Driver().list_devices())
The error is:
Traceback (most recent call last):
File “./testftdi.py”, line 32, in
print(ftdi.Driver().list_devices())
File “/home/pi/.local/lib/python2.7/site-packages/pylibftdi/driver.py”, line 240, in list_devices
raise FtdiError(msg)
pylibftdi._base.FtdiError: libusb_open() failed (-4)
I cannot get it to work. Does anyone have an idea why this error could be thrown? Is there something in the Hassbian image that would prevent this Python library to malfunction?
pi@hassbian:/home/homeassistant $ python -m pylibftdi.examples.info
pylibftdi version : 0.17.0
libftdi version : libftdi_version(major=1, minor=4, micro=0, version_str='1.4', snapshot_str='unknown')
libftdi library name : libftdi1.so.2
libusb version : libusb_version(major=1, minor=0, micro=22, nano=11312, rc='', describe='http://libusb.info')
libusb library name : libusb-1.0.so.0
Python version : 2.7.16
OS platform : Linux-4.14.98-v7+-armv7l-with-debian-buster-sid
I can’t get list_devices to work, however I just managed to fix the bitbang part which sends commands to the relayboard. That’s enough to get everything working! \o/
I think your problem is that you need to run as root or sudo. There are ways around this, but you should try to run your python script via sudo, and to see if this works.