[RELEASE] Execute user scripts on specific XBMC actions (play starts/stops...)
#91
(2014-03-10, 10:28)flarc Wrote: Hello, thanks for your helps.

1) Ok, so currently, my settings.xml is like this:
Code:
<setting id="player_pauses" value="C:\sarah\plugins\fred\bin\huelight_high.bat" />

And the "huelight_high.bat" is like that:
Code:
@echo off
c:
cd C:\sarah\plugins\fred\bin
curl http://192.168.1.21/api/newdeveloper/lights/1/state -X PUT -d "{\"on\":true, \"bri\":228}" >> NUL

This works, but i see a brief console window appear.

2) I tried also this (xml manually edited because .vbs is not displayed in xbmc add-on configuration screen):

settings.xml:
Code:
<setting id="player_pauses" value="C:\sarah\plugins\fred\bin\huelight_high.vbs" />

huelight_high.vbs:
Code:
Set WshShell = WScript.CreateObject("WScript.Shell")
cmd = "C:\sarah\plugins\fred\bin\huelight_high.bat"
Return = WshShell.Run(cmd, 0, True)
set WshShell = Nothing

The huelight_high.bat is unchanged.

If i run manually the vbs, it works without console appearing.
But within XBMC, the command is not performed (which i can see only due to no change of light)

Does not work either with:
settings.xml:
Code:
<setting id="player_pauses" value="wscript C:\sarah\plugins\fred\bin\huelight_high.vbs" />

3) I also tried compiling the .bat into .exe, and updating accordingly the settings.xml, but does not work either.
Code:
<setting id="player_pauses" value="C:\sarah\plugins\fred\bin\huelight_high.exe" />

4) I did not try yet to put directly the long curl command into the settings.xml (i need to see how to manage the quotes within the command).

5) Last thing i would try (but i do not know yet how to do it) is calling directly a python script (that would be interpreted by xbmc's own python lib) to change hue lights.

If you have an idea to make option#1 or #2 work, it would be helpful, because i would prefer those ways of doing it. But if option#5 would work, i will take it.

The way the plugin is currently written, it does not parse the string 'wscript C:\..\huelight_high.vbs' into two separate arguments to be passed to subprocess.call().
And that python call needs the 'wscript' argument to be passed because it is being called without the shell=true option.
If I have time I might fork the master branch and come up with a way to parameterize the strings for interpretation. Something along the lines of enclosing each individual parameter in curly brackets and then have the script parse them into a tuple that can be passed in subprocess.call().

Maybe pilluli can weigh in at some point...
Reply


Messages In This Thread
Great! - by gnorf - 2013-02-27, 22:50
RE: [RELEASE] Execute user scripts on specific XBMC actions (play starts/stops...) - by KenV99 - 2014-03-10, 18:00
[RELEASE] Pilulli Revisited - by KenV99 - 2014-06-28, 18:18
Logout Mark Read Team Forum Stats Members Help
[RELEASE] Execute user scripts on specific XBMC actions (play starts/stops...)4