Philips Hue

Thanks! now it works.

:smiley:

Glad to hear it’s working!

Hi,

I want to use this Hue node for one of my project, but when I import the TOX, I have an error and I don’t know how to fix that. Can someone helps me ?

Thanks,


Hi MFagniard,

Matthew here - what version of the tox are you using?

Hi @raganmd,

Sorry for the latish reply.

I’m using the TOX in the release folder. I don’t have any error when i’m importing the TOX.
I’m entering the IP adress and pressing the button of the Hue bridge, and the error appears when I’m pressing the set up individual lights parameter.

Thanks

Can you post the error message from the text port?

Hi @raganmd,

That’s the error.

Thanks

hey MFagniard - I’ve been wracking my brain trying to figure out what was going on here, and I think it’s actually the build you’re using.

Looks like you’re still on 2017.16620. Can you try updating your Touch build to see if that makes a difference?

Hi @raganmd,

I’m having some problems connecting the tox to my bridge too. Here are the text port errors I am getting:

I have followed everything methodically (use a saved toe file and use the tox in the release folder, etc.) and am able to control the lights from my computer with code, but am having several problems getting it to work in TD.

Hope you can help!

Thanks

Hi @charliej99 - what I can see right off the bat is that the python version for the latest TouchDesigner is 3.9 and this module hasn’t been updated since the change from Python 3.7. I should be able to look at this during the week and see if I can get an update pushed to github.

1 Like

Ah okay, thank you! That would be amazing if you could give it an update!

Hi @charliej99 - I just pushed some updates. You will need to download the tox from the release folder again, but you should now be able to run this in the latest Version of TouchDesigner without issue.

You will need a stand alone version of Python 3.9 installed, but otherwise should be good to go.:slight_smile:

1 Like

Thank you Matt! I really appreciate you updating it this quickly!! Works great

1 Like

Hi Matt,

how can i achieve a transition between colors?

For Example i have constant TOP where the colorr colorg colorb are changing constantly.

If i use a script which then pulses the UpdateAll Button the frame rate goes down and i get time out errors from the IP.

I have two hue play lightbars they react kinda ok and i have one Lightstrip which is sometimes reacting and then not, all connected to the same bridge.

Is there a better way to submit color changes in a short time without using the updateall button via script? I think it is triggered several times in a second.

thank you

TD Hue Control Updates

Since first making this component I’ve fielded a good set of questions about working with a third party library, and the hassles that come along with that in TouchDesigner. So, to help resolve those issues I’ve recently re-written this TOX to instead use the requests library that ships with Touch. That means that this is now a truly drag and drop tox that you can add to your network without needed any extra python libraries for this to work.

Changes also now push immediately from parameters to to lights - so you can think of this as when you make a change to the custom pars, those requests for updates go to the lights right away. This does have some performance slow-downs, and on my todo list is to improve the response rate and performance for this TOX.

Hope this helps folks who are interested in controlling Hue lights from TouchDesigner.

2 Likes

Hey @raganmd, first of all, thanks for this great tox, worked out of the box here! Tested with build 2022.31030 and then with 2022.32660. (Actually, one thing didn’t work: the “All lights” functionality. But I’m more interested in controlling each light individually, so ok by me)

I’m having some issues and doubts though. I wanted to know if these are expected or if they are actual bugs:

  1. Performance
    I’m not sure if this is what you meant with “some performance slow-downs”, but even if I’m just sliding the values in the parameters my FPS goes down dramatically (from 60 to 4). Is this normal?

    I also tried creating a simple 3x1 resolution (I have 3 lamps) rampTOP > topToCHOP > shuffleCHOP > resampleCHOP sequence and exporting the values to the base_hueControl parameters, resampling to 1 sample/sec and everytime it hit’s that sample the FPS drops considerably…

  2. Single R G B colors don’t vary in intensity
    When experimenting with low RGB values (like 0.1,0,0) and high RGB values (1,0,0), I don’t see any changes on the lamp color/intensity. Should I just set a color and then use the Brightness instead?

  3. Looking inside your tox I noticed that for some values the glsl_color_space_converter glslTOP returns some nan values, is this expected? For instance, setting the RGB parameter to 0,0,0 gives me a white lamp color and that GLSL TOP returns nan,nan,1.

Regarding the performance issue, I was looking into the Philips Hue developers documentation and found that there’s a “Hue Entertainment API” that can “stream lighting effects to multiple lights in parallel with a high update rate”. It changes the communication with the lights from HTTP to UDP, apparently making it much faster. You’ve probably seen this but still thought it was worth mentioning.

EDIT: Oh, one last question, regarding issues and bugs with your tox, do you prefer to keep on this thread or should we post them on the GitHub Issues?

Hi @sandromiccoli - glad this is working for you (mostly :grimacing: )

Some quick thoughts for you:

Yep - that’s about what I expect. Python is blocking in TouchDesigner, so a request to your bridge will stall TD during the round trip of the request, update and response. Which is a bummer, I know. That makes streaming changes pretty unusable IMO - the trade here was time spent trying to get folks up to speed on using a 3rd party library (which was often very difficult to do only over forum posts). The big improvement here would be moving to a threaded approach - most of the code is pretty thread safe already, and the lift to make it threaded isn’t too much extra work.

TL;DR - yeah, this is expected, and terrible but better than using a third party library.

  1. Single R G B colors don’t vary in intensity
    When experimenting with low RGB values (like 0.1,0,0) and high RGB values (1,0,0), I don’t see any changes on the lamp color/intensity. Should I just set a color and then use the Brightness instead?

This is also expected. Hue uses an xy color space instead of RGB - the technique for TouchDesigner aligns with other apps, where you can set the color and it’s brightness independently. It is possible to derive brightness for the Hue API from RGB, but I think for simplicity I’d take away the brightness slider. I’m not sold on a change up here - I’ll keep thinking about this one, so in the meantime use the brightness slider :slight_smile:

  1. Looking inside your tox I noticed that for some values the glsl_color_space_converter glslTOP returns some nan values, is this expected? For instance, setting the RGB parameter to 0,0,0 gives me a white lamp color and that GLSL TOP returns nan,nan,1.

Noted - this isn’t yet implemented in code anywhere, it was the start for what might be a faster update / compute solution. I’ll double check the approach here to make sure things line-up. For what it’s worth XY color space is different from RGB, so I’d expect there to be some wrinkles here.

Regarding the performance issue, I was looking into the Philips Hue developers documentation and found that there’s a “Hue Entertainment API” that can “stream lighting effects to multiple lights in parallel with a high update rate”. It changes the communication with the lights from HTTP to UDP, apparently making it much faster. You’ve probably seen this but still thought it was worth mentioning.

Oh yeah, I looked at that for a couple days and the migration from the current approach wasn’t insignificant. The bridge updates at 25 Hz, and their recommendation is half that update speed for new messages - so 12.5 Hz. You’d get roughly 10 updates per second, and for the work to get the hue up to snuff here I’d rather use a product that accepts sACN or artnet. Which is to say that as a passion project I couldn’t justify the extra time for this transition - especially as I think using threads will improve the TD side of performance. I’m up for chasing this… I just haven’t had a enough down time to make it a priority :frowning:

Oh, one last question, regarding issues and bugs with your tox, do you prefer to keep on this thread or should we post them on the GitHub Issues?

Generally prefer tracking this on GitHub - it’s easier to keep track of requests and when they’ve been addressed. I added your notes above already. No ETA on anything, but will certainly start thinking about some of these. You’re also more than welcome to fork the repo and make changes if you’re up for it.

Thanks for the reply @raganmd!

Will keep an eye on the repo.

Hello @raganmd Thank you so much for the Tox. I have been able to connect and control lights. I am facing the same issue as @sandromiccoli of the FPS dropping drastically. You mentioned something about using threads as a solution to this? Can you please elaborate what you mean by that? I am new to this. Thanks

Are you new to TouchDesigner, Python or both?

Threading in this case refers to setting up the requests to run in python threads - which don’t block the main thread in TouchDesigner. I haven’t yet settled on how I want to approach this exactly, as threads won’t guarantee an execution order. If you were moving your sliders quickly, for example, you could end up with unexpected or undesirable results.

I’ll have some time at the end of the year to start doing a little work on this project, and will be trying a few different techniques. If you’re interested in looking into threading yourself, there’s an article here to help you get started:

I did have one more thought as I’m getting ready to head to the airport about using a different request technique. There’s a decent chance that there’s an easier wait to get this working a little faster. I’ll try to test in the next few days to see if I can get a patch out.