Issue with HDMI_CEC component

Hi experts,
I cant make hdmi_cec component work anyway. My hass is installed in RPi3 and then I installed libcec following this script . libcec has been successfully installed and with the cec-client command I am able to on/off my TV as well. But problem is, whenever I try to follow the HDMI_CEC component configuration guideline, it doesn’t load anything at all. the error is like below:

16-08-05 14:59:46 homeassistant.bootstrap: Invalid config for [hdmi_cec]: expected a dictionary for dictionary value @ data[‘hdmi_cec’][‘devices’]

Basically, I am not clear though , excel on/off if anything I would be able to do with CEC (e.g. Channel Up/Down). Anyway, the on/off option looks nice to me.

Btw, can anyone point me to the right direction where I can get some automation example with HDMI CEC component as well ? I want to place a input box for on/off in the front page, possible ?

Thanks & Regards

Hi @tarikul,

Can you post the hdmi_cec: code snippet from your YAML configuration so we can see what code is generating the error?

Can you also describe how all HDMI devices are connected and to what inputs on what devices?

If you open a terminal and run echo scan|cec-client -s -d 1 What is the output?

1 Like

@andrew-curtis,

Thanks for asking. Please find the below output…

pi@raspberrypi:~$ 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: yes
vendor: Samsung
osd string: TV
CEC version: 1.3a
power status: on
language: eng

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

currently active source: TV (0)

================================

And here is the hdmi_cec yaml configuration…

hdmi_cec:
devices:
0. TV
1. raspberrypi
2. Chromecast

Thanks & Regards
Tarikul

Thanks for that.

OK i can see some pretty obvious formatting issues with your YAML which I am pretty sure is the issue. See here for an example, taking note of the indents and numbering. They are crucial to getting this working correctly.

So assuming that you have your Pi connected to HDMI1 and your Chromecast connected to HDMI 2 on your TV your hdmi_cec: entry should look like below.

hdmi_cec:
  devices:
    1: raspberrypi
    2: Chromecast

Let me know how that goes for you before we move onto the Input Boolean switch for your ‘Input Box’ for the frontend. :slight_smile:

EDIT: corrected syntax error in code as @martinhjelmare pointed out below.

1 Like

Replace the dots with colons:

hdmi_cec:
  devices:
    1: raspberrypi
    2: Chromecast
1 Like

Thanks a ton both of you guys… Indeed the solution was to use the colon(:slight_smile: in devices list… In the documentation it was mentioned as dot(.)
The YAML configuration was correct indeed but during copying I mistakenly removed the spaces. Anyway thanks again for your tremendous help.

oops, thanks for the pickup @martinhjelmare.

I’ll update my post so it doesn’t catch anyone else out.

1 Like

Glad we could help.

What documentation where ‘mentioned as dot’ @tarikul? We might need to correct it.

Hi Andrew, oops! my mistake… The documentation is correct actually as I checked again now. I referred to the HDMI component… Thanks a lot man…

By the way, could you please refer to any automation example with input_boolean to possibly power_on/standby/select_device the HDMI TV from the front end. The component example doesnt cover much or least not for a noob like myself. However, from the developer tab, I am now able to do the source change and power on/off the TV.

Ok thats good.

I’ve done something similar to what you want to do by using an input_select: instead of input.boolean: and some automation rules to go with it. I actually plan on adding an example to the component page for the reasons you have stated but only once I have something that is reliable. By that I mean I am currently working through a bug or something as I can only trigger the automation once for each option in my input.selection. After which the HDMI control part of my automation just stops working.

Maybe you could do me a favour and try a modified version of my input_select: to suit your first, to help me with my troubleshooting?

http://hastebin.com/afutejurah.sm

NOTE: I have added some otherwise unnecessary persistent notifications to help with troubleshooting my automations but It might be useful for you initially too.

Fingers crossed it works for you. :smiley:

1 Like

Thanks a lot Andrew… Its perfect! working flawlessly. However, I had added the “On” option as well so that it could turn the TV on first.

I just removed the persistent notification otherwise just used your configuration. Please find the below configuration of mine.

+++++++++++++++++++++++++++++++++++++++

  • alias: Chromecast Input
    trigger:
    platform: state
    entity_id: input_select.tv_input
    to: ‘Chromecast’
    action:
    service: hdmi_cec.select_device
    data:
    device: “Chromecast”
    • alias: Turn off TV
      trigger:
      platform: state
      entity_id: input_select.tv_input
      to: ‘OFF’
      action:
      • service: hdmi_cec.standby
    • alias: Turn On TV
      trigger:
      platform: state
      entity_id: input_select.tv_input
      to: ‘ON’
      action:
      • service: hdmi_cec.power_on
        ‘’’
        +++++++++++++++++++++++++++++++

Update: seems like I can’t place the necessary spaces in the code here…

Thanks
Tarikul

Glad I could help. :smile:

So input_select suited your requirements just fine? I’m taking it you don’t have trouble with it not changing inputs after a few tries of different selections?

What I am working on now with @dale3h’s help is some sort of status display for your HDMI devices so you can see in HASS what is on and which is selected. I’ll be sure to share it once we have something useful. :slight_smile:

Yep man… Thanks a lot again. The input_select is serving my purpose. However, hass status is not updated once the TV has been powered off/on manually. That’s okay to my purpose.

Regarding the responsiveness, I would say the reliability is not 100% but reasonable. For example, if the power is off, then if I try to change the input to Chromecast it is not responding rather I have to press ‘OFF’(once again) then ‘ON’ then ‘Chromecast’ which works fine.

Indeed, before HDMI_CEC component I tried with samsungtv component with IP address, that also works but it couldn’t power on the TV for obvious reason… When its powered off, it doesn’t have any IP assigned hence no control…

Did you make any progress as far as being able to display status in the HASS UI?

Thanks.

Nope sorry. Work has got in the way of me doing any tinkering with my HASS setup for a few months now.

Same problem. Got any solution in the meantime?