The Vera Community forums have moved!

General => Connected Objects => Philips HUE => Topic started by: shillingcl on December 28, 2018, 04:38:17 pm

Title: Easy script to reset the color of hue lights
Post by: shillingcl on December 28, 2018, 04:38:17 pm
I have a lot of hue lights and this is scene I trigger every night manually, and via Alexa, as needed.  The kids are regularly changing the color of the lights in different rooms, so this is an easy way to get all of them back to "Soft White", regardless of whether they are on or off. (They need to have power of course)

If I were to just ask Alexa to make all of the Hue lights "Soft white", it would change the color, but then I would individually need to turn off all of the lights I don't want on. 

Hope this helps a few of you.

Code: [Select]
-- Reset Hue Lights
local newColorTemp = "360"
-- Replace 271 and 272 with a comma separated list of the device ids of all the hue lights you want to reset
local lightIDs = {271, 272}
for i, lightID in ipairs(lightIDs) do
    local curDimLevel = luup.variable_get("urn:upnp-org:serviceId:Dimming1","LoadLevelStatus", lightID)
    luup.call_action("urn:micasaverde-com:serviceId:PhilipsHue1", "SetColorTemperature",{ColorTemperature=newColorTemp},lightID)
    luup.call_action("urn:upnp-org:serviceId:Dimming1", "SetLoadLevelTarget", {newLoadlevelTarget = curDimLevel}, lightID)