A HDMI-CEC and IR to MQTT bridge written in Python 3 for connecting your AV-devices to your Home Automation system. You can control and monitor power status and volume.
- HDMI-CEC
- Power control and feedback
- Volume control (up/down/specific) and feedback
- Relay HDMI-CEC messages from HDMI to broker (RX)
- Relay HDMI-CEC messages from broker to HDMI (TX)
- IR
- Relay IR keypresses from IR to broker (RX)
- Relay IR keypresses from broker to IR (TX)
-
MQTT (required)
- MQTT broker (like Mosquitto)
-
HDMI-CEC (optional)
- libcec4 with python bindings (https://github.com/Pulse-Eight/libcec)
- You can compile the bindings yourself, or use precompiled packages from my libcec directory.
- HDMI-CEC interface device (like a Pulse-Eight device, or a Raspberry Pi)
- libcec4 with python bindings (https://github.com/Pulse-Eight/libcec)
-
IR (optional)
- lirc + hardware to receive and send IR signals
- python-lirc (https://pypi.python.org/pypi/python-lirc/)
The bridge subscribes to the following topics:
topic | body | remark |
---|---|---|
prefix /cec/power/id /set |
on / off |
Turn on/off device with id id . |
prefix /cec/volume/set |
integer (0-127) / up / down |
Sets the volume level of the audio system to a specific level or up/down. |
prefix /cec/mute/set |
on / off |
Mute/Unmute the the audio system. |
prefix /cec/tx |
commands |
Send the specified commands to the CEC bus. You can specify multiple commands by separating them with a space. Example: cec/tx 15:44:41,15:45 . |
prefix /ir/remote /tx |
key |
Send the specified key of remote to the IR transmitter. |
The bridge publishes to the following topics:
topic | body | remark |
---|---|---|
prefix /bridge/status |
online / offline |
Report availability status of the bridge. |
prefix /cec/power/id /status |
on / off |
Report power status of device with id id . |
prefix /cec/volume/status |
integer (0-127) |
Report volume level of the audio system. |
prefix /cec/mute/status |
on / off |
Report mute status of the audio system. |
prefix /cec/rx |
command |
Notify that command was received. |
prefix /ir/remote /rx |
key |
Notify that key of remote was received. You have to configure key AND remote as config in the lircrc file. |
prefix /ir/rx |
key |
Notify that key was received. You have to configure key in the lircrc file. This format is used if the remote is not given in the config file. |
id
is the address (0-15) of the device on the CEC-bus.
mosquitto_pub -t media/cec/volup -m ''
mosquitto_pub -t media/cec/tx -m '15:44:42,15:45'
You can either copy config.default.ini
to config.ini
and adjust its properties, or alternatively declare any of those as environment variables using the format SECTION_KEY
(e.g., MQTT_USER
).
You need a lircrc
config file. This can be generated from the lircd.conf
of your lirc daemon using the script create_lircrc.py
.
Simply call this script with the lircd.conf
path as first argument.
It will print the lircrc contents to stdout and can be easily written to a file:
$ ./create_lircrc.py /etc/lirc/lircd.conf > lircrc
If you write your own lircrc file, notice that the config
parameter for each configuration is what is given to the bridge.
It is assumed that it is in the format <remote>,<key>
.
If only one value is given, the remote is expected to be omitted.
The lircrc format (that would be generated by the create_lircrc.py
script) should look like:
begin
remote = <remote-name>
button = <key-name>
prog = cec-ir-mqtt
config = <remote-name>,<key-name>
end
To only get the key (without the remote name in the MQTT topic) use the format without the remote in the config
:
begin
remote = <remote-name>
button = <key-name>
prog = cec-ir-mqtt
config = <key-name>
end