Guest - Testers are needed for the reworked CDateTime core component. See... https://forum.kodi.tv/showthread.php?tid=378981 (September 29) x
  • 1
  • 11
  • 12
  • 13(current)
  • 14
  • 15
  • 22
Release Execute user tasks for Kodi events (callbacks ver2)
Hello, I admire your work. Keep it going!
I use Windows 7 box and I have created an event on Playback Started.
This triggers a Http request to my remote server.
Everything works fine when I play a local video.
If I use YouTube addon to stream a video, task is being triggered only when its type is script -> Windows batch file.
When I set Task as PYTHON or HTTP, its not working.
This occurs only when the video is YouTube stream.
Any suggestions?

Thank you in advance
Reply
Hi,

Im running Kodi on my Nas QNAP, on the same machine i have a torrent client, what im trying to do is to start/stop the torrent files when Kodi's playback start/stop.

If i use the command "transmission-remote -tall --stop" through SSH it works and all my torrents stop, so what i tried to do is to create a file start.sh with this code
Code:
#!/bin/sh
transmission-remote -n "admin:admin" -tall --stop
but when i try "Test Command" i got an error "transmission-remote command not found

Any help? Thanks
Reply
Hi I was hoping someone here can help me with something that might be simple. I am trying to run a script for background music within Kodi and I am putting in this string #!/bin/sh kodi-send -a "PlayMedia(/sdcard/music.mp3)"; I put it under "var subbed arg string" Did I enter that correctly or did I miss a step? Thanks for anyones input on this.
Reply
Thanks a lot KenV99 for this, it's an absolute blinder and will help me a lot towards automating the lights in my room!

I have a scenario that I don't think is catered for (I'll happily be corrected) : I'm planning on using this to turn lights off and on to complement pause / play / stop / resume working in conjunction with eventghost and uirt, but my lights do not have separate "off" and "on" IR patterns, only a toggle.

Is there any way a "Paused Stopped" event could be captured so that if you play (lights off) then pause (lights on) then stop (lights off) the lights are not toggled when a paused film is stopped?
It's not going to be common, but I can see it happening and causing the lights to get out of sequence.

Thanks a lot
Reply
I've installed the addon on SPMC 16 (fork of kodi for android) but it doesn't work properly. When I tested my task, I got an error. Log file said that addons was using wrong directory: default for kodi instead of spmc path:
Code:
Could not locate po at  /sdcard/Android/data/org.xbmc.kodi/files/.kodi/addons/script.service.kodi.callbacks/resources/language/English/strings.po

I tried to fix it by editing files ./resources/lib/utils/kodipathtools.py and ./resources/lib/utils/poutil.py, but I still get the same error with correct path:
Code:
17:52:45.656 T:18446744072992061744  NOTICE: Could not locate po at  /sdcard/Android/data/com.semperpax.spmc16/files/.spmc/addons/script.service.kodi.callbacks/resources/language/English/strings.po
17:52:50.764 T:18446744072992061744  NOTICE: $$$ [kodi.callbacks] - Running Test for Event: E1
17:52:53.206 T:18446744072992061744   ERROR: EXCEPTION Thrown (PythonToCppException) : -->Python callback/script returned the following error<--
                                             - NOTE: IGNORING THIS CAN LEAD TO MEMORY LEAKS!
                                            Error Type: <type 'exceptions.AttributeError'>
                                            Error Contents: 'TestLogger' object has no attribute 'LOGERROR'
                                            Traceback (most recent call last):
                                              File "/storage/emulated/0/Android/data/com.semperpax.spmc16/files/.spmc/addons/script.service.kodi.callbacks/script.py", line 182, in <module>
                                                test(eventId)
                                              File "/storage/emulated/0/Android/data/com.semperpax.spmc16/files/.spmc/addons/script.service.kodi.callbacks/script.py", line 69, in test
                                                subscriber = subscriberfactory.createSubscriber(key)
                                              File "/storage/emulated/0/Android/data/com.semperpax.spmc16/files/.spmc/addons/script.service.kodi.callbacks/resources/lib/subscriberfactory.py", line 74, in createSubscriber
                                                self.logger.log(loglevel=self.logger.LOGERROR,
                                            AttributeError: 'TestLogger' object has no attribute 'LOGERROR'
                                            -->End of Python script error report<--

File /sdcard/Android/data/com.semperpax.spmc16/files/.spmc/addons/script.service.kodi.callbacks/resources/language/English/strings.po exists and it looks like the addon has permission to read it.

What else can I modify to make addon working?
Reply
Is there a reference list that shows what events are actually caused by? I want to pause at the beginning of each video in a playlist so I don't keep sleeping through videos, but I don't know which playback event would be the one to call the trigger from. I see onQueueNextItem which seems like it may be correct, but I have no way of knowing for sure.
Reply
Would it be possible to have hooks on volume up and down?
What I want to achieve is to be able to control an external IR to change the volume on my receiver when passthrough is active.
Reply
Currently running Kodi 16 with LibreELEC 7.0.3 and installed the latest callback add-on. (But same on OpenElec).
Made simple python scripts to switch the RPi3 touchscreen on and off.
This works wonderfully with onScreensaverActivated and onScreensaverDeactivated. Also in the log files the calls are filed.
Unfortunately not for onShutdown, even if I add a delay to allow the deamon to do its thing. No entry in the log file.
With debug on, the script gets activated but "interrupted". No positive effect either.

Any help?
Reply
Hi,
I use Kodi 16.1, Callbacks 1.0.0. from repo, Lubuntu 16.04 x86_64.

When testing the Callbacks, the error is:

Code:
07:27:43 T:140713899562752   ERROR: $$$ [kodi.callbacks] - Testing for task type: script
                                            Settings: {u'use_shell': True, 'notify': True, u'scriptfile': u'/bin/bash', 'taskid': u'T1',
'userargs': u'', 'type': u'script', u'waitForCompletion': True}
                                            Runtime kwargs: {}
                                            ERROR encountered for Task , Event onIdle:E1
                                            ERROR mesage: <attribute 'message' of 'exceptions.BaseException' objects>
07:27:43 T:140713899562752 WARNING: CSkinInfo: failed to load skin settings                                            
07:28:21 T:140714040039168  NOTICE: $$$ [kodi.callbacks] - Task starting for onIdle:E1                                  
07:28:21 T:140714040039168  NOTICE: $$$ [kodi.callbacks] - Command for Task T1, Event onIdle:E1 completed succesfully!  
                                            The following message was returned: taskScript ARGS = bash                  
                                                SYSEXEC = None                                                          
                                             BASEDIR = /bin                                                            
                                            Process returned no data                                                    
07:28:21 T:140714040039168  NOTICE: $$$ [kodi.callbacks] - Task finalized for onIdle:E1

No matter what Task & Event I test, the error is similar (and it is displayed also on the screen).

EDIT: Sorry. I reinstalled from github, reset settings and the error disappeared. Not sure what went wrong earlier, it was a clean install...
Reply
Hi,

I installed this addon in libreelec (v7.0.0 -- kodi 16.1) so that I can turn off the TV and sound system when a screensaver starts and turn them back on when the screensaver deactivates.

I created a small /bin/bash script that uses cec-client to do the turnon/turnoff, and setup the kodi callbacks service to call these scripts from /storage/bin/tvoff and /storage/bin/tvon.

It appears that the python subprocess software is doing the equivalent of:

Code:
cd /storage/bin
tvon
The error in the log was:

Code:
2:29:34 T:546819797216  NOTICE: $$$ [kodi.callbacks] - Testing for task type: script
                                            Settings: {u'use_shell': True, 'notify': True, u'scriptfile': u'/storage/bin/tvon', 'taskid': u'T2', 'userargs': u'', 'type': u'script', u'waitForCompletion': True}
                                            Runtime kwargs: {}
                                            Command for Task T2, Event onScreensaverDeactivated completed succesfully!
                                            The following message was returned: taskScript ARGS = tvon
                                                SYSEXEC = None
                                             BASEDIR = /storage/bin
                                            Process returned data: [/bin/sh: tvon: not found]
12:29:34 T:546819797216 WARNING: CSkinInfo: failed to load skin settings

I eventually resolved it by looking at the ENVIRON for the kodi.bin process (tr '\000' '\012' < /proc/XXXX/environ) and finding a directory in the $PATH. Moving the scripts to

Code:
/storage/.kodi/addons/virtual.network-tools/bin/tvon
/storage/.kodi/addons/virtual.network-tools/bin/tvoff

Solves the issue for me.

I am thinking that "basedir" needs to be added to the end of the $PATH variable somehow in the environment of the subprocess when running a shell process. LibreElec only has one writable directory in the $PATH. The other directories (/usr/bin:/usr/sbin, etc) are all on a Read Only filesystem.

In any case it is now working great for me...I can walk away from the TV and be confident it won't stay on all night.

Thanks!
Reply
I'm using the onStereoModeChange event to trigger a script that switches my projector to 3D mode. Works as expected - movie starts; Kodi detects 3D file and changes to stereoscopic mode; Callbacks addon triggers my script.

The problem is that there're no onStereoModeSTART or onStereoModeEND events available.

I need to run another script (onPlayBackEnded) to switch the projector back to 2D when the player stops. Kodi is also set to change to 2D once playback ends.

So right now when the movie ends - onPlayBackEnds triggers the script to switch projector to 2D; but simultaneously onStereoModeChange also triggers the "switch projector to 3D"-script again.

Is there another way to prevent this behavior?
Reply
(2017-03-11, 18:47)bigbadrabbit Wrote: I'm using the onStereoModeChange event to trigger a script that switches my projector to 3D mode. Works as expected - movie starts; Kodi detects 3D file and changes to stereoscopic mode; Callbacks addon triggers my script.

The problem is that there're no onStereoModeSTART or onStereoModeEND events available.

I need to run another script (onPlayBackEnded) to switch the projector back to 2D when the player stops. Kodi is also set to change to 2D once playback ends.

So right now when the movie ends - onPlayBackEnds triggers the script to switch projector to 2D; but simultaneously onStereoModeChange also triggers the "switch projector to 3D"-script again.

Is there another way to prevent this behavior?

The way to do this is to pass the variable 'stereoMode' to your script and then use a conditional to run one bit of code if it is a 3D mode and another bit if it is not...

Note: the last time I looked into the possible modes they were:
"off", "split_vertical", "split_horizontal", "row_interleaved", "hardware_based", "anaglyph_cyan_red", "anaglyph_green_magenta", "monoscopic"
Reply
Question 
Hello,

Thank you for this add-on. I'm runningKodi on Linux and want to create a bash script so my files are moved after playback.
I first thought it was really easy to write, this might be why it doesn't work... tried on my own and read the 13 pages before asking for help.
Code:
#!/bin/bash
# selected event: onPlayBackEnded

mv $1 /home/lukas/done/

echo $1 moved

Thanks
Reply
@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
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
  • 1
  • 11
  • 12
  • 13(current)
  • 14
  • 15
  • 22

Logout Mark Read Team Forum Stats Members Help
Execute user tasks for Kodi events (callbacks ver2)3
This forum uses Lukasz Tkacz MyBB addons.