How do you disable a PVR addon or the PVR manager on idle?
#1
Hello...

I've switched over to TVHeadend on my server and am running a powersaving script on the server to put the server to sleep after 15mins idle. The script checks if TVHeadend has any subscriptions (connected clients who could well be idling but they are on the network) and if it does it won't put the server to sleep.

One of my clients is a 24/7 raspberry pi running Kodi 17 on Libreelec. This never shuts down so it stays connected to the backend constantly. I've added the Kodi Callbacks addon to it and have created a task which issues the builtin function StopPVRManager after 15mins idle but it doesn't do anything. I also tried to do a json command to unload the hts addon but that didn't work unless I launched it from a web browser and that would result in a crash.

Does anyone know how I could get this to work?

Thanks.
Reply
#2
Are you using krypton? If you are stoppvrmanager won't work. I use a python script to disable / enable / otherwise mess with dvbviewer - the bits possibly relevant to you would be:
Code:
xbmc.executeJSONRPC('{"jsonrpc":"2.0","method":"Addons.SetAddonEnabled","id":8,"params":{"addonid":"pvr.dvbviewer","enabled":false}}')
and
Code:
xbmc.executeJSONRPC('{"jsonrpc":"2.0","method":"Addons.SetAddonEnabled","id":8,"params":{"addonid":"pvr.dvbviewer","enabled":true}}')
You could make a couple of little scripts from those, and call them however you like.
Disclaimer - this is very hacky, but it suits my needs.
Reply
#3
Thanks for replying trogggy. Yes, I'm using Krypton - didn't realise it no longer supports the stoppvrmanager function. I've tried your code in a .py file (replacing the dvbviewer addon with hts) and have triggered it with Kodi Callbacks. Unfortunately it locks up Kodi right after unloading the tvheadend addon. I've looked in the log and the only warning I see before it locks up is:

CPythonInvoker(8): Script invoked without an addon. Adding all addon modules installed to python path as fallback. This behaviour will be removed in future version.

I get the same lockup and warning in the log if I use RunScript with a mapped key on the keyboard.

If I disable the tvheadend addon through the addon menu it unloads fine. Not sure what to do as I don't really understand scripting. All I did was copy/paste the code into a file called pvrstop.py which I saved in the userdata folder.
Reply
#4
(2017-03-27, 18:53)lokum Wrote: Thanks for replying trogggy. Yes, I'm using Krypton - didn't realise it no longer supports the stoppvrmanager function. I've tried your code in a .py file (replacing the dvbviewer addon with hts) and have triggered it with Kodi Callbacks. Unfortunately it locks up Kodi right after unloading the tvheadend addon. I've looked in the log and the only warning I see before it locks up is:

CPythonInvoker(8): Script invoked without an addon. Adding all addon modules installed to python path as fallback. This behaviour will be removed in future version.

I get the same lockup and warning in the log if I use RunScript with a mapped key on the keyboard.

If I disable the tvheadend addon through the addon menu it unloads fine. Not sure what to do as I don't really understand scripting. All I did was copy/paste the code into a file called pvrstop.py which I saved in the userdata folder.
The 'warning' doesn't mean anything - other than you're running a script without an addon. I found a couple of 'proper' addons I originally used on krypton - edited them to work with hts and zipped them up. I've tried them on my machine and they seem to work exactly as with dvbviewer, but obviously I don't have a valid hts input to test.
Give them a try - let me know whether they work. If they don't, though, I'm out of ideas.
dropbox
I run these from favourites.xml, with eg
Code:
<favourite name="htsdisable">RunScript(script.htsdisable)</favourite>
    <favourite name="htsenable">RunScript(script.htsenable)</favourite>
obviously running from a keyboard key will give the same result.
Reply
#5
Thanks for the help trogggy, really, really appreciate it. I've given the addons a go but I get the same lock up unfortunately. Perhaps it's something in my setup. I've come up with a compromise which is to comment out the part in the autosuspend script which looks for connected clients. It's not very elegant and has potential issues but it's allowed my server to finally get some sleep. Thanks again Smile
Reply
#6
No worries. Sorry it didn't work.
Reply
#7
Why do you need to mess with your clients just because you want your server to go to sleep? Like you said you're already checking for subscriptions, not connections. Just suspend the backend and your clients should reconnect automatically once the server is up again. Or am I missing something here?
Reply
#8
(2017-03-30, 07:36)negge Wrote: Why do you need to mess with your clients just because you want your server to go to sleep? Like you said you're already checking for subscriptions, not connections. Just suspend the backend and your clients should reconnect automatically once the server is up again. Or am I missing something here?


Well, this only works if the client add-ons have properly implemented a reconnect on connection loss logic.

With Krypton it's up to the add-ons to manage this, because we removed shitty "reloading of add-on in a loop until it reports connected" logic from Kodi core. So, if it does not work, add-on needs to be fixed. ;-)

EDIT: and yes, the tvheadend client add-on properly handles reconnect on connection loss.
Reply
#9
(2017-03-30, 07:36)negge Wrote: Why do you need to mess with your clients just because you want your server to go to sleep? Like you said you're already checking for subscriptions, not connections. Just suspend the backend and your clients should reconnect automatically once the server is up again. Or am I missing something here?

If there's an active client who is watching a movie or doing something which doesn't require the TV server it will still be connected to the backend and should keep it awake so the client can switch to TV if they want (the client is still active afterall). However if the client is inactive for say 15mins the client Kodi can unload the PVR addon and the backend can sleep "knowing" there's no one on any clients wanting to use it. Also this way there is no backend connection lost notification during use of Kodi.

Perhaps a better option would be to allow the client to unload the PVR after x amount of time if not using the PVR feature (this would be better from a power saving point of view). Hope that makes sense. Either way I'm not sure why unloading the addon causes a crash.
Reply

Logout Mark Read Team Forum Stats Members Help
How do you disable a PVR addon or the PVR manager on idle?0