Linux KODI/VDR - Hibernate after recording
#1
Hi Folks!

For my local KODI/VDR-setup I created the following rather simple and dowdy solution to hibernate my system after a recording is finished. The approach as well as the implementation are far from being perfect, however "the script works for me", but I am also not very satisfied by my current solution so far. Therefore, I ask for feedback here.

My solution consists of two components:
  • a script called by VDR
  • a KODI-plugin providing a confirmation dialog

VDR-script GitHub

The script is called by VDR whenever some recording state changes and acts only if a recording is finished. This is achieved by setting the RECORDCMD in /etc/runvdr.conf appropriately. The script then parses VDR's timers.conf and determines the start time of the next recording. The script then
  • does not hibernate the system if another recording is close (i.e. the time span between now and the next recording does not exceed a certain threshold)
  • sets the wake-up time for the next recording
  • asks the user for confirmation to hibernate the system by activating the KODI-plugin via the JSON RPC call Addons.ExecuteAddon
  • hibernates the system

KODI-plugin GitHub

The only purpose of the plugin is to display a yesno-dialog with an autoclose-timeout to the user so he or she could confirm or deny the hibernation of the system. The communication with the VDR-script takes place via files that are created by the plugin and checked by the VDR-script: Depending on the user's decision the plugin creates a specific empty file and the VDR-script checks for the existence of this file.

Things I want to improve first

There are many things that can be improved about this solution - the configuration is hard-coded at the moment, the files used for the communication between the VDR_script and the KODI-plugin are hardcoded ... however there are a few things that are most important, if it is not possible to fix them, it does not make that much sense to fix up the other things either.
  • Communication between VDR-script and KODI-plugin

    Using hard-coded files clearly is not the optimal way to communicate between the VDR-script and the KODI-plugin. As the KODI-plugin is activated using a JSON RPC call it would be nice to return the user's decision via the result of the RPC call. Is this even possible? Are JSON RPC calls asynchronous in any case or is it possible to wait for the result of the yesno-dialog? How could I influence the result of the JSON RPC call from within the plugin?

  • VDR-script

    Currently, the script is activated by VDR and also runs in the context of VDR. However, it would by nice if the script ran in the context of KODI. Is this possible? Are there any hooks that are activated when a recording is finished a plugin could attach to? There is the Kodi Callbacks Addon but it seems not to offer a hook for that kind of event.

    Furthermore, is there an Python-API to retrieve the necessary information from the PVR-part of KODI (i.e. when does the next recording start ...). If this was available almost the complete script could be realized directly by KODI-means, the only thing that would be left is setting the wake-up time for the next recording.

Well - thanks for reading this and I would be grateful for your feedback!

Ciao, Rosepeter
Reply

Logout Mark Read Team Forum Stats Members Help
KODI/VDR - Hibernate after recording0