Kodi Community Forum

Full Version: Turn on/off TV and Kodi PC with one button
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I would like to turn a whole system (Kodi PC + TV) on and off with one (power) button on a remote control. It seems to be a pretty basic scenario that should work like a clock for a HTPC system.
I have the following equipment:
- an URC-6440 remote control;
- a FLIRC-SE adapter;
- a Pulse-Eight USB-CEC adapter;
- a Windows 10 based PC + Kodi v17.6;
- a HDMI CEC capable TV.
I've mapped a power button of the remote control to control a power button of the HTPC. When I press the power button on the remote, this starts HTPC, loads Windows and Kodi that sends a CEC command to turn the TV on. It works and I'm happy.
But there is an issue with turning that system off. When I press the same power button on the remote again, the OS quickly goes to a sleep or shutdown state depending on a power plan. I don't know what Kodi is doing at the moment, but it doesn't turn the TV off as I expect. It seems that Kodi misses some system power events. So, it doesn't work and makes me sad.
I will note that Kodi successfully turns the TV off when Exit is chosen from the Kodi's menu, but this is not what I need.
Is there a way to make it work?
Is there any 3rd-party app to control a TV's power by tracking a system power state?
Taking the " a Pulse-Eight USB-CEC adapter " out of the equation, we can shut down the PC using the Kodi power switch as long as in settings>system>power savings>shutdown funtion> is set to 'Shutdown'. Start-up is a matter of using a PC wake-up on signal (if sleeping) or some power toggle that would be offered by your specific manufacturer in the hardware, and Kodi would be in the start-up procedures, and it appears you have achieved this with success.

At this point, turning on & off the TV becomes the issue. You didn't mention if there is an AVR (with CEC) in the middle of all of this which complicates the issue quite a bit. Most  graphics cards do not support CEC in any form, and others only in a limited form. The Pulse Eight (SE version?) allows Kodi and libCEC to access the CEC communications link of your TV and send and receive control messages and in that is were the issue lies. I suggest you contact https://www.pulse-eight.com/Contact and see if they have a workable solution. " seems that Kodi misses some system power events. So, it doesn't work and makes me sad." You know the song "Be Happy" by Bobby McFerrin

A proper debug log will show the keypress from your remote, and indicate what the command is being sent, which could help isolating the failure, if there is one.
(2018-01-16, 20:36)PatK Wrote: [ -> ]Taking the " a Pulse-Eight USB-CEC adapter " out of the equation, we can shut down the PC using the Kodi power switch as long as in settings>system>power savings>shutdown funtion> is set to 'Shutdown'
I think it will make the task harder. It's simpler to control the whole system power by one button than the Kodi power.
I would be simpler to take the FLIRC out of the equation. So, there is no remote, just a power button on the PC.
 
(2018-01-16, 20:36)PatK Wrote: [ -> ]Start-up is a matter of using a PC wake-up on signal (if sleeping) or some power toggle that would be offered by your specific manufacturer in the hardware, and Kodi would be in the start-up procedures, and it appears you have achieved this with success.
There is no issue with startup, it works fine. Kodi sends a CEC command to turn on the TV on startup.
 
(2018-01-16, 20:36)PatK Wrote: [ -> ]You didn't mention if there is an AVR (with CEC) in the middle of all of this which complicates the issue quite a bit.
No, there is no an AVR. There is just a CEC compliant TV.
 
(2018-01-16, 20:36)PatK Wrote: [ -> ]A proper debug log will show the keypress from your remote, and indicate what the command is being sent, which could help isolating the failure, if there is one.
It's good idea.
Kodi successfully turns the TV off when I choose Exit from the Kodi's menu, but it fails when the whole OS is going to a sleep or shutdown state after pressing the power button. The issue can be either on Kodi side or in the Pulse Eight CEC driver.
If you find a work-round, I'm sure the user base would love to hear from you. There's a lot of complaints of software issues after sleep mode bringing back corrupted software, so I like the total restart (using the 'Shutdown' PC using Kodi) from a fresh boot and would take it from that point. The Flirc shoudn't be an issue, it's just passing along keypresses, so all you need is the Pulse Eight to turn off the TV.
Another option is to use a Harmony remote.  Then you can control any hardware and software at will with one button push.
I've caught two logs.
The first one catches the scenario with Kodi Power Menu > Exit. Kodi successfully turns TV off in that case.
Image

The second one catches the scenario with Windows Power > Reboot. Kodi doesn't turn TV off in that case.

Here are all the lines that mention CEC:
Code:

#1
17:01:59.833 T:6852   DEBUG: PERIPHERALS::CPeripherals::LoadMappings - loaded node "CEC Adapter"
17:01:59.833 T:6852   DEBUG: PERIPHERALS::CPeripherals::LoadMappings - loaded node "Pulse-Eight CEC Adapter"
17:01:59.833 T:6852   DEBUG: SECTION:LoadDLL(special://xbmcbin/cec.dll)
17:01:59.865 T:8336   DEBUG: Thread PeripBusCEC start, auto delete: false
17:01:59.866 T:8336   DEBUG: PERIPHERALS::CPeripherals::GetMappingForDevice - device (2548:1002) mapped to CEC Adapter (type = cec)
17:01:59.866 T:8336   DEBUG: PERIPHERALS::CPeripherals::GetMappingForDevice - device (2548:1002) mapped to CEC Adapter (type = cec)
17:01:59.889 T:8336   DEBUG: PERIPHERALS::CPeripheralCecAdapter::InitialiseFeature - using libCEC v4.0.1
17:01:59.889 T:8336   DEBUG: PERIPHERALS::CPeripheralCecAdapter::InitialiseFeature - using libCEC v4.0.1
17:01:59.889 T:8336  NOTICE: PERIPHERALS::CPeripheralBus::Register - new cec device registered on cec->COM3: CEC Adapter (2548:1002)
17:01:59.889 T:8336  NOTICE: PERIPHERALS::CPeripheralBus::Register - new cec device registered on cec->COM3: CEC Adapter (2548:1002)
17:01:59.889 T:8336  NOTICE: PERIPHERALS::CPeripheralBus::Register - new cec device registered on cec->COM3: CEC Adapter (2548:1002)
17:01:59.889 T:7240   DEBUG: PERIPHERALS::CPeripherals::GetMappingForDevice - device (2548:1002) mapped to Pulse-Eight CEC Adapter (type = cec)
17:01:59.889 T:7240   DEBUG: PERIPHERALS::CPeripherals::GetMappingForDevice - device (2548:1002) mapped to Pulse-Eight CEC Adapter (type = cec)
17:01:59.889 T:5788   DEBUG: Thread CECAdapter start, auto delete: false
17:01:59.889 T:5788   DEBUG: PERIPHERALS::CPeripheralCecAdapter::OpenConnection - opening a connection to the CEC adapter: COM3
17:01:59.889 T:5788   DEBUG: PERIPHERALS::CPeripheralCecAdapter::OpenConnection - opening a connection to the CEC adapter: COM3
17:02:01.082 T:5788   DEBUG: PERIPHERALS::CPeripheralCecAdapter::OpenConnection - connection to the CEC adapter opened
17:02:01.082 T:5788   DEBUG: PERIPHERALS::CPeripheralCecAdapter::OpenConnection - connection to the CEC adapter opened
17:02:01.082 T:9124   DEBUG: Thread CECAdapterUpdate start, auto delete: false
17:02:01.174 T:7240   DEBUG: PERIPHERALS::CPeripherals::GetMappingForDevice - device (2548:1002) mapped to Pulse-Eight CEC Adapter (type = cec)
17:02:01.174 T:7240   DEBUG: PERIPHERALS::CPeripherals::GetMappingForDevice - device (2548:1002) mapped to Pulse-Eight CEC Adapter (type = cec)
17:02:01.333 T:9124   DEBUG: PERIPHERALS::CPeripheralCecAdapterUpdateThread::UpdateMenuLanguage - using TV menu language is disabled
17:02:02.231 T:9124   DEBUG: PERIPHERALS::CPeripheralCecAdapterUpdateThread::UpdateAudioSystemStatus - no CEC capable amplifier found
17:02:02.231 T:9124   DEBUG: PERIPHERALS::CPeripheralCecAdapterUpdateThread::UpdateAudioSystemStatus - no CEC capable amplifier found
17:02:06.175 T:7240   DEBUG: PERIPHERALS::CPeripherals::GetMappingForDevice - device (2548:1002) mapped to Pulse-Eight CEC Adapter (type = cec)
17:02:06.175 T:7240   DEBUG: PERIPHERALS::CPeripherals::GetMappingForDevice - device (2548:1002) mapped to Pulse-Eight CEC Adapter (type = cec)
17:02:11.176 T:7240   DEBUG: PERIPHERALS::CPeripherals::GetMappingForDevice - device (2548:1002) mapped to Pulse-Eight CEC Adapter (type = cec)
17:02:11.176 T:7240   DEBUG: PERIPHERALS::CPeripherals::GetMappingForDevice - device (2548:1002) mapped to Pulse-Eight CEC Adapter (type = cec)
17:02:14.739 T:9124   DEBUG: Thread CECAdapterUpdate 9124 terminating
17:02:14.739 T:5788   DEBUG: PERIPHERALS::CPeripheralCecAdapter::Process - sending standby commands
17:02:15.803 T:5788   DEBUG: PERIPHERALS::CPeripheralCecAdapter::Process - CEC adapter processor thread ended
17:02:15.803 T:5788   DEBUG: PERIPHERALS::CPeripheralCecAdapter::Process - CEC adapter processor thread ended
17:02:15.803 T:5788   DEBUG: Thread CECAdapter 5788 terminating
17:02:15.851 T:8336   DEBUG: Thread PeripBusCEC 8336 terminating

#2
17:03:33.305 T:7416   DEBUG: PERIPHERALS::CPeripherals::LoadMappings - loaded node "CEC Adapter"
17:03:33.305 T:7416   DEBUG: PERIPHERALS::CPeripherals::LoadMappings - loaded node "Pulse-Eight CEC Adapter"
17:03:33.305 T:7416   DEBUG: SECTION:LoadDLL(special://xbmcbin/cec.dll)
17:03:33.310 T:2472   DEBUG: Thread PeripBusCEC start, auto delete: false
17:03:33.311 T:2472   DEBUG: PERIPHERALS::CPeripherals::GetMappingForDevice - device (2548:1002) mapped to CEC Adapter (type = cec)
17:03:33.311 T:2472   DEBUG: PERIPHERALS::CPeripherals::GetMappingForDevice - device (2548:1002) mapped to CEC Adapter (type = cec)
17:03:33.311 T:2472   DEBUG: PERIPHERALS::CPeripheralCecAdapter::InitialiseFeature - using libCEC v4.0.1
17:03:33.311 T:2472   DEBUG: PERIPHERALS::CPeripheralCecAdapter::InitialiseFeature - using libCEC v4.0.1
17:03:33.311 T:2472  NOTICE: PERIPHERALS::CPeripheralBus::Register - new cec device registered on cec->COM3: CEC Adapter (2548:1002)
17:03:33.311 T:2472  NOTICE: PERIPHERALS::CPeripheralBus::Register - new cec device registered on cec->COM3: CEC Adapter (2548:1002)
17:03:33.311 T:2472  NOTICE: PERIPHERALS::CPeripheralBus::Register - new cec device registered on cec->COM3: CEC Adapter (2548:1002)
17:03:33.311 T:3000   DEBUG: PERIPHERALS::CPeripherals::GetMappingForDevice - device (2548:1002) mapped to Pulse-Eight CEC Adapter (type = cec)
17:03:33.311 T:3000   DEBUG: PERIPHERALS::CPeripherals::GetMappingForDevice - device (2548:1002) mapped to Pulse-Eight CEC Adapter (type = cec)
17:03:33.311 T:8156   DEBUG: Thread CECAdapter start, auto delete: false
17:03:33.311 T:8156   DEBUG: PERIPHERALS::CPeripheralCecAdapter::OpenConnection - opening a connection to the CEC adapter: COM3
17:03:33.311 T:8156   DEBUG: PERIPHERALS::CPeripheralCecAdapter::OpenConnection - opening a connection to the CEC adapter: COM3
17:03:34.505 T:8156   DEBUG: PERIPHERALS::CPeripheralCecAdapter::OpenConnection - connection to the CEC adapter opened
17:03:34.505 T:8156   DEBUG: PERIPHERALS::CPeripheralCecAdapter::OpenConnection - connection to the CEC adapter opened
17:03:34.505 T:1316   DEBUG: Thread CECAdapterUpdate start, auto delete: false
17:03:34.755 T:1316   DEBUG: PERIPHERALS::CPeripheralCecAdapterUpdateThread::UpdateMenuLanguage - using TV menu language is disabled
17:03:35.653 T:1316   DEBUG: PERIPHERALS::CPeripheralCecAdapterUpdateThread::UpdateAudioSystemStatus - no CEC capable amplifier found
17:03:35.653 T:1316   DEBUG: PERIPHERALS::CPeripheralCecAdapterUpdateThread::UpdateAudioSystemStatus - no CEC capable amplifier found
17:03:38.346 T:3000   DEBUG: PERIPHERALS::CPeripherals::GetMappingForDevice - device (2548:1002) mapped to Pulse-Eight CEC Adapter (type = cec)
17:03:38.346 T:3000   DEBUG: PERIPHERALS::CPeripherals::GetMappingForDevice - device (2548:1002) mapped to Pulse-Eight CEC Adapter (type = cec)
17:03:43.347 T:3000   DEBUG: PERIPHERALS::CPeripherals::GetMappingForDevice - device (2548:1002) mapped to Pulse-Eight CEC Adapter (type = cec)
17:03:43.347 T:3000   DEBUG: PERIPHERALS::CPeripherals::GetMappingForDevice - device (2548:1002) mapped to Pulse-Eight CEC Adapter (type = cec)
17:03:48.348 T:3000   DEBUG: PERIPHERALS::CPeripherals::GetMappingForDevice - device (2548:1002) mapped to Pulse-Eight CEC Adapter (type = cec)
17:03:48.348 T:3000   DEBUG: PERIPHERALS::CPeripherals::GetMappingForDevice - device (2548:1002) mapped to Pulse-Eight CEC Adapter (type = cec)
It seems Kodi doesn't react to system shutdown.