28

Is there any way to programmatically turn a HDMI TV on/off on windows?

Either using an application or script/programming interface.

5
  • Does your graphics card support HDMI CEC?
    – Marki555
    May 19, 2015 at 7:59
  • let's say the card/driver supports it, how is it even exposed then? do i have to have one implementation for each video card driver in existence?!
    – gcb
    May 19, 2015 at 17:25
  • According to this question/answer superuser.com/q/569448/150695 very probably it doesn't support CEC.
    – Marki555
    May 19, 2015 at 19:23
  • @Marki555 i hope that was the case two years ago.... also, yeah, sony is know to try to abuse standards to form monopolies (betamax, blueray, minidisc, memorystick...) so it is expected that they also don't play with CEC. all my equipment is either receivers made to work with several CEC formats, or TVs from the group that fought for an open CEC standard (panasonic, etc) into the hdmi 1.0 spec...
    – gcb
    May 19, 2015 at 20:26
  • As I understand it basic CEC should work between all manufacturers. Then each one adds some non-astandard additions which won't work elsewhere and give CEC its own marketing name :)
    – Marki555
    May 20, 2015 at 10:54

3 Answers 3

19

First check if your graphics card (hardware) supports HDMI CEC. Then also the drivers must support it. But according to this review, very few cards have CEC support.

For PCs without CEC support, there exists various products which add CEC support. They connect between the PC and TV on HDMI cable plus via USB to PC. The software sends CEC commands to adapter via USB. One example of such product is: USB HDMI CEC adapter from Pulse-eight.

5
  • 1
    accepting this as this is the closes to an answer: there is zero support for CEC. the HDMI spec says: all hdmi systems must pass along pin 13. that is all. CEC protocol is bidirectional, like CANBUS on cars. since video cards are a end point, they probably don't even connect anything to pin13. I wonder why the heck it is not available via software to the host PC. it would be the perfect, and cheap, solution.
    – gcb
    May 30, 2015 at 3:37
  • 3
    HDMI on video cards can't be completely one direction because PnP detects the monitor type.
    – Jamie
    Sep 8, 2018 at 20:42
  • 1
    @Jamie via pin 13?
    – Marki555
    Sep 11, 2018 at 14:33
  • @Marki555 I don't know that, but I do know that Plug and Play detects the display type, so there must be communication from the display to the PC.
    – Jamie
    Sep 11, 2018 at 21:19
  • 1
    The RaspberryPI can do this. I think it was a 3 that I had that would do it. It might be a way to send these commands via USB if you want to take the time to program it.
    – Andrew
    Jan 12, 2021 at 22:57
5

There is a workaround to shutdown the TV (especialy samsung tvs)from the PC: over TCP/IP.

If your tv supports tcp/ip commands (nearly all Samsung tvs with network capability), you can schedule shutdown script on the pc. The script will run a python code automatically to send the "power button" interaction to the TV over TCP/IP, when you shutdown the pc. All you will need some SW;

GUIDE:

  • Install the python for windows,
  • Download the samsungctl zip,
  • Follow the installation guide on the github page to install the samsungctl,
  • Assign a static IP to your TV on TV's menu,
  • Save the following code on Notepad as shutdown.py (Don't forget to change the defined IP in the code with the TV's static IP -> "host:xxx.xxx.xxx.xxx" ) :
#!/usr/bin/env python3

import samsungctl
import time

config = {
    "name": "samsungctl",
    "description": "PC",
    "id": "",
    "host": "192.168.0.10",
    "port": 55000,
    "method": "legacy",
    "timeout": 0,
}

with samsungctl.Remote(config) as remote:
    for i in range(1):
        remote.control("KEY_POWEROFF")
        time.sleep(0.5)
  • Then create and save a batch(BAT) file like below:

"PATH of python installation folder"\python "PATH of the SHUTDOWN.PY folder"\shutdown.py

  • Then run the group policy editor and select "Group Configuration\Windows Settings\Scripts\Shutdown" and select the BAT file that you have created above.

That's it! Whenever you shutdown the PC the script will run automatically and shutdown your samsung TV over TCP/IP.

2
  • Can this not be done the other way around? Turning the TV on when the PC turns on. The reason I would actually want to do that is so that my PC can turn the TV off when it puts its screens to sleep (after the 10 minutes of inactivity I've set) and turn the TV on when it turns on the screens when I interact with it.
    – KlingL
    Oct 11, 2022 at 2:13
  • yes, there are dozen of ways. this question is about CEC. if we would list all the hacks for each manufacturer, at least use the more common, which is i2c over hdmi. or ddc. ddcutil.com/#introduction
    – gcb
    May 21 at 14:52
1

At now, Intel graphics cards still doesn't support it.

Consumer Electronic Control (CEC): Intel graphics do not support this feature.

Source: Intel: FAQ about HDMI Technology

1
  • 1
    I think when I asked this question I was indeed using a intel igpu. Since then we've been trhu amd igpu and radeon gpus. Never got CEC to work anywhere. I cannot remember last time I used windows tho.
    – gcb
    Nov 8 at 10:58

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .