Controlling Philips Hue using Jython and Phue

    Mar 26 2013 | 4:42 pm
    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.
    Thank you so much.

    • May 14 2013 | 9: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 | 10: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(
      at net.loadbang.scripting.ScriptEngineBase.(
      at net.loadbang.jython.mxj.ScriptEngine.(
      (mxj) unable to construct instance of net.loadbang.jython.mxj.ScriptEngine
    • May 14 2013 | 1:32 pm
      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.
      Let me know if you can get it to work.
    • May 14 2013 | 2:23 pm
      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 to
      so I have placed in both the
      Now when I open one op the .maxpat patches in the example folders I get the above errors.
    • May 14 2013 | 2:27 pm
      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 | 2:35 pm
      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.
    • May 14 2013 | 2:40 pm
      Hmm can you post a screenshot of your lib folder ?
    • May 14 2013 | 2:43 pm
    • May 14 2013 | 2:46 pm
    • May 14 2013 | 3:04 pm
      Hmm I see you have 3 net.loadbang files there, are they different versions ?
    • May 14 2013 | 3:16 pm
      can you try with these sets of files :
    • May 16 2013 | 7:49 am
      still same errors
    • May 16 2013 | 12:39 pm
      I'm out of ideas... Do other mxj objects work ? can you try it on another system ?
    • May 16 2013 | 2:12 pm
      max works perfectly fine.
      it really is installing these hue communicating tools that doesn't seem to work.
    • May 16 2013 | 2:17 pm
      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 | 2:40 pm
      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 | 8:29 pm
      Have you made any progress with this?
    • May 27 2013 | 8:24 am
      no, can't get it to work
    • May 27 2013 | 10: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 | 12:04 pm
      I have the philips hue working in Max/MSP, thanks to Tommy Bobo, and his simplified approach.
      Is anyone interested check the code below:
    • Aug 08 2013 | 12:46 pm
      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
    • Aug 08 2013 | 2:02 pm
      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 ?
    • Aug 08 2013 | 2:06 pm
      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...
    • Aug 08 2013 | 2:29 pm
      for the unauthorized user issue see:‎
    • Aug 09 2013 | 11:33 am
      Yes it works thanks !
    • Aug 24 2013 | 12:33 am
      @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!
    • Feb 27 2014 | 7:57 am
      Can you successors post details please?
      I did controlling hue from clip api debugger ( 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 and even if using Lekirst's patch?
      Thanks in advance
    • Feb 27 2014 | 3:07 pm
      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, Also I have attached a screenshot of my lib files.
      Also check:‎
      Hope that it is of help to you!
    • Apr 23 2014 | 1:55 pm
      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 -
    • Apr 23 2014 | 8: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:
    • Feb 21 2015 | 5:14 pm
      Hi there!
      Based on your JS i have created a Max-Plugin.
      • Play COLORS with your Midi-Keyboard and the selcted bulb (Note / Velocity to Hue / Bri)
      • Filter Maximum Bri with the Bri-Filter
      • Mix Transition-Time from 0 (immediately) to very long and smooth transitions
      • The Checkbox is to keep the last Hue-State without fallback to the 0-Bri when you release the key on your keyboard - Both Options are cool - Play around!
      • Included in the JS is a Register-User Function to register a Max4Hue-User for this Plugin
    • Oct 02 2015 | 8:08 pm
      Thanks for the Max Plugin. I have it installed and and communicating with the Hue bridge, but I am getting the following errors when I send a midi signal into it:
      js: [{"error":{"type":3,"address":"/lights/undefined/state","description":"resource, /lights/undefined/state, not available"}}]
      any ideas as to what would cause this error? Thanks!
    • Oct 30 2015 | 8:37 am
      Take a look at Hue Server:
    • Mar 13 2017 | 11:15 pm
      Where do i need to put the js? (abelton > max midi effect doesn't work)
    • Mar 14 2017 | 1:54 am
      Check the hue api documentation and use maxurl, no java needed