LUA code to set HUE color

I am using the following LUA code to toggle my lights:

local device  = 13 -- device #ID via Device -> Advanced (example 79)
local lgtsts = luup.variable_get("urn:upnp-org:serviceId:SwitchPower1", "Status", device)
if(lgtsts=="1") then -- If Device is On
    luup.call_action("urn:upnp-org:serviceId:SwitchPower1","SetTarget", {newTargetValue = "0"}, device) -- Device Off
    luup.call_action("urn:upnp-org:serviceId:Dimming1","SetLoadLevelTarget",{ newLoadlevelTarget="0" },device)  -- OPT Line if Light: Light Off
else
    luup.call_action("urn:upnp-org:serviceId:SwitchPower1","SetTarget", {newTargetValue = "1"}, device) -- Device On
    luup.call_action("urn:upnp-org:serviceId:Dimming1","SetLoadLevelTarget",{ newLoadlevelTarget="100" },device)  -- OPT Line if Light: Light On 100%
end

local device  = 14 -- device #ID via Device -> Advanced (example 79)
local lgtsts = luup.variable_get("urn:upnp-org:serviceId:SwitchPower1", "Status", device)
if(lgtsts=="1") then -- If Device is On
    luup.call_action("urn:upnp-org:serviceId:SwitchPower1","SetTarget", {newTargetValue = "0"}, device) -- Device Off
    luup.call_action("urn:upnp-org:serviceId:Dimming1","SetLoadLevelTarget",{ newLoadlevelTarget="0" },device)  -- OPT Line if Light: Light Off
else
    luup.call_action("urn:upnp-org:serviceId:SwitchPower1","SetTarget", {newTargetValue = "1"}, device) -- Device On
    luup.call_action("urn:upnp-org:serviceId:Dimming1","SetLoadLevelTarget",{ newLoadlevelTarget="100" },device)  -- OPT Line if Light: Light On 100%
end

I want to also set the hue bulb color. I am using the Phillips Hue 2 app. On the phillips hue app the code was:

    luup.call_action (“urn:intvelt-com:serviceId:HueColors1”, “SetHueSaturation”, {newHue=20, newSaturation=100}, device)
    luup.call_action (“urn:intvelt-com:serviceId:HueColors1”, “SetColorTemperature”, {newColorTemperature=20}, device)

What is teh code when using the phillips hue 2 app?

1 Like