Release - Execute user tasks for Kodi events (callbacks ver2)

  Thread Rating:
  • 3 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Post Reply
kulgan Offline
Junior Member
Posts: 9
Joined: Aug 2014
Reputation: 0
Post: #196
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.
(This post was last modified: 2017-05-05 07:27 by kulgan.)
find quote
stephr1 Offline
Junior Member
Posts: 23
Joined: Aug 2016
Reputation: 0
Post: #197
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....
find quote
KenV99 Offline
Fan
Posts: 507
Joined: Nov 2013
Reputation: 28
Post: #198
(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.
(This post was last modified: 2017-05-08 19:29 by KenV99.)
find quote
nickr Offline
Team-Kodi Member
Posts: 18,056
Joined: May 2009
Reputation: 363
Location: Christchurch NZ
Post: #199
@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 'thank user' button to give thanks :) (People with less than 20 posts won't see the "Thank you" button.)
find quote
jant90 Offline
Junior Member
Posts: 28
Joined: Apr 2011
Reputation: 1
Post: #200
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?
find quote
jant90 Offline
Junior Member
Posts: 28
Joined: Apr 2011
Reputation: 1
Post: #201
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: Action_IDs (wiki)
find quote
CaptainHero Offline
Junior Member
Posts: 29
Joined: Nov 2015
Reputation: 0
Post: #202
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!
find quote
CaptainHero Offline
Junior Member
Posts: 29
Joined: Nov 2015
Reputation: 0
Post: #203
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
find quote
valdo lopes Offline
Junior Member
Posts: 12
Joined: Nov 2010
Reputation: 0
Post: #204
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"
(This post was last modified: 2017-06-09 20:14 by valdo lopes.)
find quote
KenV99 Offline
Fan
Posts: 507
Joined: Nov 2013
Reputation: 28
Post: #205
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.
find quote
Post Reply