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
I was thinking about the same for similar reasons (turning on and off the TV/AVR based on certain events), but did not dare to ask for it. However, this is not actually about a "delay" of the event. It is more about a "grace period" until a certain task gets executed. During that grace period you still can cancel the already initiated task. This brings us to the question: Which events shall cancel the task before it will be executed?
I guees you could specify the cancle event.

Let say:
onPlayBackStarted (starts amp)
onPlayBackEnded (wait 1min)
onPlayBackStarted (cancles the previous event)

This is how i have it set up in LMS:
What type of task are you using?

If you are a bash guru, after a delay, you could use Kodi's JSON-RPC to query if the player is playing and then only shut off the amp if false.

Also easy to implement in python: https://gist.github.com/KenV99/924046810...eac1c3945d
Yes this would be possibility but then i loose functionality from LMS server which uses the same amp.
Without more detail, I don't think I can provide more help.
I just call this to turn on:
exec curl > /dev/null 2>&1

and this to turn off:
exec curl > /dev/null 2>&1
See updated gist at same link above.
You would configure the events to call the same python script for onPlaybackstarted and onPlaybackEnded, but pass 'start' and 'end' as respective parameters.
It works!

I just had to fix this "xbmc.Player.isPlaying()" to this "xbmc.Player().isPlaying()"

Thx! This has raised WAF trough the roof Smile
(2016-04-22, 22:59)snoopy86 Wrote: [ -> ]It works!

I just had to fix this "xbmc.Player.isPlaying()" to this "xbmc.Player().isPlaying()"

Thx! This has raised WAF trough the roof Smile

Sorry - that's what happens when I code from my phone Smile
I'm glad that it's working for you. My regards to ur wife Wink
Good news!!!

The addon has been accepted to the official repo.
Thank you all for your patience in pointing out bugs and helping me get this to this point.
I couldn't have done it without you.
I'm trying for a few days but I dind't get it working.
I want to call the advanced wake on lan addon. when playback is starting.
What did I have to configure?
Task 1: Scipt and choose default.py from script.advanced.wol directory
And Event 1: On Playback started + task 1

In general yes.
I do not have that installed and the source isn't available from the addon page so I can't be sure that is the way to call it.

As always see here if you need help: http://kodi.wiki/view/Add-on:Kodi_Callbacks#FAQs
I'm trying to run an HTTP Post command on onShutdown event. It appears to work for all events but onShutdown. I set the same task to run on start of playback, Kodi startup, and shutdown. It works in each case but when I shut down Kodi, it does not run. Is the HTTP Post command supported for the onShutdown event?
Yes it does. Check your log, read the post linked to in the previous post and if needed post the LINK to the log as directed here.
Thanks. After I enabled logging, it actually worked once but the next time I tried, it did not work again. Here are both logs from when it worked and didn't:

Did not work:

21:05:17 T:3264 NOTICE: $$$ [kodi.callbacks] - Shutdown started
21:05:17 T:3264 NOTICE: $$$ [kodi.callbacks] - Shutdown complete


21:03:30 T:3964 NOTICE: $$$ [kodi.callbacks] - Shutdown started
21:03:30 T:1952 NOTICE: $$$ [kodi.callbacks] - Task starting for onShutdown
21:03:31 T:1952 NOTICE: $$$ [kodi.callbacks] - Command for Task T1, Event onShutdown completed succesfully!
The following message was returned: Prepped URL:
Status: 200
Response for POST: No response received
21:03:31 T:1952 NOTICE: $$$ [kodi.callbacks] - Task finalized for onShutdown
21:03:31 T:3964 NOTICE: $$$ [kodi.callbacks] - Shutdown complete

Both times, I followed the same exact steps.
  • Opened Kodi
  • Went to Addons > Kodi Callbacks Settings
  • Clicked Write Settings into Kodi log
  • Navigated to home
  • Clicked Shutdown
Pages: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21