Files
pi-cec/README.md
phil ad963000f6 Update package name to cec-utils for Raspberry Pi OS
Change installation instructions from libcec-rpi to cec-utils which is the correct package name for Raspberry Pi OS (Raspbian).

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-02-06 17:52:40 +01:00

2.1 KiB

CEC Control for Raspberry Pi 4

Control HDMI-connected devices (TVs, receivers, etc.) from your Raspberry Pi 4 using CEC (Consumer Electronics Control).

Installation

  1. Install the required CEC utilities:
sudo apt-get update
sudo apt-get install cec-utils
  1. Make the script executable (already done):
chmod +x cec-control.sh

Usage

./cec-control.sh <command> [options]

Available Commands

Command Description Example
tv-on Turn on the TV ./cec-control.sh tv-on
tv-off Turn off the TV ./cec-control.sh tv-off
standby Put TV in standby ./cec-control.sh standby
wake Wake TV from standby ./cec-control.sh wake
vol-up Increase volume ./cec-control.sh vol-up
vol-down Decrease volume ./cec-control.sh vol-down
mute Mute audio ./cec-control.sh mute
input <port> Switch HDMI input (0-15) ./cec-control.sh input 1
source <device> Switch source device (0-15) ./cec-control.sh source 2
scan Scan for CEC devices ./cec-control.sh scan
status Show CEC adapter status ./cec-control.sh status
info Show TV information ./cec-control.sh info
raw <command> Send raw CEC command ./cec-control.sh raw 4f:82:10:00
help Show help message ./cec-control.sh help

Quick Start

  1. Connect your Raspberry Pi to your TV via HDMI
  2. Enable CEC on your TV (usually in settings)
  3. Test the connection:
./cec-control.sh scan
  1. Turn on your TV:
./cec-control.sh tv-on

Troubleshooting

  • CEC not working: Make sure CEC is enabled in your TV settings
  • Permission denied: Run with sudo if needed
  • Device not found: Check HDMI connection and try rescanning with scan command

Advanced Usage

You can integrate this script into your own automation:

# Turn on TV and switch to input 1
./cec-control.sh tv-on && sleep 2 && ./cec-control.sh input 1

# Use in cron jobs or other scripts
@reboot /path/to/cec-control.sh tv-on