Hi
I’m new to home assistant and I have a problem.
I followed this tutorial: https://www.youtube.com/watch?v=tCGlQSsQ-Mc on a raspberry pi 3 model b
but when I add a hdmi_cec component to my config I get this error:
17-04-20 00:42:17 ERROR (MainThread) [homeassistant.setup] Error during setup of component hdmi_cec
Traceback (most recent call last):
File "/srv/homeassistant/lib/python3.4/site-packages/homeassistant/setup.py", line 192, in _async_setup_component
None, component.setup, hass, processed_config)
File "/usr/lib/python3.4/asyncio/futures.py", line 388, in __iter__
yield self # This tells Task to wait for completion.
File "/usr/lib/python3.4/asyncio/tasks.py", line 286, in _wakeup
value = future.result()
File "/usr/lib/python3.4/asyncio/futures.py", line 277, in result
raise self._exception
File "/usr/lib/python3.4/concurrent/futures/thread.py", line 54, in run
result = self.fn(*self.args, **self.kwargs)
File "/srv/homeassistant/lib/python3.4/site-packages/homeassistant/components/hdmi_cec.py", line 186, in setup
adapter = CecAdapter(name=display_name, activate_source=False)
File "/home/homeassistant/.homeassistant/deps/pycec/cec.py", line 20, in __init__
import cec
ImportError: No module named 'cec'
The test command works: echo scan | cec-client -s -d 1
opening a connection to the CEC adapter...
requesting CEC bus information ...
CEC bus information
===================
device #1: Recorder 1
address: 1.4.0.0
active source: no
vendor: Pulse Eight
osd string: CECTester
CEC version: 1.4
power status: on
language: eng
device #5: Audio
address: 1.0.0.0
active source: no
vendor: Onkyo
osd string: TX-SR444
CEC version: 1.4
power status: on
language: ???
currently active source: unknown (-1)
I’m not running HA in virtual environment myself, in case that would matter (in case someone else struggling the same as I did), anyway I simply followed everything in the order you gave, and everything started to work perfectly! The only exception was that I didn’t add HA as root (ie I ignored the very first step).
Ran into that issue while trying to setup devcontainers (Docker) for Home Assistant with CEC support. The pyCec library doesn’t pull libcec (which isn’t even on Pypi), and you need to build it yourself.
Most importantly, though, you need to have SWIG installed, otherwise CMake will just silently forget to compile the Python bindings (cec.py and _cec.so) for you
sudo apt-get install swig
git clone --recursive https://github.com/Pulse-Eight/libcec.git \
&& mkdir libcec/build \
&& mkdir libcec/src/platform/build
cd libcec/src/platform/build
cmake ..
make -j$(nproc)
sudo make install
cd libcec/build
cmake .. -DHAVE_PYTHON=1 -DHAVE_LINUX_API=1
make -j$(nproc)
sudo make install
Then you need to copy or link cec.py and _cec.so to Home Assistant’s venv.