Looking for a way to turn off hdmi

I am looking for a way to turn hdmi on and off from script or plugin.
I used to use vcgencmd but that doesn’t work in the new version. I tried using tvservice by switching to the old display driver but that broke cec and h264 playback (my apollogies for thinking that was the updates fault).

I can see that osmc is capable of turning the display off because if I use the powersaving/sleep option it does turn the display off but the problem there is that it never turns on again and I have to reboot.

I tried
kodi-send --action=CECStandby

but that doesn’t send the display into standby it just causes it to switch to a different input.

If I understand correctly the osmc remote is able to do this by holding the home button so maybe I can hook into that.

Any ideas would be greatly appreciated.

I assume you are using a Raspberry Pi.

Which version of OSMC are you using?

vcgencmd is somewhat deprecated on Pi as newer versions of OSMC on Pi use a newer video and display framework.

Sam

Yes I am running on a pi 3.

OSMC running Kodi 19.5

osmc 2023.01-1 (kernel:Linux 5.10.78-
7-osmc)

I’ve asked @popcornmix if he can advise.

Thanks

Sam

vcgencmd display_power and tvservice only support the old display stack.

I don’t have a cec capable display to hand, but I might investigate something like:

cec-ctl --to 0 --standby

A different option is to blank the console. Run this as root:

setterm -term linux -blank force < /dev/tty0

(use “-blank poke” to restore), but I think you need to have kodi stopped before running that.

Thanks for the help. I couldn’t get either of the two suggestions to work but I did find a way that works. It turns out my yamaha receiver exposes a restful api over http that I can use to switch its hdmi output off and that neatly puts my display into standby mode.

The way the OSMC remote is keymapped is that in the home screen the home button is long/short press mapped to CECStandby and CECActivateSource respectively which can act as discrete on and off functions. Kodi also has an actionid for CECToggleState but none of my TV’s supported this function and from the bit of digging I did it would seem this is typical. Home is mapped to return to the home screen for most other windows with the idea being that multiple presses should turn on the TV regardless of what state Kodi is in (ie first press pulls it out of screensaver or other state, second press returns from whatever window your in back to the home screen third press now sends cec command to wake up). In this way a single button can get you back to the home screen and function as a power button. You can see how I mapped it [here]

But, for this to actually work it needs a few settings configured in settings>system>input>periperials>CEC adapter. In particular CEC needs to be enabled and “switch source to this device on startup” enables source switching when you CECActivateSource (so not just for startup but unfortunately will make the TV turn on during a reboot like from a power outage). This setting not being enabled may be why you get a source switch to the wrong input. You also need to set which devices to power on and off. These options dictate which devices get sent a power on command and which it should be set as depends on how those devices are configured. For example, if your AVR is set to power on/off with the TV then you only want Kodi to turn on/off your TV. If you send commands to both then you can get a situation where a TV or AVR turns on then right back off. If you have a ‘device connected to’ option and your connected to an AVR this may need to be set as such. There may be some other tweaks to be made in there for some setups but a bit of trial and error should normally get a working solution. Do note that when changing CEC settings make sure you click the “OK” button when your done as doing a back/esc will exit not save the changes or initiate a warning dialog (at least not in Estuary last I checked). Also some of the settings require a reboot to take effect but not all so it is probably best to just reboot after all changes just to be sure.

Do you have v4l-utils installed on your system? I don’t believe we provide this package by default, so you’d need to run sudo apt-get install v4l-utils first before running this command suggested by @popcornmix:

i get this:

Transmit from Recording Device 1 to TV (1 to 0):
STANDBY (0x36)
        Sequence: 48 Tx Timestamp: 36816.748s
        Tx, Not Acknowledged (4), Max Retries

So It looks like my display only goes to standby if the hdmi signal disappears not on cec commands.

Are you sure you have CEC turned on in your TV’s settings? If your not familiar it is frequently not enabled by default and doesn’t use the word “CEC”. If you do a web search for “[TV brand name] how to enable CEC” you should find the name of the option that needs to be enabled. I tested cec-ctl and that command switched my TV into standby and I could wake it back up with a cec-ctl --to 0 --image-view-on command.