Graveyard¶
This file contains a list of previous implementations that have been replaced with newer ones.
CEC through Raspberry PI¶
I no longer use this method because Home Assistant was regularly losing connection with the Raspberry PI and the only way to resolve it was to restart regularly Homeassistant. See latest CEC implementation .
CEC is a feature of HDMI that allows individual CEC-enabled devices to control each other without user intervention.
Overview¶
I use CEC protocol control my TV from Home Assistant. Ex: Turn on/off TV, change input source, and control volume.
Proxy configuration¶
Setup service¶
Compile/Install libcec
Install pyCEC
pip3 install pyCEC
Configure a service for pyCEC:
[Unit]
Description=PyCEC
Documentation=
After=network.target
[Service]
Type=simple
User=retro
ExecStart=/usr/bin/python3 -m pycec
Restart=always
#RuntimeMaxSec=1d
#MemoryHigh=50M
MemoryMax=60M
MemorySwapMax=0
[Install]
WantedBy=multi-user.target
It appears to have a memory leak and I made sure it kills itself when it gets to 60M of memory.
Home Assistant¶
Configuration¶
create a file hdmi_cec.yaml
and add the hostname/ip of the cec proxy:
host: retro-controller.local # this the hostname of my raspberry pi
in configuration.yaml
add:
hdmi_cec: !include hdmi_cec.yaml
Automations¶
I used CEC-O-Matic to determine the messages for my TV.
Action |
Message |
---|---|
Power on |
10:04 |
Standby |
10:36 |
Change source 1 |
1f:82:10:00 |
Change source 2 |
1f:82:20:00 |
Change source 3 |
1f:82:30:00 |
Volume up |
10:44:41:00 |
Volume down |
10:44:42:00 |
This is an example home assistant automation to switch to hdmi 1:
service: hdmi_cec.send_command
data:
raw: 1f:82:10:00
Infrared through Arduino¶
I no longer use this method because Home Assistant was regularly losing connection with the Raspberry PI and the only way to resolve it was to restart regularly Homeassistant. See latest infrared implementation .
Overview¶
I use Infrared signals to:
change profile of the Retrotink4K
change the input of the HDMI switch
This is how the whole process looks like:
This is how the whole setup looks like:
Home Assistant MQTT¶
Prerequisites¶
Setup Home Assistant’s MQTT Broker.
Automation¶
Create an automation to send the nec codes to mqtt2nec.
The codes match mqtt2nec’s config.csv. You can also send codes as hex strings.
The first value is common for the device and the next ones are the actual code you want to send.
service: mqtt.publish
data:
topic: nec/tx
payload: "{\"codes\": [ \"TINK4K\", \"TINK4K_1\" ]}"
mqtt2nec¶
Python program interfacing Home assistant with the arduino. It is installed on the Raspberry pi and runs as a service.
Installing the program¶
git clone git@github.com:jrobichaud/mqtt2nec.git
cd mqtt2nec
python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txt
Running the program¶
Make sure to change the arguments to match your mqtt broker configuration.
python3 -m "mqtt2nec" "<home assistant url>" -u "<mqtt user>" -p "<mqtt password>" -a "./config.csv"
Service configuration¶
[Unit]
Description=mqtt2nec
Documentation=
After=network.target
[Service]
Type=simple
User=retro
ExecStart=/usr/bin/python3 -m "mqtt2nec" "<home assistant url>" -u "<mqtt user>" -p "<mqtt password>" -a "/home/retro/mqtt2nec/config.csv"
Restart=always
MemorySwapMax=0
[Install]
WantedBy=multi-user.target
Arduino¶
I used this kit to prototype: Basic Kit for Arduino
I use the Arduino Nano Every on my setup.