Hdmi cec issue

Hi all, after last update of home assistant (hassbian) 0.63.3 I’ve some issue with hdmi cec.
In my configuration I’ve

hdmi_cec:
  devices:
    TV: 0.0.0.0
    Pi: 1.0.0.0

this is the result of echo scan | cec-client -s -d 1

pi@hassbian:~ $ 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:        Panasonic
osd string:    TV
CEC version:   unknown
power status:  standby
language:      ???


device #4: Playback 1
address:       1.0.0.0
active source: no
vendor:        Panasonic
osd string:    CECTester
CEC version:   1.4
power status:  on
language:      eng

Home assistant correctly show me a TV switch (switch.hdmi_0).
Before the update I could turn the tv on and of using the switch but now when I use the switch to turn on the tv, it turn back off after a second and the TV never goes on.
If I turn on the Tv with its remote the switch in home assistant turn on after 15-20 seconds. Same thing when I turn it off.

In my log I’ve found this:

Error doing job: Task exception was never retrieved
00:07 helpers/entity_platform.py (ERROR)
Not initialized. Waiting for init.
00:07 /srv/homeassistant/lib/python3.5/site-packages/pycec/network.py (WARNING)
Not initialized. Waiting for init.
00:07 /srv/homeassistant/lib/python3.5/site-packages/pycec/network.py (WARNING)

and clicking on the first error:

Log Details (ERROR)
Mon Feb 26 2018 00:07:06 GMT+0100 (CET)

Error doing job: Task exception was never retrieved
Traceback (most recent call last):
File “/usr/lib/python3.5/asyncio/tasks.py”, line 239, in _step
result = coro.send(None)
File “/srv/homeassistant/lib/python3.5/site-packages/homeassistant/helpers/entity_platform.py”, line 252, in _async_add_entity
msg)
homeassistant.exceptions.HomeAssistantError: Entity id already exists: switch.hdmi_0

Following other discussion on the forum I’ve:

  • erased the content of entity_registry.yaml
  • commented out the customize section
  • changed from direct mapping to port mapping in the hdmi configuration

bur nothing has worked.

Any suggestion will be really appreciated.
Thank you.

Last update to 0.64.1 didn’t solve my issue.
I think it’s something related to the new way of managing entities id, but the entity switch.hdmi_0 is automatically created so I really don’t know what should I do.

Hey there, i have the same issue so maybe it is caused by home-assistant and not by the config. If somebody solved the problem, please tell us.

I am using hass.io with the HDMI-CEC Add-on from the repositories.

Guess you never found a fix for this? I have the same issue
Just upgraded to 65.4 and it’s still the same
Running Hassbian

nevermind

same issue here, running hass.io

is it solved?

Same problem, also with a Panasonic TV.

Actually, I’ve got a Panasonic TV, a Sony Receiver and a Amz Fire TV. They all apear as switches, the somehow read the state of the device (if, using the remote I turn on and off the TV or the Receiver, it shows on my homeassistant) but it doesn’t obey when I change it on my HA.

any fix yet?

I’m trying to enable HDMI CEC on my Rasperry Pi 3b+ running Hassbian, no luck.
Is this not working or am I doing it wrong?

Error during setup of component hdmi_cec
Traceback (most recent call last):
  File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/setup.py", line 148, in _async_setup_component
    component.setup, hass, processed_config)  # type: ignore
  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/lib/python3.5/site-packages/homeassistant/components/hdmi_cec.py", line 182, in setup
    adapter = CecAdapter(name=display_name[:12], activate_source=False)
  File "/srv/homeassistant/lib/python3.5/site-packages/pycec/cec.py", line 20, in __init__
    import cec
ImportError: No module named 'cec'

I just reinstalled hassbian and installed libcec. I can see connected HDMI Devices via SSH and i am also able to control them (switch them on and off) but the HA component does not load and i get the exact error as forschi.

Can anybody help?

I found a workaround on reddit.

I created a command-line switch which works totally fine for me:

switches:
  - platform: command_line
  switches:
    tv:
      command_on: "echo 'on 0' | cec-client -s"
      command_off: "echo 'standby 0' | cec-client -s"
      command_state: "echo 'pow 0' | cec-client -s |grep 'power status:'"
      value_template: '{{ value == "power status: on" }}'

somehow only small characters are allowed as name so i created a friendlyname in customization.yaml

I hope this will help somebody.

Nice workaround!
Does it work flawless for you?
I often have to use the switch two times especially when turning off.

There is a short delay by using the switch and turning the TV on/off of about 2 seconds. But the service is very reliable.
If I use the normal remote the delay is about 2-3 seconds. I hope this will help you

Thanks for this. Using the CEC services through Home Assistant never worked for me, but this does. Now I need to figure out the commands to change TV inputs.

Just what I need, I only need to be able to turn my TV on/off, ther rest is handled in the amp since it can be controlled by homeassistant via IP.

you put the codes in configuration.yaml?
because i tried your code in my configuration.yaml and it wouldnt load the web gui. thats how i know the syntax is wrong. please help

This works great but totally disables Kodi control with my remote from projector. Any solution here please?

The solution to the CEC not initialising is that it the Pi must be directly connected to a TV on boot for it to work.

I’m now looking for a solution that overcomes this, making the HDMI port work even if no communication with the TV on boot.