Author Topic: LUA code to set lights to white in RGBW model?  (Read 1850 times)

Offline hippieh8er15

  • Sr. Newbie
  • *
  • Posts: 24
  • Karma: +2/-1
LUA code to set lights to white in RGBW model?
« on: January 16, 2016, 04:44:42 pm »
Does anyone know what the lua code would be just to set the lights to white?  I cant seem to find that anywhere.  I am trying to run a sunrise simulation. Everything is working great at the end of the run though I want to chage the lights to white, but I cant seem to figure out the code to do this.  I can change to every other color but not white.  Thanks in advance

Offline daemondazz

  • Jr. Member
  • **
  • Posts: 96
  • Karma: +4/-0
Re: LUA code to set lights to white in RGBW model?
« Reply #1 on: January 16, 2016, 07:24:17 pm »
I use something like this for my Aeotec RBGW bulbs:

Code: [Select]
local devId = 30
local coolWhite = "#00000000ff"
local warmWhite = "#000000ff00"

function setRgbwWhite(colourHex, devId)
    local svcidRGB = "urn:upnp-org:serviceId:RGBController1"
    luup.call_action(svcidRGB, "SetColorTarget", {newColorTargetValue = colourHex}, devId)
end

Offline ceefin

  • Full Member
  • ***
  • Posts: 139
  • Karma: +6/-0
Re: LUA code to set lights to white in RGBW model?
« Reply #2 on: January 17, 2016, 02:48:06 pm »
Does anyone know what the lua code would be just to set the lights to white?  I cant seem to find that anywhere.  I am trying to run a sunrise simulation. Everything is working great at the end of the run though I want to chage the lights to white, but I cant seem to figure out the code to do this.  I can change to every other color but not white.  Thanks in advance


Code: [Select]
luup.call_action("urn:dcineco-com:serviceId:MiLightRGBW1","SetWhiteMode",1,130)
luup.call_action("urn:upnp-org:serviceId:Dimming1","SetLoadLevelTarget",{ newLoadlevelTarget = 100 },130)

In the code above, my device ID is 130. You call the SetWhiteMode action, then you can set the loadleveltarget to whatever you need it to.

Hope this helps! Let me know if you need anything else and I'll contribute what I can.

Offline hippieh8er15

  • Sr. Newbie
  • *
  • Posts: 24
  • Karma: +2/-1
Re: LUA code to set lights to white in RGBW model?
« Reply #3 on: January 17, 2016, 04:32:11 pm »
Code: [Select]
luup.call_action("urn:dcineco-com:serviceId:MiLightRGBW1","SetWhiteMode",1,130)

Worked great thank you

If anyone is interested here is the section of code I am working with trying to simulate a sun rise working pretty well will probably tweak it a little but this is the jist.

Code: [Select]
local CNT
local CNT2
local BCNT
CNT =255
CNT2 =50
BCNT= 1



luup.call_action("urn:dcineco-com:serviceId:MiLightRGBW1", "SetHue", {newHue = "255"}, 200)
luup.sleep(500)
luup.call_action("urn:dcineco-com:serviceId:MiLightRGBW1", "SetHue", {newHue = "255"}, 200)
luup.call_action("urn:upnp-org:serviceId:Dimming1","SetLoadLevelTarget",{ newLoadlevelTarget = BCNT },200)
luup.sleep(500)
luup.call_action("urn:upnp-org:serviceId:Dimming1","SetLoadLevelTarget",{ newLoadlevelTarget = BCNT },200)
luup.call_action("urn:upnp-org:serviceId:SwitchPower1", "SetTarget", {newTargetValue = "1"}, 200)

while BCNT <100 do
  luup.call_action("urn:upnp-org:serviceId:Dimming1","SetLoadLevelTarget",{ newLoadlevelTarget = BCNT },200)
  BCNT = BCNT+1
  luup.sleep(1000)
end


while CNT >=120 do
  luup.call_action("urn:dcineco-com:serviceId:MiLightRGBW1", "SetHue", {newHue = CNT}, 200)
  CNT = CNT-1
  luup.sleep(1500)
end

luup.call_action("urn:upnp-org:serviceId:Dimming1","SetLoadLevelTarget",{ newLoadlevelTarget = CNT2 },200)
luup.call_action("urn:dcineco-com:serviceId:MiLightRGBW1","SetWhiteMode",1,200)
luup.sleep(500)
luup.call_action("urn:dcineco-com:serviceId:MiLightRGBW1","SetWhiteMode",1,200)
while CNT2 < 100 do
  luup.call_action("urn:upnp-org:serviceId:Dimming1","SetLoadLevelTarget",{ newLoadlevelTarget = CNT2 },200)
  CNT2 = CNT2+1
  luup.sleep(1000)
end