HDMI_CEC configuration error

I assume you are able to turn on and off TV through terminal and not through HA? If not, do you see hdmi_cec domain in developer tools?

What does command echo scan | cec-client -s -d 1 return for you in terminal?

Yes command line works fine:

(homeassistant) homeassistant@raspberrypi:~/.homeassistant$ echo scan | cec-client -s -d 1
opening a connection to the CEC adapter...
requesting CEC bus information ...
CEC bus information
===================
device #0: TV
address:       0.0.0.0
active source: no
vendor:        Samsung
osd string:    TV
CEC version:   1.3a
power status:  on
language:      ???


device #1: Recorder 1
address:       1.0.0.0
active source: no
vendor:        Pulse Eight
osd string:    CECTester
CEC version:   1.4
power status:  on
language:      eng


device #4: Playback 1
address:       2.0.0.0
active source: yes
vendor:        Unknown
osd string:    Playback 1
CEC version:   unknown
power status:  on
language:      ???


currently active source: Playback 1 (4)

Yes, the issue I’m facing in the other topic that rpitera linked has to do with limitations due to using Openelec (to my opinion). I haven’t been able to resolve that one yet but if i don’t find an answer soon i’m connecting my HA rpi to a free hdmi slot and that should work as well.
I’d never switch to the HA HDMI channel though, but it should work fine for sending the commands :slight_smile:

Is there a valid sym-link in /path/to/your/venv/lib/python3.4/site-packages/ that points to a version of cec in the system python install?

Sorry, writing from iPad. Formatting and autocorrect are annoying.

I just ran the following and it worked.
homeassistant@pi-smarthome:/srv/homeeassistant/homeassistant_venv/lib/python3.4/site-packages $ ln -s /usr/local/lib/python3.4/site-packages/cec cec

Looks like when I “make install” libcec it placed it in site-packages and not dist-packages

The documentation was off for me.
RPI 2,
latest raspian jessy
Latest libcec (git cloned it)

Link to doc: https://home-assistant.io/components/hdmi_cec/

Link to the libcec guide I used to install:

This ties in with what i’m seeing too. Looks like the HASS docs are wrong/out of date.

created an issue on the hass website github repo here: https://github.com/home-assistant/home-assistant.github.io/issues/1939

and corresponding pull request for the proposed change here: https://github.com/home-assistant/home-assistant.github.io/pull/1940

Once the symlink was corrected, were you able to run it correctly through homeassistant? i’ve my own issue raised over on github as it appears to be erroring out for me on a fresh raspbian image / aio install

@CBRHerms that’s me (matt-cahill) chatting to you on your github issue.

You may need to open a separate issue in the main home-assistant repo for the CEC traceback you are getting.

It looks from your logs that the CEC module is importing properly but the HASS code is making some kind of invalid call. Once the sym-link issue is resolved i think it’s outside the scope of the AiO installer.

Ahhh whoopsie. Aye, i did open a ticket up on there but as i mentioned there was the AIO issue beforehand it was closed as deemed an AIO issue even though it was a call from HA itself. I’ll move any further correspondence to there.

Found the issue with my own setup at least.

hdmi_cec component doesn’t play nicely if you’ve using the new customize feature in your configuration. i’ve added it to my issue report

@CBRHerms glad you found the culprit. The docs have been updated too which is good.

I’ve currently connected my HASS raspberry pi to my tv, installed cec and added it to home assistant… but I’ve had to remove it the same day for 2 reasons:

  • my tv setup (nothing HA can do about it) seems to be an ass when it comes to CEC. i’m using a combo of an hdmi splitter and a hdmi switch to be able to handle my Hyperion ambilight setup from any source. This seems to wreak havoc on CEC commands.
  • After activating CEC, my HA responsiveness dropped. Simply turning on a light took 3 seconds rather than instant as soon as I activate cec… might have something to do with my setup, might not.

Thank you guys!
Changing the symlink helped.

I just installed 0.37.1 aio a few days ago.
Did the libcec installiton as described here https://home-assistant.io/components/hdmi_cec/
Did the update to 0.38.2
Couldn’t get cec to run.
ImportError: No module named ‘cec’

matt-cahill comment at https://github.com/home-assistant/fabric-home-assistant/issues/44
finally helped to understand and to solve it.
Changing the sym link from within the venv fixed the problem.

homeassistant@raspberrypi:/home/pi$ source /srv/homeassistant/homeassistant_venv/bin/activate
ln -sf /usr/local/lib/python3.4/site-packages/cec /srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages
1 Like

Hi,
I’m getting a similar issue with the Raspberry Pi AIO setup, I have the sym link created (within hass virtual env):

sudo ln -s /usr/local/lib/python3.5/dist-packages/cec /srv/homeassistant/homeassistant_venv/lib/python3.5/site-packages/

(note: that the tutorial points to python3.4 and site packages, while 3.5 only has dist-packages)

I get the following error:

2017-09-14 00:28:27 ERROR (MainThread) [homeassistant.setup] Error during setup of component hdmi_cec
Traceback (most recent call last):
File "/srv/homeassistant/homeassistant_venv/lib/python3.5/site-packages/cec/__init__.py", line 18, in 
swig_import_helper
return importlib.import_module(mname)
File "/srv/homeassistant/homeassistant_venv/lib/python3.5/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 986, in _gcd_import
File "<frozen importlib._bootstrap>", line 969, in _find_and_load
File "<frozen importlib._bootstrap>", line 956, in _find_and_load_unlocked
ImportError: No module named '_cec'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/srv/homeassistant/homeassistant_venv/lib/python3.5/site-packages/homeassistant/setup.py", line 194, in 
_async_setup_component
component.setup, hass, processed_config)
File "/usr/lib/python3.5/asyncio/futures.py", line 380, in __iter__
yield self  # This tells Task to wait for completion.
File "/usr/lib/python3.5/asyncio/tasks.py", line 304, in _wakeup
future.result()
File "/usr/lib/python3.5/asyncio/futures.py", line 293, in result
raise self._exception
File "/usr/lib/python3.5/concurrent/futures/thread.py", line 55, in run
result = self.fn(*self.args, **self.kwargs)
File "/srv/homeassistant/homeassistant_venv/lib/python3.5/site-packages/homeassistant/components/hdmi_cec.py", 
line 184, in setup
adapter = CecAdapter(name=display_name[:12], activate_source=False)
File "/srv/homeassistant/homeassistant_venv/lib/python3.5/site-packages/pycec/cec.py", line 20, in __init__
import cec
File "/srv/homeassistant/homeassistant_venv/lib/python3.5/site-packages/cec/__init__.py", line 21, in <module>
_cec = swig_import_helper()
File "/srv/homeassistant/homeassistant_venv/lib/python3.5/site-packages/cec/__init__.py", line 20, in 
swig_import_helper
return importlib.import_module('_cec')
File "/srv/homeassistant/homeassistant_venv/lib/python3.5/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
ImportError: No module named '_cec'


During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/srv/homeassistant/homeassistant_venv/lib/python3.5/site-packages/homeassistant/setup.py", line 194, in 
_async_setup_component
component.setup, hass, processed_config)
File "/usr/lib/python3.5/asyncio/futures.py", line 380, in __iter__
yield self  # This tells Task to wait for completion.
File "/usr/lib/python3.5/asyncio/tasks.py", line 304, in _wakeup
future.result()
File "/usr/lib/python3.5/asyncio/futures.py", line 293, in result
raise self._exception
File "/usr/lib/python3.5/concurrent/futures/thread.py", line 55, in run
result = self.fn(*self.args, **self.kwargs)
File "/srv/homeassistant/homeassistant_venv/lib/python3.5/site-packages/homeassistant/components/hdmi_cec.py", 
line 184, in setup
adapter = CecAdapter(name=display_name[:12], activate_source=False)
File "/srv/homeassistant/homeassistant_venv/lib/python3.5/site-packages/pycec/cec.py", line 20, in __init__
import cec
File "/srv/homeassistant/homeassistant_venv/lib/python3.5/site-packages/cec/__init__.py", line 21, in <module>
_cec = swig_import_helper()
File "/srv/homeassistant/homeassistant_venv/lib/python3.5/site-packages/cec/__init__.py", line 20, in 
swig_import_helper
return importlib.import_module('_cec')
File "/srv/homeassistant/homeassistant_venv/lib/python3.5/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
ImportError: No module named '_cec'

`

any help would be greatly appreciated!

I’m getting this same error did you ever figure out what was wrong? I actually tried this with hassio blew that all away then installed hassbian to see if it worked better. I’m still getting the same error so it looks like it’s broke in both environments.

I didn’t unfortunately, and ended up getting a smartthings hub and have to buy a harmony remote I guess…

After I did all the stuff related to sym-links above and in other threads, and still having no luck, I was curious and searched around in the various folders. I realized that _cec.so wasn’t in the “site-packages” folder but was in the “dist-packages” so I tried copying the file over like so:

sudo cp /usr/local/lib/python3.5/dist-packages/_cec.so /srv/homeassistant/lib/python3.5/site-packages/

IT WORKED!!! Happy boy here!

Don’t know if anyone is still having this problem or if this will work for anyone else, but it did for me and I thought I’d throw my 2 cents into the pot in case it helps anyone.

~Naylin

where can I run the echo scan command on hassio? it doesnt seem to recognize it

nvm… i found the scanner addon for hassio… thanks