HDMI CEC integration failure

Hello,

I am facing the below validation error when I set up the HDMI CEC integration.

My configuration.yaml

hdmi_cec:
  devices:
    TV: 0.0.0.0
    Pi: 1.2.0.0
    Shield: 1.1.0.0
    BlueRay: 1.0.0.0
Log Details (ERROR)
Logger: homeassistant.setup
Source: components/hdmi_cec/__init__.py:210
First occurred: 3:21:00 PM (1 occurrences)
Last logged: 3:21:00 PM

Error during setup of component hdmi_cec
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/setup.py", line 193, in _async_setup_component
    result = await asyncio.wait_for(task, SLOW_SETUP_MAX_WAIT)
  File "/usr/local/lib/python3.8/asyncio/tasks.py", line 483, in wait_for
    return fut.result()
  File "/usr/local/lib/python3.8/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/src/homeassistant/homeassistant/components/hdmi_cec/__init__.py", line 210, in setup
    adapter = CecAdapter(name=display_name[:12], activate_source=False)
  File "/usr/local/lib/python3.8/site-packages/pycec/cec.py", line 20, in __init__
    import cec
ModuleNotFoundError: No module named 'cec'

I am running Home Assistant core (not supervised) version 0.113.3 on RPi 3B+ with Python 3.8.0
I found similar errors but those dated back a few years, nothing recent.
Hoping for some pointers.

  1. Try restarting 2 times
  2. If it continues, try running python3.8 -m pip install cec

Thanks @KTibow, but that errors out with:

ERROR: Command errored out with exit status 1:
     command: /usr/local/bin/python3.8 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-phpy0y5v/cec/setup.py'"'"'; __file__='"'"'/tmp/pip-install-phpy0y5v/cec/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-gffwxvu8/install-record.txt --single-version-externally-managed --compile
         cwd: /tmp/pip-install-phpy0y5v/cec/
    Complete output (26 lines):
    running install
    running build
    running build_ext
    building 'cec' extension
    creating build
    creating build/temp.linux-armv7l-3.8
    gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -Iinclude -I/usr/local/include/python3.8 -c cec.cpp -o build/temp.linux-armv7l-3.8/cec.o
    cec.cpp: In function ‘PyObject* can_persist_config(PyObject*, PyObject*)’:
    cec.cpp:615:32: error: ‘class CEC::ICECAdapter’ has no member named ‘CanPersistConfiguration’; did you mean ‘CanSaveConfiguration’?
           RETURN_BOOL(CEC_adapter->CanPersistConfiguration());
                                    ^~~~~~~~~~~~~~~~~~~~~~~
    cec.cpp:121:13: note: in definition of macro ‘RETURN_BOOL’
       result = (arg); \
                 ^~~
    cec.cpp: In function ‘PyObject* persist_config(PyObject*, PyObject*)’:
    cec.cpp:622:26: error: ‘class CEC::ICECAdapter’ has no member named ‘CanPersistConfiguration’; did you mean ‘CanSaveConfiguration’?
           if( ! CEC_adapter->CanPersistConfiguration() ) {
                              ^~~~~~~~~~~~~~~~~~~~~~~
                              CanSaveConfiguration
    cec.cpp:632:32: error: ‘class CEC::ICECAdapter’ has no member named ‘PersistConfiguration’; did you mean ‘SetConfiguration’?
           RETURN_BOOL(CEC_adapter->PersistConfiguration(&config));
                                    ^~~~~~~~~~~~~~~~~~~~
    cec.cpp:121:13: note: in definition of macro ‘RETURN_BOOL’
       result = (arg); \
                 ^~~
    error: command 'gcc' failed with exit status 1
    ----------------------------------------
ERROR: Command errored out with exit status 1: /usr/local/bin/python3.8 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-phpy0y5v/cec/setup.py'"'"'; __file__='"'"'/tmp/pip-install-phpy0y5v/cec/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-gffwxvu8/install-record.txt --single-version-externally-managed --compile Check the logs for full command output.

Hmm. It probably tried to do it automatically and failed. Try creating an issue over at cec's page.

I solved it a different way, following this