Philips Hue lighting: fire animation

I was astonished by how little desktop apps are available for controlling Hue bulbs, and how many of all Hue apps are simply nonfunctional. I had noticed how some of the iOS apps “ which I didn’t want to use due to the inconvenience of mobile devices as controllers for something so ever-present “ contained features to animate the lights. That was something that I really wanted, but I’d want to have full control of it. At first it seemed that I’d have to know some “real” programming languages and be able to understand and control the network api “ a far too steep learning curve for a beginner “ but I managed to come up with a workaround.

You’ll need any number of Philips Hue bulbs and a desktop app called Hue-Topia to act as a communication bridge.
Here’s my demonstration video of one lamp in action.
Oh and, you’ll want to pair this light effect with this soundscape. I have posted Applescript control over that wonderful soundscape website here.

Do not save this as an application, only run in Script Editor!
I’m a beginner scripter, and haven’t yet been able to come up with a solution on how to stop this cycle from running. Ideas are very welcome. :smiley:


tell application "Hue-topia"
 repeat
  set HueValue to (random number from 20 to 40)
  set brightnessValue to (random number from 120 to 150)
  set whitenessValue to (random number from 20 to 50)
  set hue of some lamp to HueValue
  delay 0.1
  set brightness of some lamp to brightnessValue
  delay 0.1
  set whiteness of some lamp to whitenessValue
  delay 0.1
 end repeat
end tell

¢ To make the cycling faster, remove the delay rows. Devices may get hotter and it can be tough on the CPU.
¢ To make the lights more red, make the smaller number of HueValue even smaller.
¢ Smaller numbers in brightnessValue results into dimmer light, higher to brighter. 255 is the maximum. I don’t recommend differences of much more than 30 numbers, because a huge contrast starts to feel more like a flashy disco than a calming fire.
¢ Lower numbers in whitenessValue results in deeper color, less diluted pastels.

What settings look the best depends on your room, because the surroundings affect how the light looks. For example, a room with lots of dark wood can use higher brightness settings than what would be ideal in a room with white walls and light furniture.

I’ve made some other animations using this same principle. For example, if you set the hue range to shades of green, you get an impression of trees swaying in the wind.
It’s excellent for parties, but to make it sophisticated and stylish instead of a manic and tasteless Christmas inferno, this is where limiting the range of available hues becomes so very important.
Say, reds are in the small number end of the hue spectrum. Purples are in the big number end. What if you want these but you don’t want the greens and blues in the middle? Or what if you want the lights to be in the range of very dim or very bright, but never anything from between? You can add multiple ranges to the code.

The following example is a loop for funky lights. In this code, see that I have made three different HueValue ranges, and two of them even overlap slightly. This means, that for most of the time, the lights are purple. The second most common color is what’s around purple: indigo blue and salmon red. One third of the time, we get a flash of golden yellows for accent.


tell application "Hue-topia"
	repeat
		set HueValue to (random number from 45 to 70)
		set HueValue2 to (random number from 200 to 240)
		set HueValue3 to (random number from 180 to 255)
		set brightnessValue to (random number from 150 to 255)
		set whitenessValue to (random number from 0 to 30)
		set hue of some lamp to HueValue
		delay 0.2
		set brightness of some lamp to brightnessValue
		delay 0.2
		set whiteness of some lamp to whitenessValue
		delay 0.2
		set hue of some lamp to HueValue2
		delay 0.2
		set hue of some lamp to HueValue3
		delay 0.2
	end repeat
end tell

Important things to know when creating your own:
¢ Philips bulbs understand three parameters: Hue, whiteness and brightness. These are expressed in numbers between 0-255 each.
¢ Although the colors are produced by the combination of blue, green and red LEDs, note that the color parameter is NOT RGB color values! Philips deliberately made the choice to use CIE color space instead of RGB, meaning that the blue is a bit more indigo, green a bit more yellow and red a bit more orange than in RGB equivalents. As a downside, Hue bulbs make a poor job around the teal blue zone. As a plus side, this color space creates much nicer white and pastel colors, which is the most common use of these lights; Most people simply don’t want to live in the middle of car-crash Christmas lights but it’s the tints that play well in normal home conditions.