Kodi Community Forum
Release Execute user tasks for Kodi events (callbacks ver2) - Printable Version

+- Kodi Community Forum (https://forum.kodi.tv)
+-- Forum: Support (https://forum.kodi.tv/forumdisplay.php?fid=33)
+--- Forum: Add-on Support (https://forum.kodi.tv/forumdisplay.php?fid=27)
+---- Forum: Service Add-ons (https://forum.kodi.tv/forumdisplay.php?fid=152)
+---- Thread: Release Execute user tasks for Kodi events (callbacks ver2) (/showthread.php?tid=256170)

Pages: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22


RE: Execute user tasks for Kodi events (callbacks ver2) - fantasticn - 2016-04-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?


RE: Execute user tasks for Kodi events (callbacks ver2) - snoopy86 - 2016-04-21

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:
Image


RE: Execute user tasks for Kodi events (callbacks ver2) - KenV99 - 2016-04-22

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/9240468103a02257524769eac1c3945d


RE: Execute user tasks for Kodi events (callbacks ver2) - snoopy86 - 2016-04-22

Yes this would be possibility but then i loose functionality from LMS server which uses the same amp.


RE: Execute user tasks for Kodi events (callbacks ver2) - KenV99 - 2016-04-22

Without more detail, I don't think I can provide more help.


RE: Execute user tasks for Kodi events (callbacks ver2) - snoopy86 - 2016-04-22

I just call this to turn on:
exec curl http://10.0.0.9/cgi-bin/relay.cgi?on > /dev/null 2>&1

and this to turn off:
exec curl http://10.0.0.9/cgi-bin/relay.cgi?off > /dev/null 2>&1


RE: Execute user tasks for Kodi events (callbacks ver2) - KenV99 - 2016-04-22

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.


RE: Execute user tasks for Kodi events (callbacks ver2) - snoopy86 - 2016-04-22

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


RE: Execute user tasks for Kodi events (callbacks ver2) - KenV99 - 2016-04-23

(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


RE: Execute user tasks for Kodi events (callbacks ver2) - KenV99 - 2016-04-23

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.


RE: Execute user tasks for Kodi events (callbacks ver2) - bambule - 2016-05-15

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

Right?


RE: Execute user tasks for Kodi events (callbacks ver2) - KenV99 - 2016-05-16

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


RE: Execute user tasks for Kodi events (callbacks ver2) - metec - 2016-05-16

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?


RE: Execute user tasks for Kodi events (callbacks ver2) - KenV99 - 2016-05-16

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.


RE: Execute user tasks for Kodi events (callbacks ver2) - metec - 2016-05-17

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:
http://goo.gl/4jN06I

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

Worked:
http://goo.gl/0cegvH

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: http://192.168.1.122:8080/redeye/rooms/0/devices/585/commands/send?commandId=553
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