Reputation: 19
I have a really annoying SONY android TV. The device just does not want to turn off when there is no signal via HDMI. I have also a mini PC connected to it and in majority of time the TV just works as a monitor. Now when the PC goes to sleep, the TV keeps the screen on and has a message there - no signal...
(Yes I know I should buy another TV, but this is not an option).
I decided to take some actions, and at least turn the TV off when the PC goes to sleep.
My first idea was to go with the DDC/CI way, but the TV does not have a setting to enable it, and does not react to the actual commands.
So since it is an android TV i got an idea to connect via adb via WiFi and send a shutdown command:
adb shell input keyevent KEYCODE_POWER
Tried this manually from command line - so far so good, the TV accepts the command and turns off.
But here comes the harder part, on Windows 10 I'm (only) able to detect user presence via:
User32.dll and GetLastInputInfo()
But this is not enough as I may watch a video (vlc, chrome, etc) In this case there is no user input, but the system is kept awake by the video player. So I need to know when something is blocking the Windows from sleep.
I searched and I found:
Win32_DesktopMonitor
and ManagementObject
but accessing properties field throws an exception. I would need to access result[n].Properties["Availability"]
.But later I came across this:
https://learn.microsoft.com/en-us/windows-hardware/design/device-experiences/display--sleep--and-hibernate-idle-timers
which suggest that 'Turn off the display timer' does exist. Although I'm unable to find any example how to access it. I also got across that if you actually want windows to prevent from sleep you need to use SetThreadExecutionState
. OK but how to read this ? I actually tried to list all the processes and search for such flags, but either I'm unable to find them or they are not there at all.
Then I came across a command line command: powercfg /requests
which provides me with the info what i need, but this would mean string parsing and more importantly to run the app under admin rights which I would like to avoid.
So my questions:
Thank You very much if you managed to read through, and even more if you are able to provide some clues.
Update:
I found out that the 2) is probably impossible: Possible to find all Windows processes preventing automatic sleep, w/o admin rights?
Upvotes: 0
Views: 1306
Reputation: 19
I realized that the mentioned TV (kd-49xf7596) has also a possibility to be controlled via network (so called IP control).
https://pro-bravia.sony.net/develop/integrate/rest-api/spec/index.html
Reading the doc. I would say this API provides me with all the info which I need:
getPowerStatus (v1.0)
and setPowerStatus (v1.0)
getPlayingContentInfo (v1.0)
getCurrentExternalInputsStatus (v1.1)
UPDATE: if anybody is interested it is now a working prototype:
https://github.com/tomix89/sony-stopper
Upvotes: 1