The purpose of this project is:
🔹 to provide an object-based API to libcec
for the hdmi_cec
module in Home Assistant (primary goal)
🔹 to offer a TCP ⇄ HDMI bridge to control CEC devices over network
(secondary goal)
🔌 Send commands to your TV or AV receiver
🖥️ Monitor HDMI power and input status
🏠 Integrate with Home Assistant automations
🎮 Control devices using Kodi remote or custom scripts
💻 Simple command-line interface (CLI)
🐍 Python API for custom scripting
📺 Kodi integration (via bundled plugin)
pip install pyCEC
⚠️ libcec must be installed for direct-mode usage.
Do not runpip install cec
– it will fail. Instead, compile libcec for your OS.
sudo apt install libcec-dev cec-utils
If you're using a Python virtualenv, make sure it can access system Python modules with:
python3 -m venv venv --system-site-packages
💡 Note: When using
pyCEC
in network mode (TCP client),libcec
is not required.
You can launch the server bridge with:
python3 -m pycec
This binds to TCP port 9526
on all interfaces.
Then:
- connect from a remote
pyCEC
client usingTcpAdapter
- or use Netcat to manually send CEC commands:
echo '10:04' | nc YOUR_IP 9526
You can integrate pyCEC
into Home Assistant via telnet
platform, for example:
switch:
- platform: telnet
switches:
some_device_id:
name: "Some Device Name"
resource: 192.168.1.123
port: 9526
command_on: '10:04'
command_off: '10:36'
command_state: '10:8f'
value_template: '{{ value == "01:90:00" }}'
timeout: 1
This allows you to switch devices on/off or query their state.
Contributions are welcome!
Feel free to open an issue or create a pull request.
MIT License – see LICENSE.
Made with ❤️ by @konikvranik