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

  Thread Rating:
  • 3 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Post Reply
shakuyi Offline
Junior Member
Posts: 10
Joined: Oct 2015
Reputation: 1
Post: #46
Hi I think I found a bug on a windows installation I am using Kodi v16 RC3 and when I go to run "Test Add-on Native Tasks" I get the following error:

Seems like the path may not be set right for a file? Let me know if you need more info and I am using the latest zip file from Github.

Code:
16:27:32 T:5060   ERROR: $$$ [kodi.callbacks] - testHttp returned with an error: Requests Connection Error
16:27:32 T:7740  NOTICE: Log level changed to "LOG_LEVEL_DEBUG_FREEMEM"
16:27:32 T:7740  NOTICE: Enabled debug logging due to GUI setting. Level 2.
16:27:32 T:7740  NOTICE: Log level changed to "LOG_LEVEL_DEBUG_FREEMEM"
16:27:32 T:7740  NOTICE: Enabled debug logging due to GUI setting. Level 2.
16:27:32 T:7740   DEBUG: ------ Window Init () ------
16:27:33 T:7740   DEBUG: Keyboard: scancode: 0x4d, sym: 0x0113, unicode: 0x0000, modifier: 0x0
16:27:33 T:7740   DEBUG: CInputManager::OnKey: right (0xf083) pressed, action is Right
16:27:33 T:9148   DEBUG: webserver: request received for /jsonrpc
16:27:33 T:7740   DEBUG: Keyboard: scancode: 0x4d, sym: 0x0113, unicode: 0x0000, modifier: 0x0
16:27:33 T:7740   DEBUG: CInputManager::OnKey: right (0xf083) pressed, action is Right
16:27:33 T:5060   DEBUG: POParser: loaded 183 strings from file C:\Users\shokouhi\AppData\Roaming\Kodi\addons\script.service.kodi.callbacks\reso​urces\language\English\strings.po
16:27:33 T:5060   DEBUG: Previous line repeats 1 times.
16:27:33 T:5060   DEBUG: $$$ [kodi.callbacks] - Error: Builtin test failed
16:27:33 T:7740  NOTICE: Disabled debug logging due to GUI setting. Level 0.
16:27:33 T:7740  NOTICE: Log level changed to "LOG_LEVEL_NORMAL"
16:27:33 T:7740  NOTICE: Disabled debug logging due to GUI setting. Level 0.
16:27:33 T:7740  NOTICE: Log level changed to "LOG_LEVEL_NORMAL"
16:27:33 T:5060   ERROR: $$$ [kodi.callbacks] - testScriptNoShell returned with an error: Requests Connection Error
16:27:33 T:5060   ERROR: $$$ [kodi.callbacks] - Error testing testScriptNoShell
                                            <attribute 'message' of 'exceptions.BaseException' objects>
                                            Traceback (most recent call last):
                                              File "C:\Users\shokouhi\AppData\Roaming\Kodi\addons\script.service.kodi.callbacks\reso​urces\lib\tests\testTasks.py", line 226, in runTests
                                                test()
                                              File "C:\Users\shokouhi\AppData\Roaming\Kodi\addons\script.service.kodi.callbacks\reso​urces\lib\tests\testTasks.py", line 124, in testScriptNoShell
                                                with open(outfile, 'r') as f:
                                            IOError: [Errno 2] No such file or directory: 'C:\\Users\\shokouhi\\AppData\\Roaming\\Kodi\\addons\\script.service.kodi.callba​cks\\resources\\lib\\tests\\scriptoutput.txt'
16:27:33 T:5060   ERROR: $$$ [kodi.callbacks] - testScriptShell returned with an error: <attribute 'message' of 'exceptions.BaseException' objects>
                                            Traceback (most recent call last):
                                              File "C:\Users\shokouhi\AppData\Roaming\Kodi\addons\script.service.kodi.callbacks\reso​urces\lib\tasks\taskScript.py", line 120, in run
                                                p = subprocess.Popen(args, stdout=subprocess.PIPE, shell=needs_shell, stderr=subprocess.STDOUT)
                                              File "C:\Program Files (x86)\Kodi\system\python\Lib\subprocess.py", line 710, in __init__
                                                errread, errwrite)
                                              File "C:\Program Files (x86)\Kodi\system\python\Lib\subprocess.py", line 958, in _execute_child
                                                startupinfo)
                                            WindowsError: [Error 2] The system cannot find the file specified
find quote
KenV99 Offline
Fan
Posts: 505
Joined: Nov 2013
Reputation: 28
Post: #47
The Http test makes certain assumptions about your Kodi webserver settings, and if those assumptions were false, the error may have propagated into the other tests.
However, I pushed an update to attempt to read a user's webserver settings in and use them.

If you are still experiencing problems after the update, please post a full log to pastebin and post back here with the link.

BTW: The native task tests are NOT working properly on Android currently. Will work it out soon.
find quote
Calzor Suzay Offline
Member
Posts: 62
Joined: Jan 2015
Reputation: 2
Post: #48
Hi,

I used to use the original callbacks on my Raspberry pi and run it as an sh script, I'm now on a Fire TV using the new version but can't get it to call a webpage.

In the script I have:-

#!/bin/sh
#kodi.sh
curl "http://192.168.1.19:8090/json.htm?type=command&param=switchlight&idx=11&switchcmd=Set%20Level&level=0"

On the new version I'd obviously like it to just call the page http://192.168.1.19:8090/json.htm?type=c...el&level=0

It doesn't work, when I test I get file (location), line 106,in run u=requests.get(self.taskKwargs['http']+self.runtimeargs,timeout=20) TypeError: cannot concatenate 'str' and 'list'

Also with the error pops in a windows that on a fire stick you can't seem to get to the focus of it's permanently stuck on the screen and you have to pull the plug.
find quote
KenV99 Offline
Fan
Posts: 505
Joined: Nov 2013
Reputation: 28
Post: #49
(2016-02-06 20:53)Calzor Suzay Wrote:  Hi,

I used to use the original callbacks on my Raspberry pi and run it as an sh script, I'm now on a Fire TV using the new version but can't get it to call a webpage.

In the script I have:-

#!/bin/sh
#kodi.sh
curl "http://192.168.1.19:8090/json.htm?type=command&param=switchlight&idx=11&switchcmd=Set%20Level&level=0"

On the new version I'd obviously like it to just call the page http://192.168.1.19:8090/json.htm?type=c...el&level=0

It doesn't work, when I test I get file (location), line 106,in run u=requests.get(self.taskKwargs['http']+self.runtimeargs,timeout=20) TypeError: cannot concatenate 'str' and 'list'

Also with the error pops in a windows that on a fire stick you can't seem to get to the focus of it's permanently stuck on the screen and you have to pull the plug.

I pushed an update to catch that error.
The actual http connection and the parameters need to be separated.
So in the task the http string would be : http://192.168.1.19:8090/json.htm
Then in the event, the 'Var subbed argument string would be: '?type=command&param=switchlight&idx=11&switchcmd=Set%20Level&level=0'

Let me know if that fixes that for you.
find quote
Calzor Suzay Offline
Member
Posts: 62
Joined: Jan 2015
Reputation: 2
Post: #50
Yes that got it workingSmile
My lights come on and off with movies now, thanks Smile
find quote
fantasticn Offline
Senior Member
Posts: 289
Joined: Dec 2012
Reputation: 2
Location: Germany
Post: #51
Callbacks addon is working just fine for me. Does anybody know a way to use it to wake up an Android TV Box (Shield TV) from sleep mode (some builtin "StartAndroidActivity"-command or any python-script that will work)? The Android box is not actually in standby mode. It is more like an Android tablet with display off and locked. So Kodi and the Callbacks addon are still running and the box itself is still accessible via network. I would like to start the Android TV box whenever I access it via Airplay, so I can integrate the box into my Airplay.based multiroom audio system.

Thanks in advance for any help!
find quote
KenV99 Offline
Fan
Posts: 505
Joined: Nov 2013
Reputation: 28
Post: #52
(2016-02-13 09:46)fantasticn Wrote:  Callbacks addon is working just fine for me. Does anybody know a way to use it to wake up an Android TV Box (Shield TV) from sleep mode (some builtin "StartAndroidActivity"-command or any python-script that will work)? The Android box is not actually in standby mode. It is more like an Android tablet with display off and locked. So Kodi and the Callbacks addon are still running and the box itself is still accessible via network. I would like to start the Android TV box whenever I access it via Airplay, so I can integrate the box into my Airplay.based multiroom audio system.

Thanks in advance for any help!

Unfortunately this is non-trivial. The Kodi documentation doesn't indicate that there is any python bridge to the Android API's. I believe that you would need to implement a 'WakefulBroadcastReceiver' to then wake the device when Airplay is utilized.
See: http://developer.android.com/reference/a...eiver.html

This would need to be done in Java and is beyond my abilities. Good luck.
find quote
fantasticn Offline
Senior Member
Posts: 289
Joined: Dec 2012
Reputation: 2
Location: Germany
Post: #53
Hi KenV99,

thanks for your reply. Sounds complicated. I was hoping for kind of an Android app I could start that would cause the box to wake up. But all I could find was tons of apps that will put it asleep or that will just wake it up by triggering the nearfield sensor of a smartphone (which the box does not have). Alternatively I thought about some keystroke I could send (e.g. sending the "keyevent 26" through adb shell causes the box to wake up - that is how I have managed to get kind of a "wake on lan" functionality for it). But I was not able to figure out how to do it with the callbacks addon. Your statement now is a bit discouraging.

Best regards,

FantasticN
find quote
fantasticn Offline
Senior Member
Posts: 289
Joined: Dec 2012
Reputation: 2
Location: Germany
Post: #54
Hi KenV99,

I now found a workaround, thanx to your addon: Since the Shield TV box consumes only 1 watt more in idle than in sleep mode I will keep it fully running all the time. Instead of shutting down the Shield TV box, the TV and the AV-receiver all together via CEC-function I have the "Exit"-button of Kodi sending a http-request to my home-automation which will then turn off the power plug for the TV and AV-receiver. So Shield TV box will stay on, but TV and AV-receiver will be powered off then. Same will happen after 2 hours of idle time, http-request triggered by your addon (I have to wait this long because if I start an Android app or an Android game it will also be considered as idle time from Kodi perspective). To have the TV and the AV-receiver turn on again by pressing a button on the remote control of my Shield TV box I had to apply I trick: I have the screensaver in Kodi turn on after 1 minute and when I hit any key on the remote-control it will turn off again - this event is recognized by your addon and will then execute a http-request causing my homeautomation to switch on the plug for TV and AV-receiver. This also happens automatically when accessing the Shield TV box via airplay, so sound (and TV) will be switched on at once when I use the Shield TV as a multiroom audio receiver together with my other Airplay-devices. It is almost like Sonos or any other multiroom audio solution :-)

But here is another question: Could you maybe implement a timer clock as trigger for tasks? E.G. I would like to have the device stream a certain internet radio channel in the morning and turn in off again after midday etc.

Best regards,

FantasticN
find quote
KenV99 Offline
Fan
Posts: 505
Joined: Nov 2013
Reputation: 28
Post: #55
(2016-02-16 14:37)fantasticn Wrote:  Hi KenV99,

I now found a workaround, thanx to your addon: Since the Shield TV box consumes only 1 watt more in idle than in sleep mode I will keep it fully running all the time. Instead of shutting down the Shield TV box, the TV and the AV-receiver all together via CEC-function I have the "Exit"-button of Kodi sending a http-request to my home-automation which will then turn off the power plug for the TV and AV-receiver. So Shield TV box will stay on, but TV and AV-receiver will be powered off then. Same will happen after 2 hours of idle time, http-request triggered by your addon (I have to wait this long because if I start an Android app or an Android game it will also be considered as idle time from Kodi perspective). To have the TV and the AV-receiver turn on again by pressing a button on the remote control of my Shield TV box I had to apply I trick: I have the screensaver in Kodi turn on after 1 minute and when I hit any key on the remote-control it will turn off again - this event is recognized by your addon and will then execute a http-request causing my homeautomation to switch on the plug for TV and AV-receiver. This also happens automatically when accessing the Shield TV box via airplay, so sound (and TV) will be switched on at once when I use the Shield TV as a multiroom audio receiver together with my other Airplay-devices. It is almost like Sonos or any other multiroom audio solution :-)

But here is another question: Could you maybe implement a timer clock as trigger for tasks? E.G. I would like to have the device stream a certain internet radio channel in the morning and turn in off again after midday etc.

Best regards,

FantasticN

I thinks that I can do that, but it may be a little bit since I'm bogged down with work. If I can work it out easily it might be sooner.
find quote
fantasticn Offline
Senior Member
Posts: 289
Joined: Dec 2012
Reputation: 2
Location: Germany
Post: #56
No prob. Just take your time. It is not high priority to me. But I think it would complete the Callbacks addon for also becoming an omnipotent timer.

Thanks again for your support!
find quote
KenV99 Offline
Fan
Posts: 505
Joined: Nov 2013
Reputation: 28
Post: #57
(2016-02-17 08:00)fantasticn Wrote:  No prob. Just take your time. It is not high priority to me. But I think it would complete the Callbacks addon for also becoming an omnipotent timer.

Thanks again for your support!

Please download the newest from the nonrepo branch: https://github.com/KenV99/script.service...onrepo.zip
The time you input for on Daily Alarm is 24h clock time.
Let me know if this works for you.
Also, there are some new tools in Settings for updating the script directly from GitHub. This part is still kind of experimental. When the next time comes for an update, please give it a try from there and again, report back if it's working for you.

BTW, over two weeks ago I submitted to the official repo, but have yet to hear back from them.
find quote
fantasticn Offline
Senior Member
Posts: 289
Joined: Dec 2012
Reputation: 2
Location: Germany
Post: #58
Hi KenV99,

thank you very much for integrating the timer. However, I tried the new version on my Windows machine and it does not work. I get an error message right at the start of Kodi. I tried completely deleting the addon and then reinstalling it via zip-file, I also tried deleting the settings.xml file. But it did not help.

Here ist the excerpt from the log-file:

08:18:37 T:6428 ERROR: EXCEPTION Thrown (PythonToCppException) : -->Python callback/script returned the following error<--
- NOTE: IGNORING THIS CAN LEAD TO MEMORY LEAKS!
Error Type: <type 'exceptions.ImportError'>
Error Contents: cannot import name schedule
Traceback (most recent call last):
File "C:\Users\norma\AppData\Roaming\Kodi\addons\script.service.kodi.callbacks-nonrepo\default.py", line 49, in <module>
from resources.lib.publisherfactory import PublisherFactory
File "C:\Users\norma\AppData\Roaming\Kodi\addons\script.service.kodi.callbacks-nonrepo\resources\lib\publisherfactory.py", line 24, in <module>
from resources.lib.publishers.schedule import SchedulePublisher
File "C:\Users\norma\AppData\Roaming\Kodi\addons\script.service.kodi.callbacks-nonrepo\resources\lib\publishers\schedule.py", line 19, in <module>
from resources.lib import schedule
ImportError: cannot import name schedule
-->End of Python script error report<--

Regards,

FantasticN
find quote
KenV99 Offline
Fan
Posts: 505
Joined: Nov 2013
Reputation: 28
Post: #59
(2016-02-18 09:28)fantasticn Wrote:  Hi KenV99,

thank you very much for integrating the timer. However, I tried the new version on my Windows machine and it does not work. I get an error message right at the start of Kodi. I tried completely deleting the addon and then reinstalling it via zip-file, I also tried deleting the settings.xml file. But it did not help.

Here ist the excerpt from the log-file:

08:18:37 T:6428 ERROR: EXCEPTION Thrown (PythonToCppException) : -->Python callback/script returned the following error<--
- NOTE: IGNORING THIS CAN LEAD TO MEMORY LEAKS!
Error Type: <type 'exceptions.ImportError'>
Error Contents: cannot import name schedule
Traceback (most recent call last):
File "C:\Users\norma\AppData\Roaming\Kodi\addons\script.service.kodi.callbacks-nonrepo\default.py", line 49, in <module>
from resources.lib.publisherfactory import PublisherFactory
File "C:\Users\norma\AppData\Roaming\Kodi\addons\script.service.kodi.callbacks-nonrepo\resources\lib\publisherfactory.py", line 24, in <module>
from resources.lib.publishers.schedule import SchedulePublisher
File "C:\Users\norma\AppData\Roaming\Kodi\addons\script.service.kodi.callbacks-nonrepo\resources\lib\publishers\schedule.py", line 19, in <module>
from resources.lib import schedule
ImportError: cannot import name schedule
-->End of Python script error report<--

Regards,

FantasticN
Should be fixed now. Please download the latest nonrepo branch.
find quote
bigbadrabbit Offline
Senior Member
Posts: 260
Joined: Sep 2008
Reputation: 2
Location: Austria
Post: #60
I cannot get any of my scripts to execute. They work perfectly with previous versions of your plugin from the old thread.

Here's one of my scripts (Player_START.sh) that should get executed when the player starts:
Code:
#!/bin/bash

/usr/bin/osascript <<-EOF

tell application "Hue Server" to run command "Wohnzimmer Off"
delay 0.2

do shell script "curl http://localhost:5005/Wohnzimmer/pause"
delay 0.2

do shell script "curl http://192.168.0.20/goform/formiPhoneAppDirect.xml?SDHDMI"
do shell script "curl http://192.168.0.20/goform/formiPhoneAppDirect.xml?MSDOLBY%20DIGITAL"


EOF

And here're the errors:
Code:
18:46:39 T:123145304526848   ERROR: /Users/macmini_home/Library/Application Support/Kodi/addons/script.service.kodi.callbacks-nonrepo/resources/lib/watchdog/observers/__init__.py:83: UserWarning: Failed to import fsevents and kqueue. Fall back to polling.
                                              warnings.warn("Failed to import fsevents and kqueue. Fall back to polling.")
18:46:39 T:123145304526848   ERROR: Previous line repeats 1 times.
18:46:39 T:123145304526848  NOTICE: $$$ [kodi.callbacks] - Running Test for Event: E1
18:46:39 T:123145304526848  NOTICE: $$$ [kodi.callbacks] - Settings for test read
18:46:39 T:123145304526848  NOTICE: $$$ [kodi.callbacks] - Creating subscriber for test
18:46:39 T:123145304526848  NOTICE: $$$ [kodi.callbacks] - Test subscriber created successfully
18:46:39 T:123145304526848  NOTICE: $$$ [kodi.callbacks] - Running test
18:46:39 T:123145304526848 WARNING: CSkinInfo: failed to load skin settings
18:46:39 T:123145304526848   ERROR: /Users/macmini_home/Library/Application Support/Kodi/addons/script.service.kodi.callbacks-nonrepo/resources/lib/dialogtb.py:47: DeprecationWarning: object.__init__() takes no parameters
                                              super(MessageDialog, self).__init__(*args, **kwargs)
18:46:40 T:123145308819456 WARNING: DARWINOSX: underflow (0 vs 4096 bytes)

Kodi Krypton
macOS Sierra 10.12
Mac mini (late 2012)
(This post was last modified: 2016-02-18 19:49 by bigbadrabbit.)
find quote
Post Reply