-
Notifications
You must be signed in to change notification settings - Fork 249
Control TV over HDMI
A Raspberry PI can automatically turn a TV that's connected over HDMI on and off using HDMI-CEC. More info: https://pimylifeup.com/raspberrypi-hdmi-cec/
You might need to configure the Pi to always output HDMI so do this add these two lines to /boot/config.txt and reboot:
hdmi_force_hotplug=1
hdmi_drive=2
More info: https://raspberrypi.stackexchange.com/a/2171
sudo apt install cec-utils
Put TV into stand-by
Run the following command to turn it on:
echo 'on 0.0.0.0' | cec-client -s -d 1
Create Systemd service to turn the tv on when booting:
sudo nano /etc/systemd/system/tv-on.service
[Unit]
Description=Turn TV on using cec-client
After=network.target
[Service]
Type=simple
ExecStart=/bin/bash -c "echo 'on 0.0.0.0' | cec-client -s -d 1"
[Install]
WantedBy=multi-user.target
Enable service: sudo systemctl enable tv-on
Edit cronjobs: crontab -e
:
0 18 * * * echo 'standby 0.0.0.0' | /usr/bin/cec-client -s -d 1
5 18 * * * sudo /sbin/shutdown -h now >/dev/null 2>&1
This does: 18:00: Put the tv into standby mode 18:15: Gracefully shutdown
Alternatively you could also use systemd timers https://opensource.com/article/20/7/systemd-timers