Release Sleep Timer (service.sleeptimer)
#1
Image

service.sleeptimer

Description: This service addon makes Kodi stop any playback if it exceeds a given idle time. If you have that awful habit of leaving Kodi playing live content after you fell asleep, this addon is for you! It gives extended control over the playback time. Step mute the audio, enable the screensaver or run a custom command after the playback is stopped.

Usefull information:
-> Sleeptimer checks kodi idle time (xbmc.getGlobalIdleTime()). This idle time is different from the overall playback time so it assumes you're watching content with no interaction with the user interface.
-> The service has a debug mode which will check and stop based on one minute intervals.
-> For any changes/setting to take effect you need to restart kodi

Why you need it
-If you have a family member that never stops the playback, leaving content playing "forever" from network-based locations.
-If you fall asleep leaving kodi playing without any timer and find kodi still playing in the morning.
-To be sure any playback is being stopped on every kodi htpc around the house.

Settings
Image
Image
Image

General tab:
Service check time -> Interval in minutes for kodi to check your idle time and compute the difference between this idle time and the max time allowed for playback/idle.
Waiting time -> Time you have to tell kodi you want to continue watching a given content. (Dialog progress)
Slow mute the audio -> Option to low the volume of the video/audio before playback is stopped (volume will be changed again to default after stop)
Enable screensaver -> Option to enable the screensaver after playback is stopped.
Custom command -> You can define a command to be run after the playback is stopped. The service runs this command using os.system("command").

Audio Video supervision tab:
Apply the service checks for audio and video and define maximum allowed playback/idle time when playing each one of them.

Debug tab:
Overwrite all settings to the minimum interval possible for testing purposes. Again, the service checks for idle time not for total playback time. So, if you have any interaction with kodi (mouse, keyboard) idle time will be 0!


Screenshot
Image

Download:
This service is now on the official repository. Settings -> addons -> get addons -> kodi repository -> services -> Sleep Timer -> install

Source code / Translations
https://github.com/enen92/service.sleeptimer

License
GPL V2

Cheers
Reply
#2
just what i was looking for

thank you!
Reply
#3
Hey, thanks for the service addon. Saw your post on reddit. I can't seem to get this to work, I stream from an addon, is it supposed to be compatible with any streaming addon?
Reply
#4
Nice one!

...but I feel these additional settings should be optional within the global powersaving settings anyway, so that after "Service check time" the "Dialog time" would kick in and trigger the screensaver etc. until the client falls asleep/shutsdown or whatever.

My actual TV is configured this way: after 4h without user intervention it asks whether it should continue showing what it's showing and goes to standby if I (respectively my wife Wink ) don't react.

This way this would also make sense if the option 'Play the next video automatically' for local content was enabled.
Bye,
Fry
Kodi v17.6 with shared MariaDB v10.3 | HTS Tvheadend 4.2.6 on RPi2 | running on:
Windows 10x64 | Nvidia Shield | FireTV4k | FireTVStick4 | Android 5 | RPi3 with OSMC
Reply
#5
No one else really fond of this?
I'd love to have this option in Kodi by deafult!
Bye,
Fry
Kodi v17.6 with shared MariaDB v10.3 | HTS Tvheadend 4.2.6 on RPi2 | running on:
Windows 10x64 | Nvidia Shield | FireTV4k | FireTVStick4 | Android 5 | RPi3 with OSMC
Reply
#6
Very usefull add-on!!!
Reply
#7
(2015-01-03, 09:00)Tim8 Wrote: Hey, thanks for the service addon. Saw your post on reddit. I can't seem to get this to work, I stream from an addon, is it supposed to be compatible with any streaming addon?

It just detects if xbmc is playing independently of what it is playing. Also it starts counting since the start of each video so if you have a playlist or "repeat mode" active it won't work. I made this mainly for live content.
Of course you need to restart kodi for this to take effect but I though that was not important to mention since is common to any service that initiates at startup.

(2015-01-03, 09:43)Fry7 Wrote: Nice one!

...but I feel these additional settings should be optional within the global powersaving settings anyway, so that after "Service check time" the "Dialog time" would kick in and trigger the screensaver etc. until the client falls asleep/shutsdown or whatever.

My actual TV is configured this way: after 4h without user intervention it asks whether it should continue showing what it's showing and goes to standby if I (respectively my wife Wink ) don't react.

This way this would also make sense if the option 'Play the next video automatically' for local content was enabled.

I'll check if there's any way of checking the last time the user has made any input to the system but I doubt it. As of being part of kodi itself I agree...however I don't know c++ so it has to be made by others Sad
Reply
#8
I modded this version of service.safestop (Kodi 14+ only):
new features:
- changed to "idle"
it works with "Live-TV" also. If the user doesn't do anything for $check_time the dialog pops up
- separate Audio and Video supervision and check_time
you can switch Audio and Video Supervision off separately. This is useful for Partys, where you don't want the Music to stop after 2,5h Wink
- option to slowly mute Audio before stopping
Who didn't wakeup in front of the TV because of the abrupt volume change if it stops playing Wink
- option to enable the screensaver after stopping
- improved activating/deactivating of the plugin
You don't have to restart Kodi to make the new settings work. Just reactivate the Addon

Image

Image

Image
get the latest version here:
https://github.com/walterheisenberg/serv...master.zip

Please report any bugs and/or feature requests
Philips TV with Kodi 20.2 with IPTV --- Orbsmart 500 Android 21 alpha/beta as Online-radio/TV in the kitchen
Reply
#9
Just add yourself as an author and send me a PR. After some minor tweaks that are needed for it to be accepted in the oficial Repo we can send it to the Repo and make it available for everyone. Nice job.

Cheers
Reply
#10
Done!
This version is only for Kodi >= Helix, because of "xbmc.Monitor().waitForAbort()", see:
http://kodi.wiki/view/Service_addons

Also I thought about adding language files, but this is my first change to an addon for Kodi and I'm haven't coded python before. Please have a look at the code and feel free to improve it. I tried to comment as much as possible.
If you enable "Debug-Logging" you can easily find log-entries with
Code:
cat /path/to/kodi.log | grep safestop
on Linux

I tried to change the variables as they look in other addons, but it didn't work and I gave up:
e.g.: https://github.com/elbowz/partymode-auto...tostart.py
Is there a need for global variables? If not, please change it.

and:
How about change the name to "service.sleeptimer"?
Philips TV with Kodi 20.2 with IPTV --- Orbsmart 500 Android 21 alpha/beta as Online-radio/TV in the kitchen
Reply
#11
Yap no problem, finding a good logo will also be a good idea. I think first se need to solve the possible bug (havent tested) of Kodi hanging on shutdown. Addon strings is a simple resources/language/english/strings.po file in which each entry has an id (there are rules for the range) and then the string is obtained by calling xbmc.getlocalizedstring(id).
I also think xbmc has its own log function that will print to the log according to the debug level. That's something we'll have to look into as well.
I am away but will have a look at it tonight.
Thanks for your work and lets hope this is your first contribution of many to come (for new addons).

Cheers
Reply
#12
The shutdown issue should be fixed
Philips TV with Kodi 20.2 with IPTV --- Orbsmart 500 Android 21 alpha/beta as Online-radio/TV in the kitchen
Reply
#13
It is fixed, if you install version 2.0. There is NO autoupdate, because there is no repo
Philips TV with Kodi 20.2 with IPTV --- Orbsmart 500 Android 21 alpha/beta as Online-radio/TV in the kitchen
Reply
#14
Hey Solo0815 apologies for the lack of news. Already renamed the addon to sleeptimer, added an icon and added you as a colaborator. You can now (I think) push to the project page. The reason I did so is the fact that the github link is used in the mailing list when you submit addons, you just mail the last commit to the mailing list. Hence if you have access to the repository you can push to it and mail the team-kodi for an update. I will implement translations and have a look at that xbmc monitor function. Ideally, since the bottom repository is Gotham we should have a way of using abortrequest/xbmc.monitor according to the version we are running.
I'll make some changes and notify you. Then if you're happy with it I'll submit to the official repository.

Cheers
Reply
#15
Thx for the update, will have a look at it.
another things I thought about:
- adding a "debug" and "debug test" mode. Both modes should log much info to kodi.log
--> Differences:
*** debug: settings from the GUI are used
*** debug test: settings from the GUI are overwritten with much shorter values (for easier testing). So you don't have to wait 30 min for the script to react Wink
- do we need (or is there already) a "xbmc.Player().isrecording()" function? I asked in the forum, but no one answered:
http://forum.kodi.tv/showthread.php?tid=223194
If Kodi is recording anything, the script should not stop playing. Don't know, if "stop" also stops recording ...
- we should think about adding "isplaying" when Garbear has RetroPlayer working.
Philips TV with Kodi 20.2 with IPTV --- Orbsmart 500 Android 21 alpha/beta as Online-radio/TV in the kitchen
Reply

Logout Mark Read Team Forum Stats Members Help
Sleep Timer (service.sleeptimer)1