Kodi Community Forum

Full Version: Do the PVR manager react on Kodi "standby" state?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
Hi all

in a previous thread (http://forum.kodi.tv/showthread.php?tid=...pid2002734) we discussed the following problem:

A raspi running openelec & Kodi Helix has a headless vdr server as backend, controlled by the TV remote control via HDMI-CEC. The problem is that the remote server won't shutdown as it is permanently triggered by EPG requests.

The hope was now that this can somehow be controlled/stopped by a "standby" mode, which can be started according to a setting item in the CEC adaptor, which says "set Kodi into standby when the TV is switched off".

Some trials (see a.m. thread), shows that the TV off signal is been received and also handled (at least for another variant of the a.m. setting "Turn Kodi off when TV is switched off"), but there is neither any indication in the log files nor any reaction in the PVR manager, when requesting these mysterious standby mode.

Does anybody know, what this standby mode means and if it has any effect on the PVR manager (means stop him from requesting EPG data to let the remote server fall asleep)?

any idea is appreciated Confused

Cheers
Steffen
(Please refer again to the parallel discussion in http://forum.kodi.tv/showthread.php?tid=...pid2003110)

Hello Ksooo

many thanks for your explanation.
So to summarize: The CEC TV status is not handled as an status flag as such, it has only the more or less dramatic effect (depends on the setting) to either suspend to RAM (with seems not to work on my raspi B1) or shutdown the raspi completely.

So to solve my problem with the not-sleeping server, I would need either a) to ask the author of the PVR-manager to listen to the CEC TV status flag to stop all external communication temporarily, or b) to find out if on a raspi hardware something strange exist like "wakeup on CEC", similar to "wakeup on Lan"

For b) I can ask Google,
but for a) I would need to contact the author of the PVR manager.

Hello PVR manager, are you somewhere out there ? Angel
Hi,

I completely agree to your summery.

I'm not the maintainer of the PVR manager, but have some insights in the code. To my best knowledge, implementation of "make PVR manager stop all external communication" will not be trivial, because PVR has no knowledge about what the add-ons actually do internally. So, no hope for a quick fix for the problem, at least from my point of view.

Imo, what you actually want is raspi going to suspend to RAM / shut down when TV is switched off. This is how "big" HTPCs behave. No idea, whether this is possible with the raspi, though.
Hi
after some google exercises I can say:

no, the raspi can not be waken by CEC, but that's not a big surprise, so it need to be done by software, somehow...

Unfortunaly I'm not familar with the Kodi internal structures. Is there any way for example to add a hook script, which listens to the CEC state changes and activate/deactivates the whole PVR manager in line with the TV state??

But maybe I'm just thinking totally in the wrong direction and there's already a simple process in place - how do get all the others their f##king remote server off? Wink

Cheers
Steffen
To all who like to know, an update:
After some trials it now looks as if the following approach could help:
I can read the TV state with cec-client. When ever the TV goes off, I can shut off the kodi process with systemctl.
Then waiting with cec-client that the TV goes on again and then starting kodi again.

That seems to work fine, but with one unsolved problem: As soon as I use cec-client to identify the TV state, that "takes away" the connection between the TV remote and kodi, and I can't control kodi anymore with the remote. That's not a problem when kodi is restarted afterwards during a normal restart, but during the normal operation while I'm waiting that the TV goes off.

So as next I need to get this fixed somehow, but this is likely more a openelec as a kodi problem, I guess...?
Hi Ksooo,
as I found in the source history, you've worked on that particular source too, so maybe you can help me on this again Wink

I followed down the sources to figure out how a CEC "tv goes off" event it handled:
When the TV is switched off and the CEC settings are set to "Go into standby", then the PeripheralCECAdapter calls a ExecuteXBMCAction("Suspend") (https://github.com/xbmc/xbmc/blob/faf2e3...r.cpp#L665)

In the ExecuteXBMCAction(), this event is evaluated and identified first as BuildIn - , and then as SystemPowerdown- command (https://github.com/xbmc/xbmc/blob/56a28e....cpp#L4097)

where I wonder, btw, why the condition there says "if ( !CBuiltins::IsSystemPowerdownCommand( " but not if ( CBuiltins::IsSystemPowerdownCommand" (it's negated..?)


which finally ends up in a CApplicationMessenger::Get().Suspend(); call (https://github.com/xbmc/xbmc/blob/e1da27...s.cpp#L337

which obviously does not make any further actions (I did not deeper checked it), as a raspi don't have a suspend mode


but up to there I didn't found any chance to place any custom action in it; also the .config/shutdown.sh (http://wiki.openelec.tv/index.php/Autostart.sh) is not called, as probably Kodi decides somewhere in CApplicationMessenger::Get().Suspend(), that there's nothing to suspend.. When setting CEC to "turn Kodi off when the TV goes off", then shutdown.sh is called, but not, as said, when CEC requests the (non-existing) suspend mode.


So I'm slowly running out of ideas from where to get the CEC information about the switched off TV to shut down the remote vdr server. If I use cec-client, by that I disconnect Kodi from the CEC input stream, but when trying to ask Kodi instead Kodi itself won't tell me about the "TV off" state Sad

It would be good if at least the shutdown script would be called in all cases, even if a suspend is not executed in the end, so the user could handle the event in the script by himself.

Also of course a more generic information coming from the CEC device would help. Do you know if there's any interface where I could request the CEC state from?


Sorry for bother you with all this questions Angel Maybe you also have an idea who else I could ask?

Many thanks in advance

cheers
Steffen
Kodi != OpenELEC. I THINK, startup.sh and shutdown.sh are specific to OpenELEC.
Maybe I shut formalize the question more generic Blush

Kodi acts on CEC state changes, otherways Kodi would not shutdown when TV goes off (of course only, if it's configured that way), so :

Is there anywhere in Kodi any hook mechanism which would react if CEC reports a "TV off" state change (like a user defined script, a DBus message, a flashing blue LED, a screaming noise on the audio line etc.) or ANYTHING ELSE, which I could use to finally shutdown my remote vdr server, which would otherwise burn my hard earned money by consuming electricity all night long? Wink

Any hint is appreciated Big Grin

Cheers
Steffen
I know this is a bit old, but it wasnt solved at the time and I have the same problem.

I believe a lot of people see the RPi as a low power user so just leave it running, or connect to TV usb so it powers on/off. I'm trying to dual use it for Kodi and some Home Automation so I want the box to keep running but I need to stop it holding open the connection to my expensive to run i5 Windows box via pvr.

My thought on keeping it running but stopping it keeping a remote server awake is to take it off the network. The issue with using cec to stop/start kodi is losing the cec-link, how about using a cec trigger to change the ip address to a 169.x.x.x range, and then re-sync to network when TV was turned back on.
(2015-10-26, 04:26)rideti.me Wrote: [ -> ]..
My thought on keeping it running but stopping it keeping a remote server awake is to take it off the network. The issue with using cec to stop/start kodi is losing the cec-link, how about using a cec trigger to change the ip address to a 169.x.x.x range, and then re-sync to network when TV was turned back on.

Hi Ridety
that's really a quite interesting idea, I've to admit... Actual I'm just on a business trip, but I'll try when I'm back on the weekend. But one thing I need to figure out for that: You wrote about a cec- trigger: Where can I find this, means how can I hook into that?

Because for such a event I was looking for, and that's where I stacked so far. If I would know via CEC that the TV is just switched off, I could do e.g. something similar, which I got to work already, which was simply stop the kodi process, waiting via CEC-Input that the TV comes back and give control back to a new started Kodi.

This as such worked so far, but I was not able to find any cec trigger in the system which then can tell me that the TV is off- Do you know where such a trigger is available??


Many thanks for your help!!

best regards
Steffen
Hello, any progress on this?

I'd prefer just to stop the PVR manager or the VDR VNSI Client reacting / communicating with the VNSI Server on the VDR-Server when the TV is switched off.
So one could still use Kodi as a media player when TV is off.
I have the same problem (and the same setup, openelec on a raspi and a headless vdr backend based on minidvblinux).
Up to now I handled the problem with the 'Idle Actions' Add-On.
This determines the Idle state based on the internal function xbmc.getGlobalIdleTime and performes some configurable action after timeout.
Even more you can configure some action on return from timeout (which means any button pressed)

Up to now I used this addon to send a 'HITK Power' over the SVDRP protocol to the vdr.
But if you have multiple clients this is not really satisfying because the vdr shuts down even if other clients are connected.
Now you convinced me that the client should just somehow 'logoff' from the server and leave the further behaviour to the server and its configuration.
To achieve this I added two actions to the idle-actions-addon and used the internal command 'StartPVRManager' and 'StopPVRManager'
This looks like this:
Code:
        if action == 'StartPVR':
            xbmc.executebuiltin('xbmc.' + 'StartPVRManager')
            xbmc.executebuiltin('Notification(Idle Actions, PVR Manager started, 6000)')

        if action == 'StopPVR':
            xbmc.executebuiltin('xbmc.' + 'StopPVRManager')
            xbmc.executebuiltin('Notification(Idle Actions, PVR Manager stopped, 6000)')

For me this is an acceptable solution.
BTW, I didn't contact the author of the addon up to now.
I'm also an OpenElec, RPi and PVR user and have had similar frustrations.

Probably the best solution is to add a 'user defined action' option to trigger on CEC state transitions.

Then you could make this do:
CEC_Standby -> xbmc.StopPVRManager
CEC_PowerOn ->xbmc.StartPVRManager

Or in my case:
CEC_HDMI1InputSelected -> CEC_MakeActiveSource
(So my brain-dead LG TV remote starts working with Kodi when you select the HDMI1 input instead of the 'Kodi Simplink' input)

I'll take a look at what the options might be.

Unfortunately Jarvis is now in beta, so nothing would hit the streets until Kxxxx, although if you don't mind rolling your own OpenElec build, a patch of this kind isn't that hard to apply... :-).
Hello metaron,
What you propose sounds good to me, but somehow I missed the magic page in the documentation anyhow: where is the place to add such can user defined actions to a CEC state transitionHuh
Unfortunately it doesn't exist yet - I was thinking to add one :-).

I had a dig around the code. It seems the CEC device options are very closely tied to libCEC.
Shoe-horning this in as an extra option in 'kodi' doesn't look like it would be that simple (i.e. more than a 1 hour job for me!) and it might not get accepted into the main code base either. It might be better to try and get something merged 'upstream' as they say, in libCEC.

Maybe it would be simpler to change kodi to generate internal events based on selected key CEC events (TV standby, TV power on etc...), then use a technique like the one proposed here http://forum.kodi.tv/showthread.php?tid=...pid2169900 to tie it in to your desired action.

I do however think this is a really good idea which would improve RPi kodi PVR day to day user friendliness.

In the short term @Kleinschmidts approach seems the most encouraging one here to me.
Pages: 1 2