Martin C
Martin C

Reputation: 31

Detecting if HDMI input is currently the TV's selected source, using Raspberry PI

I am using a RPi connected through HDMI to a Samsung TV. I am attempting to trigger RPi processes so that they are only active when the HDMI output is being used by the TV. Effectively, I would like to start the process when the correct HDMI input is selected from the TV and terminate it when another TV source is selected.

I have tried to use tvservice –s for that end, but the command’s output does not change depending on whether the TV is configured to use the RPi’s HDMI or any other source.

Therefore, I welcome suggestions on what other mechanisms could be used (e.g. low-level drivers, libCEC, xrandr) to determine if the TV is currently using the RPI’s HDMI.

Thanks!

Upvotes: 3

Views: 2322

Answers (3)

Martin Edlman
Martin Edlman

Reputation: 753

No matter how I try to use tvservice -s or tvservice -m and no matter if TV is on, stand by or off, it still reports same value state 0x120001 [TV is off]. My TV is some older Samsung, device is RPi 4B. The only solution I found to detect the TV is on or goes to stand by is by using cec-ctl -m which monitors CEC commands. When TV goes to stand by it sends a message containing STANDBY text. So I monitor CEC and grep first STANDBY message, then I poweroff RPi. cec-ctl -m --tv | grep -m 1 STANDBY. Maybe this will help someone. I can post my full shell script if someone find it interesting.

Upvotes: 1

Chris Eloranta
Chris Eloranta

Reputation: 21

HDMI sink devices (like TVs) no longer break the HDMI “handshake” when switching sources. When HDMI was young, switching sources would take 3-6 seconds... generally with a black screen during the interim. TV consumers found this unacceptable, so manufacturers created inputs which were “always on.” This makes the connection appear to remain on even when switched.

Upvotes: 2

Himanshu Gajjar
Himanshu Gajjar

Reputation: 21

You may try "tvservice --name" I have tried without connecting display it replied with "[E] No device present" Maybe it replies with Name of Tv when connected.

Upvotes: 0

Related Questions