Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HDMI Cec not working #15406

Closed
nitobuendia opened this issue Jul 10, 2018 · 22 comments
Closed

HDMI Cec not working #15406

nitobuendia opened this issue Jul 10, 2018 · 22 comments

Comments

@nitobuendia
Copy link

Home Assistant release with the issue:
0.73.1

Last working Home Assistant release (if known):
Not known or never workign.

Operating environment (Hass.io/Docker/Windows/etc.):
Hass.io 0.73.1 on Raspberry Pi

Component/platform:
hdmi_cec

Description of problem:
Hass.io does not seem to detect any HDMI devices.
Services like hdmi_cec.power_on are added to services in Hass.io. Calling them will have no effect.

HDMI Set up:
Raspberry Pi (Hass.io) connected to HDMI port2 of TV.

Kinivo device connected to HDMI port1 of TV. This provides 5 ports. Port 1 is occupied by Chromecast TV and port 2 by PS4.

Both Chromecast (+Assistant) and PS4 are able to use HDMI Cec to switch on and off the TV.

Problem-relevant configuration.yaml entries and (fill out even if it seems unimportant):

hdmi_cec: !include devices/hdmi_cec.yaml

devices/hdmi_cec.yaml

platform: media_player

Also tried, devices/hdmi_cec.yaml

devices:
  1:
    1: Chromecast
    2: PS4
    3: Slot 3
    4: Slot 4
    5: Slot 5
  2: Hassio TV

Traceback (if applicable):

2018-07-10 21:48:02 WARNING (ThreadPoolExecutor-1_0) [pycec] Not initialized. Waiting for init.
2018-07-10 21:48:03 WARNING (ThreadPoolExecutor-1_0) [pycec] Not initialized. Waiting for init.
2018-07-10 21:48:04 WARNING (ThreadPoolExecutor-1_0) [pycec] Not initialized. Waiting for init.
2018-07-10 21:48:05 WARNING (ThreadPoolExecutor-1_0) [pycec] Not initialized. Waiting for init.
2018-07-10 21:48:06 WARNING (ThreadPoolExecutor-1_0) [pycec] Not initialized. Waiting for init.
2018-07-10 21:48:07 WARNING (ThreadPoolExecutor-1_0) [pycec] Not initialized. Waiting for init.
2018-07-10 21:48:08 WARNING (ThreadPoolExecutor-1_0) [pycec] Not initialized. Waiting for init.
2018-07-10 21:48:09 WARNING (ThreadPoolExecutor-1_0) [pycec] Not initialized. Waiting for init.
2018-07-10 21:48:10 WARNING (ThreadPoolExecutor-1_0) [pycec] Not initialized. Waiting for init.
2018-07-10 21:48:11 WARNING (ThreadPoolExecutor-1_0) [pycec] Not initialized. Waiting for init.
2018-07-10 21:48:12 WARNING (ThreadPoolExecutor-1_0) [pycec] Not initialized. Waiting for init.

(and many more like this one...)

@pvizeli
Copy link
Member

pvizeli commented Jul 11, 2018

64bit ?

@nitobuendia
Copy link
Author

@pvizeli Thanks for your message. Could you kindly elaborate? Not sure what you mean by that.

@pvizeli
Copy link
Member

pvizeli commented Jul 12, 2018

What kind of host system do you use? ResinOS/HassOS/raspbian ?

@nitobuendia
Copy link
Author

Hass.io which I understand should be HassOs?

As per hdmi_cec component:

If you are using Hass.io then just move forward to the configuration as all requirements are already fulfilled.

@KristianAndersson
Copy link

I'm experiencing issues with hdmi_cec component as well. It doesn't detect the hdmi devices connected.

Made a clean install with the 0.73.1 Hass.io image based on HassOS (64bit) on a new Raspberry PI 3B+, and copied my configuration from my previous instalment.

I'm getting the Not initialized. Waiting for init. warning every second.

I have tried to set the log level to debug and pulled out these logs:

2018-07-14 19:56:24 INFO (SyncWorker_5) [pycec] HDMI network starting...
2018-07-14 19:56:24 DEBUG (ThreadPoolExecutor-1_0) [pycec] initializing
2018-07-14 19:56:24 DEBUG (ThreadPoolExecutor-1_0) [pycec] setting callback
2018-07-14 19:56:24 DEBUG (ThreadPoolExecutor-1_0) [pycec] Callback set
2018-07-14 19:56:24 DEBUG (ThreadPoolExecutor-0_0) [pycec.cec] Initializing CEC...
2018-07-14 19:56:24 DEBUG (ThreadPoolExecutor-1_0) [pycec] Init pending - <Future pending cb=[_chain_future.<locals>._call_check_cancel() at /usr/lib/python3.6/asyncio/futures.py:408]>
2018-07-14 19:56:24 DEBUG (ThreadPoolExecutor-0_0) [pycec.cec] Created adapter
2018-07-14 19:56:24 DEBUG (ThreadPoolExecutor-1_0) [pycec] Start watching...
2018-07-14 19:56:24 DEBUG (ThreadPoolExecutor-1_0) [pycec] loop: <uvloop.Loop running=True closed=False debug=False>
2018-07-14 19:56:24 WARNING (ThreadPoolExecutor-1_0) [pycec] Not initialized. Waiting for init.
2018-07-14 19:56:24 INFO (ThreadPoolExecutor-0_0) [pycec.cec] found a CEC adapter:
2018-07-14 19:56:24 INFO (ThreadPoolExecutor-0_0) [pycec.cec] port:     RPI
2018-07-14 19:56:25 INFO (ThreadPoolExecutor-0_0) [pycec.cec] vendor:   0x2708
2018-07-14 19:56:25 INFO (ThreadPoolExecutor-0_0) [pycec.cec] product:  0x1001
2018-07-14 19:56:25 DEBUG (ThreadPoolExecutor-1_0) [pycec] Init pending - <Future pending cb=[_chain_future.<locals>._call_check_cancel() at /usr/lib/python3.6/asyncio/futures.py:408]>
2018-07-14 19:56:25 WARNING (ThreadPoolExecutor-1_0) [pycec] Not initialized. Waiting for init.
2018-07-14 19:56:26 DEBUG (ThreadPoolExecutor-1_0) [pycec] Init pending - <Future pending cb=[_chain_future.<locals>._call_check_cancel() at /usr/lib/python3.6/asyncio/futures.py:408]>
2018-07-14 19:56:27 WARNING (ThreadPoolExecutor-1_0) [pycec] Not initialized. Waiting for init.
2018-07-14 19:56:27 DEBUG (ThreadPoolExecutor-1_0) [pycec] Init pending - <Future pending cb=[_chain_future.<locals>._call_check_cancel() at /usr/lib/python3.6/asyncio/futures.py:408]>
2018-07-14 19:56:28 WARNING (ThreadPoolExecutor-1_0) [pycec] Not initialized. Waiting for init.
2018-07-14 19:56:28 DEBUG (ThreadPoolExecutor-1_0) [pycec] Init pending - <Future pending cb=[_chain_future.<locals>._call_check_cancel() at /usr/lib/python3.6/asyncio/futures.py:408]>
2018-07-14 19:56:29 WARNING (ThreadPoolExecutor-1_0) [pycec] Not initialized. Waiting for init.
2018-07-14 19:56:29 DEBUG (ThreadPoolExecutor-1_0) [pycec] Init pending - <Future pending cb=[_chain_future.<locals>._call_check_cancel() at /usr/lib/python3.6/asyncio/futures.py:408]>
2018-07-14 19:56:30 WARNING (ThreadPoolExecutor-1_0) [pycec] Not initialized. Waiting for init.
2018-07-14 19:56:30 DEBUG (ThreadPoolExecutor-1_0) [pycec] Init pending - <Future pending cb=[_chain_future.<locals>._call_check_cancel() at /usr/lib/python3.6/asyncio/futures.py:408]>
2018-07-14 19:56:31 WARNING (ThreadPoolExecutor-1_0) [pycec] Not initialized. Waiting for init.
2018-07-14 19:56:32 DEBUG (ThreadPoolExecutor-1_0) [pycec] Init pending - <Future pending cb=[_chain_future.<locals>._call_check_cancel() at /usr/lib/python3.6/asyncio/futures.py:408]>
2018-07-14 19:56:32 WARNING (ThreadPoolExecutor-1_0) [pycec] Not initialized. Waiting for init.
2018-07-14 19:56:33 DEBUG (ThreadPoolExecutor-1_0) [pycec] Init pending - <Future pending cb=[_chain_future.<locals>._call_check_cancel() at /usr/lib/python3.6/asyncio/futures.py:408]>
2018-07-14 19:56:33 WARNING (ThreadPoolExecutor-1_0) [pycec] Not initialized. Waiting for init.
2018-07-14 19:56:34 DEBUG (ThreadPoolExecutor-1_0) [pycec] Init pending - <Future pending cb=[_chain_future.<locals>._call_check_cancel() at /usr/lib/python3.6/asyncio/futures.py:408]>
2018-07-14 19:56:34 WARNING (ThreadPoolExecutor-1_0) [pycec] Not initialized. Waiting for init.
2018-07-14 19:56:35 DEBUG (ThreadPoolExecutor-1_0) [pycec] Init pending - <Future pending cb=[_chain_future.<locals>._call_check_cancel() at /usr/lib/python3.6/asyncio/futures.py:408]>
2018-07-14 19:56:35 ERROR (ThreadPoolExecutor-0_0) [pycec.cec] failed to open a connection to the CEC adapter
2018-07-14 19:56:35 WARNING (ThreadPoolExecutor-1_0) [pycec] Not initialized. Waiting for init.
2018-07-14 19:56:36 DEBUG (ThreadPoolExecutor-1_0) [pycec] Init done
2018-07-14 19:56:36 WARNING (ThreadPoolExecutor-1_0) [pycec] Not initialized. Waiting for init.
2018-07-14 19:56:37 WARNING (ThreadPoolExecutor-1_0) [pycec] Not initialized. Waiting for init.
2018-07-14 19:56:38 WARNING (ThreadPoolExecutor-1_0) [pycec] Not initialized. Waiting for init.

@laithalsunni
Copy link

I’m having the same problem. I’m using hassio running on Resin OS 2.3.0+rev1 on a raspberry pi 3

@nitobuendia
Copy link
Author

My error has evolved into:

Error during setup of component hdmi_cec
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/homeassistant/setup.py", line 146, in _async_setup_component
    component.setup, hass, processed_config)  # type: ignore
  File "/usr/local/lib/python3.6/concurrent/futures/thread.py", line 56, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/local/lib/python3.6/site-packages/homeassistant/components/hdmi_cec.py", line 182, in setup
    adapter = CecAdapter(name=display_name[:12], activate_source=False)
  File "/usr/local/lib/python3.6/site-packages/pycec/cec.py", line 20, in __init__
    import cec
ModuleNotFoundError: No module named 'cec'

Which is consistent with the reports on #15514.

@laithalsunni
Copy link

this is my error

Error during setup of component hdmi_cec
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/homeassistant/setup.py", line 146, in _async_setup_component
    component.setup, hass, processed_config)  # type: ignore
  File "/usr/local/lib/python3.6/concurrent/futures/thread.py", line 56, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/local/lib/python3.6/site-packages/homeassistant/components/hdmi_cec.py", line 182, in setup
    adapter = CecAdapter(name=display_name[:12], activate_source=False)
  File "/usr/local/lib/python3.6/site-packages/pycec/cec.py", line 20, in __init__
    import cec
ModuleNotFoundError: No module named 'cec'

@nathanm412
Copy link

I attempted to move to HassOS to see if it changed anything, but unfortunately I'm having the same issues.
HassOS 1.7 production
HomeAssistant 0.74.0

configuration.yaml:

hdmi_cec:
  devices:
    VizioTV: 0.0.0.0
    Hassio: 2.0.0.0
    Soundbar: 1.0.0.0
    Shield: 1.1.0.0

error message:

2018-07-22 21:26:58 ERROR (MainThread) [homeassistant.setup] Error during setup of component hdmi_cec
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/homeassistant/setup.py", line 146, in _async_setup_component
    component.setup, hass, processed_config)  # type: ignore
  File "/usr/local/lib/python3.6/concurrent/futures/thread.py", line 56, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/local/lib/python3.6/site-packages/homeassistant/components/hdmi_cec.py", line 182, in setup
    adapter = CecAdapter(name=display_name[:12], activate_source=False)
  File "/usr/local/lib/python3.6/site-packages/pycec/cec.py", line 20, in __init__
    import cec
ModuleNotFoundError: No module named 'cec'

I don't know if it would be useful or not, but here's the output from the CEC Scanner add-on:

starting version 3.2.2
opening a connection to the CEC adapter...
requesting CEC bus information ...
ERROR:   [           14392]	failed to request the physical address
CEC bus information
===================
device #0: TV
address:       0.0.0.0
active source: no
vendor:        Unknown
osd string:    TV
CEC version:   1.3a
power status:  standby
language:      ???
device #1: Recorder 1
address:       2.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:       f.f.f.f
active source: no
vendor:        Unknown
osd string:    Playback 1
CEC version:   unknown
power status:  unknown
language:      ???
device #5: Audio
address:       1.0.0.0
active source: no
vendor:        Unknown
osd string:    VIZIO SB4031
CEC version:   1.4
power status:  standby
language:      ???
device #B: Playback 3
address:       1.1.0.0
active source: no
vendor:        Unknown
osd string:    SHIELD
CEC version:   1.4
power status:  standby
language:      ???
currently active source: unknown (-1)

@laithalsunni
Copy link

Updating to 0.74.1 fixed it for me

@nitobuendia
Copy link
Author

nitobuendia commented Jul 28, 2018

Still happens for me on 0.74.2.

Not initialized. Waiting for init.
16:46 /usr/local/lib/python3.6/site-packages/pycec/network.py (WARNING)

I feel this error, while being the original error, it is different than the "No module named cec" which seems fixed.

Under current situation, hdmi_cec services appear. However, no devices are detected. When trying to run a command, say power on, this is the error generated:

Jul 28 2018 16:54:08 GMT+0800 (Singapore Standard Time)

Exception in callback <bound method CecAdapter.power_on_devices of <pycec.cec.CecAdapter object at 0x733dfc90>>
handle: <Handle CecAdapter.power_on_devices>
Traceback (most recent call last):
  File "uvloop/cbhandles.pyx", line 62, in uvloop.loop.Handle._run
  File "/usr/local/lib/python3.6/site-packages/pycec/cec.py", line 51, in power_on_devices
    self._adapter.PowerOnDevices)
AttributeError: 'NoneType' object has no attribute 'PowerOnDevices'

This means self._adapter is None.

self._adapter seems to be defined on line 84 of cec.py when init method is called. Although it could be initiated in other parts on derived classes.

If we re-read the original error, it says we are "waiting for init", which might be waiting for it to be called? The waiting for init message is logged by the network.py code.

Any thoughts?

@Minims
Copy link
Contributor

Minims commented Jul 30, 2018

Here is how I make it worked, it is not the right way, but it has resolved my issue.

homeassistant@rpi3:~$ diff -u  /srv/homeassistant/lib/python3.5/site-packages/homeassistant/helpers/entity_platform.py.old  /srv/homeassistant/lib/python3.5/site-packages/homeassistant/helpers/entity_platform.py
--- /srv/homeassistant/lib/python3.5/site-packages/homeassistant/helpers/entity_platform.py.old 2018-05-23 19:09:34.692849510 +0200
+++ /srv/homeassistant/lib/python3.5/site-packages/homeassistant/helpers/entity_platform.py     2018-05-23 19:09:59.252695151 +0200
@@ -299,6 +299,8 @@
         if not valid_entity_id(entity.entity_id):
             raise HomeAssistantError(
                 'Invalid entity id: {}'.format(entity.entity_id))
+        elif 'hdmi' in entity.entity_id:
+            msg = 'Entity id is CEC: {}'.format(entity.entity_id)
         elif entity.entity_id in component_entities:
             msg = 'Entity id already exists: {}'.format(entity.entity_id)
             if entity.unique_id is not None:
homeassistant@rpi3:~$

@rob1998
Copy link

rob1998 commented Aug 8, 2018

Did a fresh install of HassOS today, running version 0.75.2
and I'm also stil encountering this error

@ghost ghost added the in progress label Oct 17, 2018
@nbeernink
Copy link

nbeernink commented Oct 22, 2018

Thanks for posting this @nitobuendia, I came across the exact same thing you are experiencing and was about to log an issue.

Sadly no fix to contribute yet. Constantly having to reboot home assistant in order to see if any changes fixes the issue make it really cumbersome to test.

core-ssh:~# hassio ha info
{
    "result": "ok",
    "data": {
        "version": "0.80.3",
        "last_version": "0.80.3",
        "machine": "raspberrypi3-64",
        "image": "homeassistant/raspberrypi3-64-homeassistant",
        "custom": false,
        "boot": true,
        "port": 8123,
        "ssl": true,
        "watchdog": true,
        "wait_boot": 600
    }
}

hdmi_cec:
  devices:
    TV: 0.0.0.0
    Onkyo: 1.0.0.0
    Chromecast: 1.1.0.0
    Home Assistant: 1.3.0.0
    Steam Link: 1.4.0.0

Turning on the chromecast works using the mediaplayer platform.

@nbeernink
Copy link

Maybe this issue needs to be moved to the hassio project instead of home-assistant?

@danieledwardgeorgehitchcock

Maybe this issue needs to be moved to the hassio project instead of home-assistant?

I'd recommend against this as the issue is apparent in both the Docker image and HASSIO.

@pvizeli
Copy link
Member

pvizeli commented Nov 14, 2018

@frkos
Copy link

frkos commented Feb 15, 2019

I have hass.io + docker installation (HA ver 0.87.1). And I see the same issue with HDMI CEC
Not initialized. Waiting for init. /usr/local/lib/python3.6/site-packages/pycec/network.py (WARNING)

but HA sees my TV and even it's actual status - on or off (with a delay ~5 sec). So I can use it as trigger in automation. But commands still don't work...

@nbeernink
Copy link

nbeernink commented Feb 15, 2019

frkos' response triggered me to post this reply, sorry for not posting sooner. 😉

I do get the status delay that he's describing but switching on/off does work for me (several months ago).

arch aarch64
dev false
docker true
hassio true
os_name Linux
python_version 3.6.6
timezone Europe/Amsterdam
version 0.87.1
virtualenv false

@frkos
Copy link

frkos commented Feb 15, 2019

Hi @nbeernink
So could you share your config? I've just added these lines to configuration.yaml

hdmi_cec:
   devices:
      TV: 0.0.0.0

@nbeernink
Copy link

nbeernink commented Feb 15, 2019

Sure!
configuration.yaml contains:

hdmi_cec: !include hdmi_cec.yaml

hdmi_cec.yaml contains:

devices:
  TV: 0.0.0.0
  Onkyo: 1.0.0.0
  Chromecast: 1.1.0.0
  Home Assistant: 1.3.0.0
  Steam Link: 1.4.0.0

@stale
Copy link

stale bot commented Jul 7, 2019

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates.
Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍
This issue now has been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Jul 7, 2019
@stale stale bot closed this as completed Jul 14, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests