JPersson77 / LGTVCompanion

Power On and Off WebOS LG TVs together with your PC
MIT License
964 stars 40 forks source link

LG C1 shut off when restarting PC IF a shutdown has been done before. #204

Closed tupac55 closed 6 months ago

tupac55 commented 6 months ago

Hi.

I'll try to explain myself the best i can.

When I boot my PC if it boot from a shutdown .. The next restart will shut off my LG C1 and open it after the restart, IF i restart again (because my PC boot from a RESTART) it doesn't shut off my TV LG C1 and so it stays open (which is the expected behavior)

if i restart again, it's still behave like it should (doesn't shut off the TV)

BUT if i shutdown my PC ... it shut off my TV (which is OK too) but then if i boot my pc and restart it then it will shut off my TV and open it after the restar (which is not good and only do this for a restart event AFTER a BOOT from a complete SHUTDOWN)

I just updated to the last 3.5.0 version to see if it fix the issue but still same

In the option the "RESTART" is tick (in french)

Here's the log ( 1- Restart was ok 2-shutdown pc 3-restart was not behave normally 4-restart was ok)

Sun 05:01:21 > LGTV Companion Service started (v 3.5.0) --------------------------- Sun 05:01:21 > Data path: C:\ProgramData\LGTV Companion\ Sun 05:01:21 > Device1, [LG] webOS TV OLED48C16LA, with IP 192.168.2.76 initiated (Enabled:yes, NewConn:yes, WOL:2, SubnetMask:255.255.255.0, PairingKey:33a04c33827dd8edb233c63b1bcbc6b5, MAC: DC:03:98:1D:C9:C6 , VerifyHdmiInput:off, SetHdmiInput:off, BlankOnIdle:on(10m)) Sun 05:01:21 > Host IP detected: 192.168.2.11/24 Sun 05:01:21 > Shutdown timing: default Sun 05:01:21 > System requests displays ON. Sun 05:01:21 > Device1, spawning Thread_DisplayOn(). Sun 05:01:21 > Device1, repeating WOL broadcast started to MAC: DC03981DC9C6 using IP address: 192.168.2.76 Sun 05:01:21 > Device1, Best route to IP - interface index 5 LUID 1689399632855040 route protocol 2 Sun 05:01:21 > -daemon 1 started Sun 05:01:21 > [IPC Daemon 1] Started. Sun 05:01:21 > Device1, [DEBUG] (SSL) ON response 1: {"type":"registered","id":"register_0","payload":{"client-key":"33a04c33827dd8edb233c63b1bcbc6b5"}} Sun 05:01:21 > Device1, [DEBUG] (SSL) ON response 2: {"type":"error","id":1,"error":"500 Application error","payload":{"returnValue":false,"state":"Active","errorCode":"-102","errorText":"The current state must be 'Screen Off'"}} Sun 05:01:21 > Device1, [DEBUG] (SSL) ON response 3: {"type":"response","id":2,"payload":{"returnValue":true,"state":"Active"}} Sun 05:01:21 > Device1, power state is: ON Sun 05:01:22 > Device1, repeating WOL broadcast ended Sun 05:01:26 > Event subscription callback: System restart detected. Sun 05:01:27 > System is restarting. Sun 05:01:29 > The service terminated.

Sun 05:01:51 > LGTV Companion Service started (v 3.5.0) --------------------------- Sun 05:01:51 > Data path: C:\ProgramData\LGTV Companion\ Sun 05:01:51 > Device1, [LG] webOS TV OLED48C16LA, with IP 192.168.2.76 initiated (Enabled:yes, NewConn:yes, WOL:2, SubnetMask:255.255.255.0, PairingKey:33a04c33827dd8edb233c63b1bcbc6b5, MAC: DC:03:98:1D:C9:C6 , VerifyHdmiInput:off, SetHdmiInput:off, BlankOnIdle:on(10m)) Sun 05:01:51 > Shutdown timing: default Sun 05:01:51 > System requests displays ON. Sun 05:01:51 > Device1, spawning Thread_DisplayOn(). Sun 05:01:51 > Device1, repeating WOL broadcast started to MAC: DC03981DC9C6 using IP address: 192.168.2.76 Sun 05:01:51 > Device1, Best route to IP - failed with code 1231 Sun 05:01:51 > Device1, WARNING! Thread_WOL WS sendto(): 10051 Sun 05:01:51 > Device1, WARNING! Thread_DisplayOn(): connect: Une op ration a t tent e sur un r seau impossible atteindre [system:10051 at D:\a\LGTVCompanion\LGTVCompanion\vcpkg_installed\x64-windows-static\x64-windows-static\include\boost\asio\detail\win_iocp_socket_service.hpp:629:5 in function 'connect'] Sun 05:01:52 > Device1, Best route to IP - interface index 5 LUID 1689399632855040 route protocol 2 Sun 05:01:52 > Device1, [DEBUG] (SSL) ON response 1: {"type":"registered","id":"register_0","payload":{"client-key":"33a04c33827dd8edb233c63b1bcbc6b5"}} Sun 05:01:52 > Device1, [DEBUG] (SSL) ON response 2: {"type":"error","id":1,"error":"500 Application error","payload":{"returnValue":false,"state":"Active","errorCode":"-102","errorText":"The current state must be 'Screen Off'"}} Sun 05:01:52 > Device1, [DEBUG] (SSL) ON response 3: {"type":"response","id":2,"payload":{"returnValue":true,"state":"Active"}} Sun 05:01:52 > Device1, power state is: ON Sun 05:01:53 > Device1, repeating WOL broadcast ended Sun 05:02:03 > -daemon 1 started Sun 05:02:03 > [IPC Daemon 1] Started. Sun 05:02:30 > Event subscription callback: system shut down detected. Sun 05:02:31 > System requests displays OFF. Sun 05:02:31 > Device1, spawning Thread_DisplayOff(). Sun 05:02:31 > Device1, [DEBUG] (SSL) OFF response 1: {"type":"registered","id":"register_0","payload":{"client-key":"33a04c33827dd8edb233c63b1bcbc6b5"}} Sun 05:02:31 > Device1, [DEBUG] (SSL) OFF response 2: {"type":"response","id":4,"payload":{"returnValue":true,"state":"Active"}} Sun 05:02:31 > Host IP detected: 192.168.2.11/24 Sun 05:02:31 > Device1, [DEBUG] (SSL) OFF response 4: {"type":"response","id":5,"payload":{"returnValue":true}} Sun 05:02:31 > Device1, power state is: OFF. Sun 05:02:32 > System is shutting down (low power mode). Sun 05:02:59 > System resumed from low power state. Sun 05:02:59 > System resumed from low power state (Automatic). Sun 05:02:59 > System requests displays ON. Sun 05:02:59 > Device1, spawning Thread_DisplayOn(). Sun 05:02:59 > Device1, repeating WOL broadcast started to MAC: DC03981DC9C6 using IP address: 192.168.2.76 Sun 05:02:59 > Device1, Best route to IP - interface index 5 LUID 1689399632855040 route protocol 2 Sun 05:03:10 > -daemon 2 started Sun 05:03:10 > [IPC Daemon 2] Started. Sun 05:03:21 > Device1, WARNING! Thread_DisplayOn(): connect: Une tentative de connexion a chou car le parti connect n a pas r pondu convenablement au-del d une certaine dur e ou une connexion tablie a chou car l h te de connexion n a pas r pondu [system:10060 at D:\a\LGTVCompanion\LGTVCompanion\vcpkg_installed\x64-windows-static\x64-windows-static\include\boost\asio\detail\win_iocp_socket_service.hpp:629:5 in function 'connect'] Sun 05:03:21 > Device1, [DEBUG] (SSL) ON response 1: {"type":"registered","id":"register_0","payload":{"client-key":"33a04c33827dd8edb233c63b1bcbc6b5"}} Sun 05:03:21 > Device1, [DEBUG] (SSL) ON response 2: {"type":"error","id":6,"error":"500 Application error","payload":{"returnValue":false,"state":"Active","errorCode":"-102","errorText":"The current state must be 'Screen Off'"}} Sun 05:03:21 > Device1, [DEBUG] (SSL) ON response 3: {"type":"response","id":7,"payload":{"returnValue":true,"state":"Active"}} Sun 05:03:21 > Device1, power state is: ON Sun 05:03:22 > Device1, repeating WOL broadcast ended Sun 05:03:31 > WARNING! The application did not receive an Event Subscription Callback prior to system shutting down. Unable to determine if system is shutting down or restarting. Sun 05:03:31 > Device1, spawning Thread_DisplayOff(). Sun 05:03:31 > Device1, [DEBUG] (SSL) OFF response 1: {"type":"registered","id":"register_0","payload":{"client-key":"33a04c33827dd8edb233c63b1bcbc6b5"}} Sun 05:03:31 > Device1, [DEBUG] (SSL) OFF response 2: {"type":"response","id":9,"payload":{"returnValue":true,"state":"Active"}} Sun 05:03:31 > Device1, [DEBUG] (SSL) OFF response 4: {"type":"response","id":10,"payload":{"returnValue":true}} Sun 05:03:31 > Device1, power state is: OFF. Sun 05:03:33 > The service terminated.

Sun 05:03:52 > LGTV Companion Service started (v 3.5.0) --------------------------- Sun 05:03:52 > Data path: C:\ProgramData\LGTV Companion\ Sun 05:03:52 > Device1, [LG] webOS TV OLED48C16LA, with IP 192.168.2.76 initiated (Enabled:yes, NewConn:yes, WOL:2, SubnetMask:255.255.255.0, PairingKey:33a04c33827dd8edb233c63b1bcbc6b5, MAC: DC:03:98:1D:C9:C6 , VerifyHdmiInput:off, SetHdmiInput:off, BlankOnIdle:on(10m)) Sun 05:03:52 > Shutdown timing: default Sun 05:03:52 > System requests displays ON. Sun 05:03:52 > Device1, spawning Thread_DisplayOn(). Sun 05:03:52 > Device1, repeating WOL broadcast started to MAC: DC03981DC9C6 using IP address: 192.168.2.76 Sun 05:03:52 > Device1, Best route to IP - failed with code 1231 Sun 05:03:52 > Device1, WARNING! Thread_WOL WS sendto(): 10051 Sun 05:03:52 > Device1, WARNING! Thread_DisplayOn(): connect: Une op ration a t tent e sur un r seau impossible atteindre [system:10051 at D:\a\LGTVCompanion\LGTVCompanion\vcpkg_installed\x64-windows-static\x64-windows-static\include\boost\asio\detail\win_iocp_socket_service.hpp:629:5 in function 'connect'] Sun 05:03:53 > Device1, Best route to IP - interface index 5 LUID 1689399632855040 route protocol 2 Sun 05:04:04 > -daemon 1 started Sun 05:04:04 > [IPC Daemon 1] Started. Sun 05:04:14 > Device1, WARNING! Thread_DisplayOn(): connect: Une tentative de connexion a chou car le parti connect n a pas r pondu convenablement au-del d une certaine dur e ou une connexion tablie a chou car l h te de connexion n a pas r pondu [system:10060 at D:\a\LGTVCompanion\LGTVCompanion\vcpkg_installed\x64-windows-static\x64-windows-static\include\boost\asio\detail\win_iocp_socket_service.hpp:629:5 in function 'connect'] Sun 05:04:14 > Device1, [DEBUG] (SSL) ON response 1: {"type":"registered","id":"register_0","payload":{"client-key":"33a04c33827dd8edb233c63b1bcbc6b5"}} Sun 05:04:14 > Device1, [DEBUG] (SSL) ON response 2: {"type":"error","id":1,"error":"500 Application error","payload":{"returnValue":false,"state":"Active","errorCode":"-102","errorText":"The current state must be 'Screen Off'"}} Sun 05:04:14 > Device1, [DEBUG] (SSL) ON response 3: {"type":"response","id":2,"payload":{"returnValue":true,"state":"Active"}} Sun 05:04:14 > Device1, power state is: ON Sun 05:04:15 > Device1, repeating WOL broadcast ended Sun 05:04:41 > Event subscription callback: System restart detected. Sun 05:04:47 > System is restarting. Sun 05:04:48 > Host IP detected: 192.168.2.11/24 Sun 05:04:49 > The service terminated.

Sun 05:05:11 > LGTV Companion Service started (v 3.5.0) --------------------------- Sun 05:05:11 > Data path: C:\ProgramData\LGTV Companion\ Sun 05:05:11 > Device1, [LG] webOS TV OLED48C16LA, with IP 192.168.2.76 initiated (Enabled:yes, NewConn:yes, WOL:2, SubnetMask:255.255.255.0, PairingKey:33a04c33827dd8edb233c63b1bcbc6b5, MAC: DC:03:98:1D:C9:C6 , VerifyHdmiInput:off, SetHdmiInput:off, BlankOnIdle:on(10m)) Sun 05:05:11 > Shutdown timing: default Sun 05:05:11 > ** System requests displays ON. Sun 05:05:11 > Device1, spawning Thread_DisplayOn(). Sun 05:05:11 > Device1, repeating WOL broadcast started to MAC: DC03981DC9C6 using IP address: 192.168.2.76 Sun 05:05:11 > Device1, Best route to IP - failed with code 1231 Sun 05:05:11 > Device1, WARNING! Thread_WOL WS sendto(): 10051 Sun 05:05:11 > Device1, WARNING! Thread_DisplayOn(): connect: Une op ration a t tent e sur un r seau impossible atteindre [system:10051 at D:\a\LGTVCompanion\LGTVCompanion\vcpkg_installed\x64-windows-static\x64-windows-static\include\boost\asio\detail\win_iocp_socket_service.hpp:629:5 in function 'connect'] Sun 05:05:12 > Device1, Best route to IP - interface index 5 LUID 1689399632855040 route protocol 2 Sun 05:05:12 > Device1, [DEBUG] (SSL) ON response 1: {"type":"registered","id":"register_0","payload":{"client-key":"33a04c33827dd8edb233c63b1bcbc6b5"}} Sun 05:05:12 > Device1, [DEBUG] (SSL) ON response 2: {"type":"error","id":1,"error":"500 Application error","payload":{"returnValue":false,"state":"Active","errorCode":"-102","errorText":"The current state must be 'Screen Off'"}} Sun 05:05:12 > Device1, [DEBUG] (SSL) ON response 3: {"type":"response","id":2,"payload":{"returnValue":true,"state":"Active"}} Sun 05:05:12 > Device1, power state is: ON Sun 05:05:13 > Device1, repeating WOL broadcast ended Sun 05:05:23 > -daemon 1 started Sun 05:05:23 > [IPC Daemon 1] Started.

JPersson77 commented 6 months ago

hi @tupac55 I understand from your description the issue is that, on your system the first restart event after a fresh boot (resume from low power actually according to the log) always fails, in the sense that the TV will power off instead of remaining on during the restart.

I think the key takeaway from the log is that the system, for some reason, did not write the required info to the event log, which caused that the app could not determine if it was a shutdown or restart and thus default behavior was initiated, i.e. to power off the TV.

Sun 05:03:31 > WARNING! The application did not receive an Event Subscription Callback prior to system shutting down. Unable to determine if system is shutting down or restarting.

So in a sense there may not much to be done. Microsoft does not guarantee that the required info is written to the event log on shutdown/reboot unfortunately. But it is weird if this is a repeatable pattern, and I think you say that this is reproducible on your system, right? If you open the event viewer and filter the system log for event id 1074 - do you have an event at the approximate time of '05.03.31'?

It does surprise me that you would have to tick "restart" (in french) in the options though as that should be automatic in v3.5.0 for french. Would you mind posting your config.json too?

tupac55 commented 6 months ago

It was automatic on 3.5.0, but as i had 3.4.0 before and 3.3.3 before that too i enabled manually on these. Where' can i find the config.json so i can post to you ?

For event viewer i have these :

at : 05:01:25 Le processus C:\Windows\System32\RuntimeBroker.exe (TIMURPC) a lancé le Redémarrer de l’ordinateur TIMURPC pour l’utilisateur TIMURPC\tyild pour la raison suivante : Autre (non planifié) Code : 0x0 Type d’extinction : Redémarrer Commentaire :

at 05:02:29

Le processus C:\Windows\System32\RuntimeBroker.exe (TIMURPC) a lancé le se mettre hors tension. de l’ordinateur TIMURPC pour l’utilisateur TIMURPC\tyild pour la raison suivante : Autre (non planifié) Code : 0x0 Type d’extinction : se mettre hors tension. Commentaire :

at 05:04:40

Le processus C:\Windows\System32\RuntimeBroker.exe (TIMURPC) a lancé le Redémarrer de l’ordinateur TIMURPC pour l’utilisateur TIMURPC\tyild pour la raison suivante : Autre (non planifié) Code : 0x0 Type d’extinction : Redémarrer Commentaire :

I have nothing at 05:03:31 exactly

JPersson77 commented 6 months ago

Hi again,

Thanks! config.json is in c:/programdata/lgtv companion/

It looks like there was nothing written in the event log so that is why the app fall back to powering the screen off. Unfortunately there is not a more straightforwad way to determine if the system is restarting or shutting down.

Is this 100% reproducible on your system (first restart event after a cold boot does not write an event in the event log)?

tupac55 commented 6 months ago

Hi,

{ "Device1": { "Enabled": true, "HDMIinputcontrol": false, "IP": "192.168.2.76", "MAC": [ "DC:03:98:1D:C9:C6" ], "Name": "[LG] webOS TV OLED48C16LA", "NewSockConnect": true, "OnlyTurnOffIfCurrentHDMIInputNumberIs": 4, "SessionKey": "33a04c33827dd8edb233c63b1bcbc6b5", "SetHDMIInputOnResume": false, "SetHDMIInputOnResumeToNumber": 4, "Subnet": "255.255.255.0", "UniqueDeviceKey": "\\?\DISPLAY#GSMC0C8#7&2d1f1eec&0&UID264#{e6f07b5f-ee97-4a90-b076-33f57bf4eaa7}", "WOL": 2 }, "LGTV Companion": { "AdhereDisplayTopology": false, "AutoUpdate": true, "BlankWhenIdle": true, "BlankWhenIdleDelay": 10, "ExtendedLog": false, "ExternalAPI": false, "IdleFsExclusionsEnabled": false, "IdleFullscreen": false, "IdleWhiteListEnabled": false, "KeepTopologyOnBoot": false, "LocalEventLogRestartString": [ "Redémarrer" ], "LocalEventLogShutdownString": [ "se mettre hors tension." ], "MuteSpeakers": false, "PowerOnTimeOut": 40, "RemoteStream": false, "RemoteStreamPowerOff": true, "TimingPreshutdown": false, "Version": 2 } }

here's the config.json

It is 100% reproducible (because it's something that i've try to fix like for 2 month on my free time) but i think i just found the culprit ! I disabled fast startup in my power plan in config pannel and it seems that now it behave as it should ! I'll try 1 more day like that to be sure it's not a fluke and i'll feedback here.

JPersson77 commented 6 months ago

Thanks, I had a suspicion as well that it might have to do with fast startup. But not sure why it would cause the issue. But at least I can see if I can reproduce

(I always disable fast startup)

tupac55 commented 6 months ago

I've tested few more times and i can confirm that disabling fast startup fixed the issue for me.

Usually i disable fast startup too but i've done a clean format windows like 2 month ago and didn't disabled it since.. Can you reproduce the issue on your side with fast startup enabled ?

JPersson77 commented 6 months ago

Yep I can confirm. Same issue as you are describing.

I don't know if i can find some way to manage this, but it seems likely then that windows does not write to the event log in this particaular case.

I will add it as a troubleshooting step in the readme

tupac55 commented 6 months ago

No problem, then we can close this issue as there's a workaround for it 👍