Query HDMI status?

Is there a simple way via a script etc. to get the current HDMI status? ie. if I switch the HDMI input on my receiver to something other than my odroid is there a way to recognise this action?

I notice if I run “cec-client” via SSH that I get all sorts of info back but a) I can’t make much out of it and b) I don’t really know what this binary is used for?

cat /sys/class/amhdmitx/amhdmitx0/hpd_state

Is that what you want? Shows you if hdmi is connected.

Sadly no, that just returns 1, I guess to indicate the HDMI interface is connected to something.

I really wanted a way of knowing whether the CEC link was using this connection, not even sure if it’s possible? If I switch inputs on my amp while running cec-client then things happen so it knows CEC instructions are being sent around, it’s just how to make use of the outputs.

I see. You have to know that normally you should not use cec-client while Kodi is running. Your current physical address can be read from sysfs. You can also send raw cec commands through sysfs. I think there is no command to query the current physical address that is the active source. You would have to monitor CEC and see what physical address requests active source.

Use the following website to find out what messages you are looking for.

Just out of curiosity, why do you need to know that programmatically?


Not sure if I’ll explain it well, but I like having my coreelec box set to turn off my display/n2/amp after 30 minutes of inactivity because I don’t want to waste power and I’m always a bit paranoid about my oled display.

The downside to this is that at if I switch my amp to another input, like my gaming pc or bluray player then after 30 minutes everything then just shuts off.

It would be nice if I could come up with a simple way for the n2 to then stay on, at least for as long as I’m using another input via the amp.

But this should already work out of the box. At least I was using it before. I was even a bit more restrictive then you. I had set that TV is turned of after 3min of inactivity and my N2 suspend after 5min. It will only turn of the TV is it’s the Active Source. If I watch Netflix within the TV App the TV will not be turned off and the N2 still goes into suspend after 5min.

EDIT: Just tested and it’s still working here.

@Ray: glad to see you back here again…
I recognize your hut again…


Hmm, that’s never worked like that for me, I’ll have to try again.

Maybe the difference is suspend rather than shutdown? I’ve always set it to shutdown rather than suspend.

@Ray so maybe it’s my Sony amp, but if I set it to suspend after say 5 minutes and leave the input as my n2, it then goes to suspend successfully and shuts down the TV and amp in the process.

If I leave it and switch the input on my amp to something else, after 5 minutes it switches my amp back to the n2 rather than going to suspend.

Ok I think I know what you mean. I had that with the power save option. Here is how it works for me.
System --> Power Saving --> Shutdown fiction timer off
Interface --> Screensaver --> wait time 1min (example)
System --> input --> Peripherals --> CEC Adapter --> put devices in standby mode when activating the screensaver
Optionally you can use: wake devices when deactivating screensaver

@Ray I will give it a go using the screensaver method instead, will let you know if that method works.

Nope, that still just turns off the TV and amp unfortunately so I’m still after a method whereby I can have the TV/Amp/n2 turn off, but ONLY if the n2 is the current source being used.

Thie is working here. I have an LG OLED and the N2 is connected to a Samsung Soundbar. Weird.

Must be my Sony amp then confusing it.

Just checking you got only the screensaver option and not the power saving option right?

like any linux command, you better use cec-client --help to know what to do.
apart from the commands listed there, you can also see at the bottom of that help screen:
“Type ‘h’ or ‘help’ and press enter after starting the client to display all available commands”
so writing echo "h" | cec-client -s -d 1 should get you more advanced commands.

I use a similar test in my setup, to see if the TV is on before doing other stuff.
you can try the ad {address of queried device} command which “checks whether the specified device is active.”
the address of my TV is usually 0. you can use lad to “list the active devices on the bus” and get the addresses.

but the bad news are that for me, the output of cec-client is wrong many times.
so for me, it’s pretty much unreliable.
but give it a try and see if it works for you…

@Ray yes I tried the screensaver option like you suggested.

So it looks like something is not working as intended because in the code Mediaplayer checks if it’s the active source:

Can you make a screenshot of your peripheral settings. Maybe you don’t set active source.