HDMI CEC on networked device

Hi guys,

Short version: Is there a way to get the HDMI CEC commands to work on another device in the same network?

I’ve currently got a few dedicated pi’s running around the house, one of which is running all my home automation fun (home assistant, mqtt, homebridge, …) and another on my tv running openelec (Kodi). I was hoping there was a simple way to issue hdmi cec commands from my home automation pi to my media center pi but turns out it isn’t quite that easy :slight_smile:
The current workaround I have in mind will issue ssh commands from my home automation pi to my media center pi’s CEC client, but there’s a delay in my preliminary testing that I’d like to remove if possible at all.

Anyone else tried to do something similar? Any success?

Thanks!

Install HA on TV connected pi.
Use eventstream component to issue command and sync state between main HA and slave HA.

OR

Create webserver on 2nd pi and some scripting that triggers HDMI command
Create MQTT server on main HA and send MQTT from 2nd pi to inform state
Use MQTT sensor to pull state into HA
Instead of MQTT you can also have webpage showing state details and poll this data as sensor in HA

Have a look here:

:slight_smile:

Great!!!
Thank you, will give this a go during the holidays.
I’ll be expanding it to toggle hdmi input source but this is an awesome starting point.

Thanks for taking the time to answer me.
option 1 is not available for me as I’m running the openelec OS on that pi.

Option 2 might be a possibility. I’ll have to toy around with the answer below, and a mqtt-client python script possibility to check which has best performance.

I made a project that does this over MQTT. You can also blast and receive infrared commands. It works instantly.

You can use mqtt.publish to send a command and you can create a binary MQTT sensor to capture the device state updates.

3 Likes

Do you have any documentation on where the info for the config.ini should come from? Specifically “ID of CEC controller” and “Port where the CEC-device is connected”

You can mostly leave the defaults as they are.
For the mqtt section, you do need to configure the broker, user and password.
For the cec section, you can configure the id and port based on the output of cec-client -l, but for a RPI, the defaults should be okay.

Actually, I’m not even sure the id is used for cec. I think libcec automatically uses id 1.

More information about the id’s of cec is available on http://wiki.kwikwai.com/index.php?title=The_HDMI-CEC_bus.

Sorry for the late reply, but this looks perfect! will try it asap.

Hey,
I’m trying to get this up an running on Openelec, however I’m not able to get the module cec imported.
I get this error message:
Initialising CEC…
(‘ERROR: Could not initialise CEC:’, ‘No module named _cec’)

I’ll reply on GitHub as well.
Would be great if I could get it to go on there but since it’s a pretty closed system …

Note that networked HDMI CEC will be integrated into the Home Assistant hdmi_cec component in the next release.

Owww, sweet. did not know that. I’ll take a look at the info for the upcomming release :slight_smile: I’m trying to find more info on it but can’t seem to find it. could you direct me in the reight direction?

Well, the pull request is here: https://github.com/home-assistant/home-assistant/pull/4781

There’ll be full documentation on home-assistant.io when the next release comes out, which I believe is this weekend.

I’ve installed the build, but I “think” the required module on the client (pyCec) is a python 3 only module … openelec doesn’t have python3 available, only 2 :frowning:

HDMI CEC component needs all devices to be connected together by hdmi cable. Managing devices by network is still unavailable. :frowning:

This is a grave dig but I am struggling.

Trying to get cec-mqtt-bridge running on a Pi Zero. I have followed instructions from self hosted home (Make a Dumb TV "Smart" using MQTT and CEC - Self Hosted Home) and every time I build the docker image, it wants to update Raspbian looking at the older Jesse OS, not Bullseye. Is there something really basic I am missing?

Also tried Docker from (Docker Hub) but cannot seem to get the container to run at all. I am a Docker noob but it shouldn’t be this hard.

~/cec-mqtt-bridge $ docker build -t cec-mqtt-bridge .
Sending build context to Docker daemon  494.1kB
Step 1/8 : FROM jonaseck/rpi-raspbian-libcec-py
 ---> 069597d2af8a
Step 2/8 : RUN apt-get update  && apt-get install -qqy libxrandr2 liblircclient-dev  && rm -rf /var/lib/apt/lists/*
 ---> Running in a160093fac07
Get:1 http://archive.raspberrypi.org jessie InRelease [22.9 kB]
Ign http://archive.raspbian.org jessie InRelease
Ign http://archive.raspbian.org jessie Release.gpg
Ign http://archive.raspbian.org jessie Release
Err http://archive.raspbian.org jessie/main armhf Packages
  404  Not Found
Err http://archive.raspbian.org jessie/contrib armhf Packages
  404  Not Found
Get:2 http://archive.raspberrypi.org jessie/main armhf Packages [170 kB]
Err http://archive.raspbian.org jessie/non-free armhf Packages
  404  Not Found
Err http://archive.raspbian.org jessie/rpi armhf Packages
  404  Not Found
Err http://archive.raspbian.org jessie/firmware armhf Packages
  404  Not Found
Fetched 193 kB in 38s (4965 B/s)
W: Failed to fetch http://archive.raspbian.org/raspbian/dists/jessie/main/binary-armhf/Packages  404  Not Found

W: Failed to fetch http://archive.raspbian.org/raspbian/dists/jessie/contrib/binary-armhf/Packages  404  Not Found

W: Failed to fetch http://archive.raspbian.org/raspbian/dists/jessie/non-free/binary-armhf/Packages  404  Not Found

W: Failed to fetch http://archive.raspbian.org/raspbian/dists/jessie/rpi/binary-armhf/Packages  404  Not Found

W: Failed to fetch http://archive.raspbian.org/raspbian/dists/jessie/firmware/binary-armhf/Packages  404  Not Found

E: Some index files failed to download. They have been ignored, or old ones used instead.
The command '/bin/sh -c apt-get update  && apt-get install -qqy libxrandr2 liblircclient-dev  && rm -rf /var/lib/apt/lists/*' returned a non-zero code: 100

@goobags Did you find this out in the end ?