Forums > MaxMSP

Controlling Philips Hue using Jython and Phue

March 26, 2013 | 4:42 pm

Hi.

I am trying to write a patch to control the Philips Hue lights.
I have found a Python Library that i can use in conjunction with Jython.
I just have no idea and have found little info on how to get all the components connected and running.

If anyone has been working on this, I would really appreciate a little help.

What I have been using https://github.com/studioimaginaire/phue and https://github.com/cassiel/net.loadbang.jython

Thank you so much.


May 14, 2013 | 2:28 am

Did you figure out how to install all components? I am still having trouble to get the system up and running..


May 14, 2013 | 3:31 am

The error I am getting is the following:

java.lang.NoClassDefFoundError: Could not initialize class net.loadbang.jython.JythonEngineImpl
at net.loadbang.jython.mxj.ScriptEngine.buildEngine(ScriptEngine.java:58)
at net.loadbang.scripting.ScriptEngineBase.(ScriptEngineBase.java:61)
at net.loadbang.jython.mxj.ScriptEngine.(ScriptEngine.java:42)
(mxj) unable to construct instance of net.loadbang.jython.mxj.ScriptEngine



Nat
May 14, 2013 | 6:32 am

 

Hi Guys, I’d be glad to help you guys, I’m the one who did the phue library.

Seems like you have a problem with your Jython installation.  You will need Jython 2.7 to use phue.

Make sure you download it here.

Check out these instructions : https://github.com/cassiel/net.loadbang.jython#jython-27

Let me know if you can get it to work.

 


May 14, 2013 | 7:23 am

I have downloaded jyphon 2.7.

I have placed all the contents of the distribution folder of net.loadbang.jython-master and placed it in /Applications/Max5/Cycling ’74/java/lib.

I have placed all the contents of the distribution folder of net.loadbang.lib-master and placed it in /Applications/Max5/Cycling ’74/java/lib.

I am not quite sure were to place the phue.py to
so I have placed phue.py in both the
net.loadbang.jython-master/examples/
and
net.loadbang.jython-master/examples/max5/

Now when I open one op the .maxpat patches in the example folders I get the above errors.



Nat
May 14, 2013 | 7:27 am

In your /Applications/Max5/Cycling ’74/java/lib folder do you have a jython.jar file ?

The download on github comes with jython 2.5 which needs to be removed and you need to replace it with the jython from 2.7. Also, is there  a Lib folder with a bunch of python files in the same directory ?


May 14, 2013 | 7:35 am

In the java/lib folder I have now replaced the jython.jar file.
And I have added the Lib folder with the python files.
However, still no luck.



Nat
May 14, 2013 | 7:40 am

Hmm can you post a screenshot of your lib folder ?


May 14, 2013 | 7:43 am

screenshot


May 14, 2013 | 7:46 am

hereby the screenshot

Attachments:
  1. screenshot-lib-folder-maxmsp


Nat
May 14, 2013 | 8:04 am

Hmm I see you have 3 net.loadbang files there, are they different versions ?



Nat
May 14, 2013 | 8:16 am

can you try with these sets of files :

https://dl.dropboxusercontent.com/u/149476/jython2.zip


May 16, 2013 | 12:49 am

still same errors



Nat
May 16, 2013 | 5:39 am

I’m out of ideas… Do other mxj objects work ? can you try it on another system ?


May 16, 2013 | 7:12 am

max works perfectly fine.
it really is installing these hue communicating tools that doesn’t seem to work.



Nat
May 16, 2013 | 7:17 am

Well, from what I can see the problem doesn’t come from phue but from jython, perhaps communicate with the author of the jython mxj object ?


May 16, 2013 | 7:40 am

If anything’s going wrong in the Java/Jython world you should be seeing it in the Max window. The list of JARs looks reasonable (if that jython.jar is 2.7) but the contents of Lib don’t match what I see in mine.


May 25, 2013 | 1:29 pm

Have you made any progress with this?


May 27, 2013 | 1:24 am

no, can’t get it to work


May 27, 2013 | 3:00 am

Can you provide a complete list of what’s in `Cycling ’74/java/lib`, and confirm what version of Jython you’re using? Also: what exactly is printed in the Max window?


May 28, 2013 | 5:04 am

I have the philips hue working in Max/MSP, thanks to Tommy Bobo, and his simplified approach. http://vimeo.com/64914947

Is anyone interested check the code below:

<code>

– Pasted Max Patch, click to expand. –

</code>


August 8, 2013 | 5:46 am

Hi,

I tried to run the patch from Lekirst but in the max window I have this message : js: can’t find file BulbArray.js

Did I miss something ?

Thanks for request


August 8, 2013 | 7:02 am

I finnaly understood that i have to copy the js BulbArray.js content in the object, I replace the ip address by mine but I have this error message :

print: [{"error":{"type":1,"address":"/lights","description":"unauthorized user"}}

Any idea ?



Nat
August 8, 2013 | 7:06 am

Not sure how the javascript system works but in order to talk to the Bridge you need to be registered with the api, this is usually done by sending a post request while the button on the bridge has been pressed…


August 8, 2013 | 7:29 am

for the unauthorized user issue see:

developers.meethue.com/gettingstarted.html‎


August 9, 2013 | 4:33 am

Yes it works thanks !


August 23, 2013 | 5:33 pm

@enzo and lekirst
If you could post details on your working setups that would be great— Max version, OS version, installation of lib files…just want to make sure I can get this going before buying the hardware.
thanks in advance!



jin
February 26, 2014 | 11:57 pm

Can you successors post details please?

I did controlling hue from clip api debugger (http://developers.meethue.com/gettingstarted.html) with no problem.
I can’t control from Max patch that Lekirst posted.
I set up ip in BulbArray.js too.

Should I still need to use these https://github.com/studioimaginaire/phue and https://github.com/cassiel/net.loadbang.jython even if using Lekirst’s patch?

Thanks in advance
Jin


February 27, 2014 | 7:07 am

Hey Jin,
It’s been a while so I can’t exactly remember how I got it working. But check the approach by Tommy Bobo, http://vimeo.com/64914947. Also I have attached a screenshot of my lib files.
Also check: developers.meethue.com/gettingstarted.html‎
Hope that it is of help to you!


April 23, 2014 | 6:55 am

Hi.

Thanks for this topic, I had been able to run Hue very easily!

Now, I made a little modify on the patch following Lekirst’s js and cURL approach, allows to use Max’s common style message like (bri $1 sat $2) .

test patch pasted in below, and js in Gist -

https://gist.github.com/tgck/11185861#file-huerequestbuilder-js

– Pasted Max Patch, click to expand. –


Nat
April 23, 2014 | 1:40 pm

For those curious, in Max 6.1.7 there is direct support for this using the maxcurl object (or via javascript)
This means that it should work on both Osx and Windows and doesn’t require any 3rd party externals:

JS file: https://gist.github.com/natcl/11231597/dcd019c14bc098aa4adc0305cbad62bb357b0958

– Pasted Max Patch, click to expand. –

Viewing 31 posts - 1 through 31 (of 31 total)