Jump to content

Welcome, Guest!

Be a part of CinemaVision today! Once registered and logged in, you will have access to public chat and your own private messenger, you can view and contribute guides, collaborate on the forums, review downloads, give reputation to your fellow members, contribute content and so much more. Registering is quick and completely free, so what are you waiting for?
   Sign In    Sign Up

Become a RedCarpet Club Member Today!

Lorem ipsum dolor sit amet, sea eu causae aperiri periculis, iusto affert soleat an sea, soluta petentium inciderint nec no. Dolorum reprimique ullamcorper sed ad. Ei quo malorum singulis, tota mundi feugait ut pro. Choro utamur inimicus ex sea. Tota dicit te usu. Sea ad erant possim reformidans. An modus detraxit postulant vel. Per no habeo ludus qualisque. Vix legere singulis legendos et, an cum eius soluta accumsan. Facer discere no nec.
   Join Now

Download the Kodi Add-on Today!

Lorem ipsum dolor sit amet, sea eu causae aperiri periculis, iusto affert soleat an sea, soluta petentium inciderint nec no. Dolorum reprimique ullamcorper sed ad. Ei quo malorum singulis, tota mundi feugait ut pro. Choro utamur inimicus ex sea. Tota dicit te usu. Sea ad erant possim reformidans. An modus detraxit postulant vel. Per no habeo ludus qualisque. Vix legere singulis legendos et, an cum eius soluta accumsan. Facer discere no nec.
  • 0
Sign in to follow this  
McSwindler

Python script minimizes Kodi

Question

I'm trying to get my LimitlessLED lights to dim til off before the movie starts, I've created a python script that does this fine when ran from the windows command prompt.

However, when I test it or try to run it in sequence from CinemaVision, the Kodi window gets minimized and the script doesn't run. I can maximize Kodi again and everything is fine, it doesn't crash, and the test window doesn't have any errors nor does the log.

My files are as follows:

Limitless-Lights-Off.cvaction

python://C:\Users\James\AppData\Roaming\Kodi\Actions\limitless-onoff.py
192.168.0.12
off
2

limitless-onoff.py

import milight, sys

controller = milight.MiLight({'host': sys.argv[1], 'port': 8899}, wait_duration=0)
light = milight.LightBulb(['rgbw'])

if sys.argv[2] == "on":
	controller.send(light.on(int(sys.argv[3])))
	controller.send(light.fade_up(int(sys.argv[3]))) 
elif sys.argv[2] == "off":
	controller.send(light.on(int(sys.argv[3])))
	controller.send(light.fade_down(int(sys.argv[3])))
	controller.send(light.off(int(sys.argv[3])))

 

 

Any ideas?

Share this post


Link to post
Share on other sites

3 answers to this question

Recommended Posts

  • 0

Well, I got it working by tweaking the ScriptCommand class in actions.py

I changed

subprocess.Popen(command)

to

runscript = 'XBMC.RunScript({0})'.format(','.join(command))
xbmc.executebuiltin(runscript) 

and it works great, only caveat is I had to copy the milight library into my Actions folder

and standalone python is no longer needed

  • Upvote 1

Share this post


Link to post
Share on other sites
  • 0
10 hours ago, McSwindler said:

I'm trying to get my LimitlessLED lights to dim til off before the movie starts, I've created a python script that does this fine when ran from the windows command prompt.

However, when I test it or try to run it in sequence from CinemaVision, the Kodi window gets minimized and the script doesn't run. I can maximize Kodi again and everything is fine, it doesn't crash, and the test window doesn't have any errors nor does the log.

My files are as follows:

Limitless-Lights-Off.cvaction


python://C:\Users\James\AppData\Roaming\Kodi\Actions\limitless-onoff.py
192.168.0.12
off
2

limitless-onoff.py


import milight, sys

controller = milight.MiLight({'host': sys.argv[1], 'port': 8899}, wait_duration=0)
light = milight.LightBulb(['rgbw'])

if sys.argv[2] == "on":
	controller.send(light.on(int(sys.argv[3])))
	controller.send(light.fade_up(int(sys.argv[3]))) 
elif sys.argv[2] == "off":
	controller.send(light.on(int(sys.argv[3])))
	controller.send(light.fade_down(int(sys.argv[3])))
	controller.send(light.off(int(sys.argv[3])))

Any ideas?

Excellent find. I'm going to pose this question to our developer to see what could have been causing Kodi to minimize. I didn't see that Limitless offered any kind of REST API, which is disappointing. I did find that openHAB has hooks into Limitless LED that might simplify your whole set up if you're interested.

Share this post


Link to post
Share on other sites
  • 0
1 hour ago, Ragnarok said:

Excellent find. I'm going to pose this question to our developer to see what could have been causing Kodi to minimize. I didn't see that Limitless offered any kind of REST API, which is disappointing. I did find that openHAB has hooks into Limitless LED that might simplify your whole set up if you're interested.

I have been using If This Then Node to work with IFTTT, which was working fine for CinemaVision, but the limitless support is lacking and wouldn't let me gradually fade down the lights like I wanted. I didn't realize openHAB had limitless support, I might have to switch to that, looks like I can use that to spoof a Hue bridge and get it working with my Amazon Echo too...but that's another topic for another forum :P 

 

Back on topic: I made another tweak to the actions.py file which allows for scripts to be relative to the action file. Once I get back home, I'll probably make a pull request on github in case y'all want to use those tweaks.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

About Us

CinemaVision began in 2014 as a collaboration to create content for use with your home theater, offering movie trivia slides and video bumpers. It has since grown to be THE PREMIER WAY to create and customize your preshow experience. Download the CinemaVision add-on for Kodi today from the official Kodi repository, and easily create a sequence of trivia, videos, trailers, home automation triggers and more that will bring the experience of a movie theater straight to your screen!

×

Important Information

By using this site, you agree to our Guidelines and Terms of Use.