• 1
  • 12
  • 13
  • 14(current)
  • 15
  • 16
  • 22
Release Execute user tasks for Kodi events (callbacks ver2)
Hi,

I'm using osmc on PI3.
kodi 17.1
callbacks 1.0
I use 2 profiles "Enfants" and "Master User" at boot, kodi start on "Enfants".

What I'm trying to acheive is, when using Master user profile, "on screensaver activate" to have an automatic kodi restart (and so to be back in "Enfants" profiles)

Issue : is seems calback addon only load configuration of first profile, indeed If in both profile callback is reconfigured to restart onscreensaveractivated, "Master user" is properly restarted (but in that case "Enfants" is also restarted.)
if "Enfants" is configured to no action and Master to restart on screensaver : restart doesn't happen.
Note : if when log in master I enter callback addon configuration, after existing configuration, then restart happenned on screensaveractivate.

Thanks for your help.
Reply
Bump...anyone?

(2017-04-23, 17:40)stephr1 Wrote: BUMP!! Anyone offer any help here? Thx....

(2017-04-20, 16:37)stephr1 Wrote: @KenV99

Thank you for your efforts!! I haven't started using it yet, but have a need for an event that isn't obviously available...

Running OSMC/RPI 3. Have a HDHomeRun dual tuner connected (thru the network) and would like to be able to turn on an LED (1 for each tuner channel) when a recording is happening, and off when it isn't (or recording is finished).

Does that exist in your addon (thought "onDailyAlarm" or "onIntervalAlarm" might be the answer, but not sure either would work the way I'd like it to), is there a combination of events I could use, or am I on my own here....

Thanks in advance....
Reply
(2017-05-08, 18:44)stephr1 Wrote: Bump...anyone?

(2017-04-23, 17:40)stephr1 Wrote: BUMP!! Anyone offer any help here? Thx....

(2017-04-20, 16:37)stephr1 Wrote: @KenV99

Thank you for your efforts!! I haven't started using it yet, but have a need for an event that isn't obviously available...

Running OSMC/RPI 3. Have a HDHomeRun dual tuner connected (thru the network) and would like to be able to turn on an LED (1 for each tuner channel) when a recording is happening, and off when it isn't (or recording is finished).

Does that exist in your addon (thought "onDailyAlarm" or "onIntervalAlarm" might be the answer, but not sure either would work the way I'd like it to), is there a combination of events I could use, or am I on my own here....

Thanks in advance....

The events are listed in the Wiki:Add-on:Kodi_Callbacks (wiki)
There are no events for recording and I don't know how that could be done.
IF you know of another way of checking, you could write your own code to check if a recording is occurring and IF you know how to turn on the LED in code then send the codes to turn it on or off depending on coding state.
If the above is true, then you COULD use the onIntervalAlarm to call the above intermittently (like every second).
However, if you know how to code all of the above, consider writing your own addon to do it.
Reply
@stephr1 this is really a backend job I think. Which backend are you using?
If I have helped you or increased your knowledge, click the 'thumbs up' button to give thanks :) (People with less than 20 posts won't see the "thumbs up" button.)
Reply
Is it possible to execute 2 built-in Kodi functions with a minor sleep in between them under one task?

I've currently set it up my task as "Kodi Builtin Function: Action(xxxxxx)" and I want something like "Kodi Builtin Function: Action(xxxxxx); sleep250ms; Action(xxxxxx);", is something like that possible?
Reply
I think I solved it by creating an external script that utilizes the JSON RPC:

Code:
curl --silent --user user:pass --header 'Content-Type: application/json' --data-binary '{"jsonrpc":"2.0","id":1,"method":"Input.ExecuteAction","params":{"action":"actionhere"}}' 'http://localhost:8080/jsonrpc'
sleep 0.25s
curl --silent --user user:pass --header 'Content-Type: application/json' --data-binary '{"jsonrpc":"2.0","id":1,"method":"Input.ExecuteAction","params":{"action":"anotheraction"}}' 'http://localhost:8080/jsonrpc'

Possible actions can be found here: http://kodi.wiki/view/Action_IDs
Reply
Hi Guys,

I found this addon while searching for a solution to deactivate and reactivate certain processes that are running on my Libreelec installation when i start to watch a movie.
I use a Cubox-i4 Pro as my HTPC which runds Libreelec and Kodi 17.3. The cubox additionally runds my Sickrage, Transmission and NzbGet clients which manage my automated downloads towards my NAS.

What i would like to achieve is that when i start to watch a movie or a tvshow that Kodi:
- Either pauses all downloads in NZBGet (via a possible API call?) or if that is not possible kill the NZBGet process altogether.
- Kill Sickrage process
- Kill Transmission process

once playback of a movie has stopped Kodi should automatically
- Resume all downloads in NZBGet or if process was killed start NZBGet daemon again
- Restart Sickrage process
- Restart Transmission process

I guess this can be done via the builtin functions of this addon by calling scripts or maybe shell commands but as i have very very limited linux script knowledge i am unsure how to go about this to achieve above mentioned goals.

Can anyone who is more proficient in this help me here? Or if not at least give me the right pointers/examples of how i could reach the above goal?

Cheers!
Reply
Ok i think i got what i want. I simply created two one line scripts with the appropriate killall shell command to stop the service. I just tryed it with sickrage and it works. So i guess i'll just rince and repeat this for the two other applications and then i'm set. Probably not the most elegant solution but at least it works Smile
Reply
Hello everyone!!
I'm trying to start a python script, for 1 led to light up when pausing a file, but I'm getting error.

https://pastebin.com/Km1UsXhu


Code:
#!/usr/bin/python

import sys
sys.path.append('/storage/.kodi/addons/virtual.rpi-tools/lib')

import RPi.GPIO as GPIO
import time
GPIO.setmode(GPIO.BCM)
GPIO.setwarnings(False)
GPIO.setup(18,GPIO.OUT)

while(true):
print "LED on"
GPIO.output(18,GPIO.HIGH)
time.sleep(1)
print "LED off"
GPIO.output(18,GPIO.LOW)
time.sleep(1)
[/quote][/code]


[code]ERROR encountered for Task T1, Event onPlayBackPaused
ERROR mesage: <attribute 'message' of 'exceptions.BaseException' objects>
<type 'exceptions.IndentationError'>
Traceback (most recent call last):
File "/storage/.kodi/addons/script.service.kodi.callbacks/resources/lib/tasks/taskPython.py", line 127, in run
module = __import__(module_name.encode('utf-8'))
File "/storage/led/LED.py", line 13
print "LED on"
Reply
Indentation matters in python.
You need to indent after the while statement.
https://www.tutorialspoint.com/python/py...e_loop.htm

I assume this is just test code bc you have a 'while True' loop without any break statement.
Reply
Hey Guys -


I'm trying to implement Kodi with my whole home automation system so currently linking it via SmartThings - having issues though I've done research and seen similar posts in this thread, but still have questions.

The custom code for ST which I found most up to date was north3221SmartThings. The installation instructions mention setup of Kodi Callbacks, but below is all it states:

You will also need to set up the Callbacks plugin. This is how Kodi talks to Smartthings, meaning you get real time updates. Once installed you need to create the tasks for play, pause, stop, resume, shutdown, startup and then add them to the appropriate events (read the Wiki in the link for help)
NB You only need this for two way comms and you can install this after installing the smartthings app & device handler.


I've installed the add-on, but don't know what type of Task to create (assume http), how to configure it, and what type of Event to tie it to.
Here's a direct link to the code which interacts with the addon. I've written the author of the code, but so far no response.

I'm running Kodi 17.3 and installed the add-on from the official repo. Any suggestions?

UPDATE

After posting, I proceeded to add Kodi to SmartThings via the app anyways. Once I did, the final screen provided further information. Still trying to find out how I need to set up within Callbacks, though...

This app is designed to work with the xbmc.callbacks2 plugin for Kodi. Please download and install callbacks2 and in its settings assign the following URLs for corresponding events:

It then provided me with 6 custom URLs (below) where the only difference is the final command. I obviously took out the auth portions Smile
I've tried a few things within Callbacks using these URLs without luck. Any suggestions? Thanks!
- BzowK -
Reply
Hi,

For some reason onShutdown event never triggers. There is not much in the logs so I have posted them below.

These are my settings:
Quote:16:45:55 T:140222960924416 NOTICE: $$$ [kodi.callbacks] - { 'Events': { u'E1': { 'task': u'T1',
'type': 'onPlayBackStarted',
'userargs': u''}},
'General': { 'LogFreq': 500,
'LoopFreq': 500,
'Notify': False,
'TaskFreq': 100,
'elevate_loglevel': True},
'Tasks': { u'T1': { u'content-type': u'application/json',
u'http': u'http://request.in/1az****',
'maxrunning': -1,
'maxruns': -1,
u'pass': u'',
'refractory': -1,
u'request-type': u'GET',
'type': u'http',
u'user': u''}}}

And the following is the task being successfully called by the "onPlayBackStarted" event. You can then see I change the event to "onShutdown" and then shutdown, but nothing happens. I have tried shutting down numerous times but it never triggers.
Quote:16:48:47 T:140223114905344 NOTICE: $$$ [kodi.callbacks] - Command for Task T1, Event onPlayBackStarted completed succesfully!
The following message was returned: Prepped URL: http://requestb.in/1azs****
Body:
Status: 200
Response for GET: ok
16:48:47 T:140223114905344 NOTICE: $$$ [kodi.callbacks] - Task finalized for onPlayBackStarted
16:49:42 T:140223235979008 NOTICE: ES: Client from 192.168.0.96 timed out
16:50:19 T:140224698169408 NOTICE: Samba is idle. Closing the remaining connections
16:53:05 T:140224698169408 WARNING: Trying to add unsupported control type 1
16:53:16 T:140223400883968 NOTICE: $$$ [kodi.callbacks] - Settings change detected - attempting to restart
16:53:17 T:140223400883968 NOTICE: $$$ [kodi.callbacks] - Settings read
16:53:17 T:140223400883968 NOTICE: $$$ [kodi.callbacks] - Dispatcher initialized
16:53:17 T:140223400883968 NOTICE: $$$ [kodi.callbacks] - Subscriber for event: onShutdown, task: T1 created
16:53:18 T:140223400883968 NOTICE: $$$ [kodi.callbacks] - Dispatcher started
16:53:18 T:140223400883968 NOTICE: $$$ [kodi.callbacks] - Publisher(s) started
16:54:05 T:140224698169408 NOTICE: Storing total System Uptime
16:54:05 T:140224698169408 NOTICE: Saving settings
16:54:05 T:140224698169408 NOTICE: Saving skin settings
16:54:05 T:140224698169408 NOTICE: stop all
16:54:05 T:140224698169408 NOTICE: stop player
16:54:05 T:140224698169408 NOTICE: ES: Stopping event server
16:54:05 T:140224698169408 NOTICE: stopping upnp
16:54:05 T:140224698169408 NOTICE: stopping zeroconf publishing
16:54:05 T:140224698169408 NOTICE: WebServer: Stopped the webserver
16:54:05 T:140223235979008 NOTICE: ES: UDP Event server stopped
16:54:06 T:140224698169408 NOTICE: stop dvd detect media
16:54:06 T:140224698169408 NOTICE: stop sap announcement listener
16:54:06 T:140224698169408 NOTICE: clean cached files!
16:54:06 T:140224698169408 NOTICE: unload skin
16:54:06 T:140224698169408 WARNING: Cleanup: Having to cleanup texture dialogs/options/buttons/default-fo.png

I am running OpenElec on an Intel NUC, Kodi 16.1.

Any help appreciated.

Thanks
Reply
Hi there,

Firstly thanks for this script.

I've been trying to write a script that will use HDMI CEC to turn my TV on (as the stereo is connected to the TV OUT) when I start airplaying music to Kodi.

My match event is successful, however I can't figure out why my script is not working.

Quote:osmc@osmc:~/.kodi/temp$ tail -f kodi.log | grep --line-buffered call
00:02:59.671 T:1455420400 INFO: Platinum [neptune.http]: calling connector (proxy:no) (http 1.1:yes) (url:http://192.168.1.254:34050/)
00:03:02.439 T:1472197616 DEBUG: $$$ [kodi.callbacks] - Task starting for onLogSimple:E1
00:03:04.174 T:1455420400 INFO: Platinum [neptune.http]: calling connector (proxy:no) (http 1.1:yes) (url:http://192.168.1.254:34050/)
00:03:04.374 T:1455420400 INFO: Platinum [neptune.http]: calling connector (proxy:no) (http 1.1:yes) (url:http://192.168.1.254:34050/)
00:03:04.675 T:1455420400 INFO: Platinum [neptune.http]: calling connector (proxy:no) (http 1.1:yes) (url:http://192.168.1.254:34050/)
00:03:07.503 T:1472197616 DEBUG: $$$ [kodi.callbacks] - Command for Task T1, Event onLogSimple:E1 completed succesfully!
00:03:07.504 T:1472197616 DEBUG: $$$ [kodi.callbacks] - Task finalized for onLogSimple:E1

So callbacks is successful.

The command I'm trying to run in a script (I've tried a bash script, and a python script):

Bash:
Quote:osmc@osmc:~$ cat script.sh
#!/bin/sh

echo "on 0" | cec-client -s -d 1
sleep 5
exit

You can see I tried adding in a sleep, but that didn't help..

Quote:osmc@osmc:~$ cat script.py
import subprocess

subprocess.Popen("echo 'on 0' | cec-client -s -d 1", shell=True)

Running either script manually works successfully. I just can't see why it's not working when I call either from within Kodi Callbacks.

Manually execute:
Quote:osmc@osmc:~$ python script.py
osmc@osmc:~$ opening a connection to the CEC adapter...

osmc@osmc:~$



osmc@osmc:~$ ./script.sh
opening a connection to the CEC adapter...
osmc@osmc:~$



Help?

Thanks!

Matt
Reply
Hey guy im having trouble setting up a script to start a slideshow from a remote folder, which i was able to launch via favorites in kodi before, that doesnt seem to be working so i thought id try callbacks but im getting an error, [bin/sh: 1: slideshow.py: not found] the full directory is /xbmc/scripts/slideshow.py

Code:
import xbmc
from time import sleep
from os import listdir

minutes =1
picfolder = "/home/pi/SharePics"

l1 = []
while 1:
    l2 = listdir(picfolder)
    if (l1 != l2):
        xbmc.executebuiltin('xbmc.slideshow(' + picfolder + ')[random]')
        l1 = l2
    for seconds in range(minutes * 60):
        sleep(1)

Any help would be appreciated.
Reply
@KenV99

Thanks for the response. Haven't checked here in a while and was never notified of your response. Thus my delay in responding to your posting.

I'll do some more looking and if I find/figure anything, I'll post back here in case anyone else is interested.

Cheers....


(2017-05-08, 19:26)KenV99 Wrote:
(2017-05-08, 18:44)stephr1 Wrote: Bump...anyone?

(2017-04-23, 17:40)stephr1 Wrote: BUMP!! Anyone offer any help here? Thx....

The events are listed in the Wiki:Add-on:Kodi_Callbacks (wiki)
There are no events for recording and I don't know how that could be done.
IF you know of another way of checking, you could write your own code to check if a recording is occurring and IF you know how to turn on the LED in code then send the codes to turn it on or off depending on coding state.
If the above is true, then you COULD use the onIntervalAlarm to call the above intermittently (like every second).
However, if you know how to code all of the above, consider writing your own addon to do it.
Reply
  • 1
  • 12
  • 13
  • 14(current)
  • 15
  • 16
  • 22

Logout Mark Read Team Forum Stats Members Help
Execute user tasks for Kodi events (callbacks ver2)3