Kodi Community Forum

Full Version: Execute user tasks for Kodi events (callbacks ver2)
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
(2016-06-16, 02:21)rroos Wrote: [ -> ]So I've wrote a Python script that can monitor network usage, and I want to execute the script when the 'shutdown' event kicks in. The idea is that the script determines if there is network activity and if so, prevent the shutdown from taking place.

But I'm having problems getting that to work. I'm pretty confident about the script, and I'm presuming it gets executed, but I'm also presuming that nothing is preventing Kodi from executing the actual Suspend action while the script is being executed: the script probably doesn't replace the Kodi action. Are there ways in the plugin to prevent Kodi from executing the actual event?

There is no way to 'abort' Kodi's shutdown. If your code doesn't exit in 5 seconds, Kodi kills the thread it is executing in.
To my knowledge, there is no way around this. Even for the hardcore python developers, it makes debugging shutdown code challenging.
I am looking for some help with using Kodi Callbacks with SmartThings Kodi Manager smartapp. The goal is to have the status of kodi cause my lights to dim. So if I am playing something on kodi the lights will dim to a certain level and if I pause or stop playing the lights turn on to 100 percent. The problem is the Smartapp in SmartThings shows a list of URLS to enter into callbacks for various commands such as Play, Pause, Stop. I have not been able to find where I should paste these urls into callbacks. Can someone help point me in the right direction. Sorry but I am fairly new at this. Thanks in advance.
Image

You first create the task and then go to the Events page and link the Task with an event.
For the task, change the type to http.
Then click on HTTP string which will bring up a dialog box where you can type or right click to paste the string.
You will need a separate task for each url string.

Add-on:Kodi_Callbacks (wiki)
[Windows]
I've written a script that uses Kodi Callbacks to execute on playback.

What Will Happen:
script gets playback from kodi. script tells sonarr to unmonitor episode. sonarr stops looking for upgrade.

Available at https://github.com/Blackkatt/ToggleThatEpisode
(2016-07-02, 10:12)Blackkatt Wrote: [ -> ][Windows]
I've written a script that uses Kodi Callbacks to execute on playback.

What Will Happen:
script gets playback from kodi. script tells sonarr to unmonitor episode. sonarr stops looking for upgrade.

Available at https://github.com/Blackkatt/ToggleThatEpisode

Very nice! Thanks for sharing.
(2016-07-05, 14:20)KenV99 Wrote: [ -> ]
(2016-07-02, 10:12)Blackkatt Wrote: [ -> ][Windows]
I've written a script that uses Kodi Callbacks to execute on playback.

What Will Happen:
script gets playback from kodi. script tells sonarr to unmonitor episode. sonarr stops looking for upgrade.

Available at https://github.com/Blackkatt/ToggleThatEpisode

Very nice! Thanks for sharing.

Glad you like! Blush
I like to dim the lights of our Home Theater when A movie starts to play, but if I want to listen to some music the lights dim as well,
My goal is to dim the lights when watching a movie, but only then en not when listening to audio.
On page 2 of this thread there is someone with the same question and A given solution, but unfortunately its to hard for me to understand what to do or how to solve this.
Is there somebody out there that can explain to me what to do?

Thanks in advance!

regards
Can this allow me to restart kodi.bin or reboot LE when RAM reaches say 75% but only when not used and idle 30 minutes? Meaning if video is playing and RAM gets to 80% kodi will function as normal and continue playing the video, when playback is stopped and the system is not used for 30 minutes it will reboot if the RAM is still above 75%.

Reason i need this is i keep my s905 box on 24/7 and there is a bug that slowly uses the RAM but does not release it, I'm running a cron job to restart but it's not smart and will restart when it's scheduled.
(2016-08-21, 23:57)jebise Wrote: [ -> ]Can this allow me to restart kodi.bin or reboot LE when RAM reaches say 75% but only when not used and idle 30 minutes? Meaning if video is playing and RAM gets to 80% kodi will function as normal and continue playing the video, when playback is stopped and the system is not used for 30 minutes it will reboot if the RAM is still above 75%.

Reason i need this is i keep my s905 box on 24/7 and there is a bug that slowly uses the RAM but does not release it, I'm running a cron job to restart but it's not smart and will restart when it's scheduled.

Well, it can help by running a script whenever Kodi is idle for 30 minutes, but you would have to place code in the script to figure out the percentage of used RAM and then trigger the restart.
Quick research seems to indicate that from a python script you may need to read 'cat proc/meminfo's output into a string and then parse the string, calculate the percentage, compare it to your value and then call xbmc.restart().

If you are more adept at js, you might be able to use Activity Manager to get the memory usage and then use the JSON-RPC interface to trigger the restart.

Although I'm happy to outline the process, unfortunately I do not have the time or easy access to an android platform to actually write and test this.
Good luck!

EDIT:
In python it would looks something like this:

Code:
import xbmc
meminfo = dict((i.split()[0].rstrip(':'),int(i.split()[1])) for i in open('/proc/meminfo').readlines())
mem_used = float(meminfo['MemTotal'] - meminfo['MemFree'])/float(meminfo['MemTotal'])
if mem_used > 0.75:
    xbmc.restart()

Note - there seems to be an ongoing discussion about what these numbers mean in Android and what represents memory that is actually free for program use. Adjust your 0.75 threshold accordingly.
Thanks for this useful addons... But how do i make it work in 14.2 Helix?
Upgrading to new versions messing up my custom skin and my database..
Is there any version that works on 14.2?
When i installed it it's asking for dependencies and i cant find a way to install that dependencies without upgrading..

I only need to call a script that closes Kodi once the update process is finished...

thanks
(2016-08-24, 05:45)denywinarto Wrote: [ -> ]Thanks for this useful addons... But how do i make it work in 14.2 Helix?
Upgrading to new versions messing up my custom skin and my database..
This the first report of an issue with a skin or a database.
Which skin.
Which database.
(2016-08-24, 05:45)denywinarto Wrote: [ -> ]Is there any version that works on 14.2?
When i installed it it's asking for dependencies and i cant find a way to install that dependencies without upgrading..
It requires script.module.requests.
If needed, install manually from here:https://github.com/beenje/script.module.requests
If you install from zip or repo, it downloads and installs automatically.

AS ALWAYS: If you don't post a log to pastebin or similar and provide a link, there is very little help that can be offered.
http://kodi.wiki/view/Add-on:Kodi_Callbacks#FAQs
(2016-08-24, 15:44)KenV99 Wrote: [ -> ]
(2016-08-24, 05:45)denywinarto Wrote: [ -> ]Thanks for this useful addons... But how do i make it work in 14.2 Helix?
Upgrading to new versions messing up my custom skin and my database..
This the first report of an issue with a skin or a database.
Which skin.
Which database.
(2016-08-24, 05:45)denywinarto Wrote: [ -> ]Is there any version that works on 14.2?
When i installed it it's asking for dependencies and i cant find a way to install that dependencies without upgrading..
It requires script.module.requests.
If needed, install manually from here:https://github.com/beenje/script.module.requests
If you install from zip or repo, it downloads and installs automatically.

AS ALWAYS: If you don't post a log to pastebin or similar and provide a link, there is very little help that can be offered.
http://kodi.wiki/view/Add-on:Kodi_Callbacks#FAQs

Im using customized ace skin..
Was going to post a log yesterday but i couldnt find anything related to failed dependencies..
Anyways i think i managed to install older version.. i think it was 0.5.. and i got it the auto-close after update working..
Just 1 more question, can this addon auto retry update process when metadata source is down? Thetvdb sometimes down and it would be very useful if we could auto retry... thanks
(2016-08-25, 10:14)denywinarto Wrote: [ -> ]Just 1 more question, can this addon auto retry update process when metadata source is down? Thetvdb sometimes down and it would be very useful if we could auto retry... thanks

Not easily.
All it could provide is a scheduler to run your own script which would need to assess if it is down and then call for an update for all media.
Hi there,

I stumbled upon this addon when I was looking for a way to start a Kodi addon automatically on a weekly basis. Is this possible with this addon?

Ive set the task up and the event (daily event) i've set runs every 6828 hours.

Will this work?
(2016-08-29, 17:39)ed_davidson Wrote: [ -> ]Hi there,

I stumbled upon this addon when I was looking for a way to start a Kodi addon automatically on a weekly basis. Is this possible with this addon?

Ive set the task up and the event (daily event) i've set runs every 6828 hours.

Will this work?

I believe so as long as you don't shut down Kodi in between.
Pages: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21