Can't get HDMI-CEC to work in Docker

This is pretty much the same issue as Docker: Error during setup of component hdmi_cec, which was never addressed and is still an issue 5 years later from the looks of it

hdmi_cec:
  platform: media_player
  devices:
    TV: 0.0.0.0
    Fire TV Stick: 1.0.0.0
    Games Consoles: 2.0.0.0
    Media Server: 3.0.0.0
    VHS / DVD: 4.0.0.0
    Laserdisc: 5.0.0.0
  types:
    hdmi_cec.hdmi_1: media_player

And i get the folowing Error

Logger: homeassistant.setup
Source: components/hdmi_cec/__init__.py:206
First occurred: 4:02:13 AM (1 occurrences)
Last logged: 4:02:13 AM
Error during setup of component hdmi_cec

Traceback (most recent call last):
  File "/lsiopy/lib/python3.11/site-packages/homeassistant/setup.py", line 286, in _async_setup_component
    result = await task
             ^^^^^^^^^^
  File "/usr/lib/python3.11/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/lsiopy/lib/python3.11/site-packages/homeassistant/components/hdmi_cec/__init__.py", line 206, in setup
    adapter = CecAdapter(name=display_name[:12], activate_source=False)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/lsiopy/lib/python3.11/site-packages/pycec/cec.py", line 20, in __init__
    import cec
ModuleNotFoundError: No module named 'cec'

Iā€™m sure this is not in the pristine HA docker image. Any explanations?

1 Like

Ah yes, I forgot to mention I use the linuxserver.io image which increases security, it basically pulls down the official one and applies some environmental updates to the user and such so it doesnt run as root.