Raspberry Pi: Power On / Off A TV Connected Via HDMI-CEC

With the help of cec-client (part of libcec), your Raspberry Pi can control a device that supports CEC, like a TV, connected via HDMI. You could power the TV on or off, switch the active source, and more. This should work with any Raspberry Pi version or model, including the original Raspberry Pi, as well as the latest Raspberry Pi 4.