Author Topic: Would really appreciate some help with a luup script  (Read 758 times)

Offline Kaizen

  • Newbie
  • *
  • Posts: 19
  • Karma: +0/-0
Would really appreciate some help with a luup script
« on: June 20, 2017, 10:57:00 am »

I have a luup script that sets the color of my Philips HUE bulbs. It works and all is good... mostly. The problem is that I can't set the color correctly and need a way to read the hue and saturation values.

There is apparently a way to do this using the following:
Code: [Select]
local LampValues = luup.variable_get("urn:micasaverde-com:serviceId:PhilipsHue1","LampValues",HueBulbId)
How do I access the values read into LampValues? I am clueless.  :'(

Offline Steven

  • Newbie
  • *
  • Posts: 3
  • Karma: +0/-0
Re: Would really appreciate some help with a luup script
« Reply #1 on: June 27, 2017, 05:31:44 pm »

I'm somewhat new to Luup, but not to coding.
Here are couple of things I can think of that might help point you in the right direction, or might be helpful information for the community to try to assist you.

Open a Web Browser to:
-- Replace IP Address
-- Replace the UUID ( You can get this by going to the device > click the little arrow > go to advanced scroll at the way down its labeled as local_udn )
PASTE all of that XML here so we can decypher what the device is capable of and what values are presently available...

Part 2. Looking at the LUUP code you posted....
If I understand correctly, the code you posted is getting a SINGLE value not multiple....
So This purely a theoretical example (You'll have to utilize the above xml to find out the name of the value you are looking for).
local SatLevel = luup.variable_get("urn:micasaverde-com:serviceId:PhilipsHue1","SaturationLevel",HueBulbId)

It's possible you may have to set the saturation level to get the desired colored.
Do you'd then need to set the Saturation Level accordingly (Again theoretical coding)
luup.call_action("urrn:micasaverde-com:serviceId:PhilipsHue1","SetSatLevel",{ newSatLevel="32" },HueBulbId)

Hope it helps. Post back any additional info you have from the XML or whatever documentation you may have found and I'd be happy too look at it and provide you with some suggestions.

Offline joshewing02

  • Newbie
  • *
  • Posts: 2
  • Karma: +0/-0
Re: Would really appreciate some help with a luup script
« Reply #2 on: August 03, 2017, 05:24:39 pm »
I am having the same sort of problem but trying to get set a color when calling a scene.
I followed your steps and got back

<Device_Num_128 PendingJobs="0" status="-1">
<state id="55" service="urn:micasaverde-com:serviceId:PhilipsHue1" variable="BulbModelID" value="LCT007"/>
<state id="56" service="urn:micasaverde-com:serviceId:PhilipsHue1" variable="IconValue" value="R"/>
<state id="57" service="urn:micasaverde-com:serviceId:PhilipsHue1" variable="LampValues" value="hue:65535;sat:254"/>
<state id="58" service="urn:micasaverde-com:serviceId:PhilipsHue1" variable="LampHexValue" value="#FF0202"/>
<state id="59" service="urn:micasaverde-com:serviceId:PhilipsHue1" variable="LampEffectValue" value="none"/>
<state id="60" service="urn:upnp-org:serviceId:SwitchPower1" variable="Status" value="1"/>
<state id="61" service="urn:upnp-org:serviceId:Dimming1" variable="TurnOnBeforeDim" value="0"/>
<state id="62" service="urn:upnp-org:serviceId:Dimming1" variable="LoadLevelStatus" value="100"/>
<state id="63" service="urn:upnp-org:serviceId:Dimming1" variable="LoadLevelTarget" value="100"/>
<state id="64" service="urn:upnp-org:serviceId:Dimming1" variable="LoadLevelLast" value="100"/>
<state id="65" service="urn:micasaverde-com:serviceId:HaDevice1" variable="ModeSetting" value="1:;2:;3:;4:"/>
<state id="66" service="urn:micasaverde-com:serviceId:HaDevice1" variable="CommFailure" value="0"/>
<state id="67" service="urn:micasaverde-com:serviceId:HaDevice1" variable="CommFailureTime" value="0"/>
<state id="68" service="urn:micasaverde-com:serviceId:HaDevice1" variable="CommFailureAlarm" value="1501488480,0"/>
<state id="69" service="urn:micasaverde-com:serviceId:HaDevice1" variable="Configured" value="0"/>
<state id="70" service="urn:micasaverde-com:serviceId:HaDevice1" variable="TransitionTime" value="50"/>
<tooltip display="0"/>

Now all I want to do is when I run the Scene to set this light to these settings. 
I have tried

luup.call_action("urrn:micasaverde-com:serviceId:PhilipsHue1","SetLampHexValue",{ newLampHexValue="#FF0202" },128)

luup.call_action("urrn:micasaverde-com:serviceId:PhilipsHue1","SetLampValues",{ newlampvalues="hue:65535;sat:254" },128)

luup.call_action("urrn:micasaverde-com:serviceId:PhilipsHue1","SetLampHexValue",{ newLampHexValue="#FF0202" },HueBulbId128)

Any suggestions?  Not really sure what I am doing wrong.

Offline Matsohl

  • Sr. Newbie
  • *
  • Posts: 30
  • Karma: +4/-1
Re: Would really appreciate some help with a luup script
« Reply #3 on: September 30, 2017, 01:40:05 pm »
Bump! Did you get any answer on this?

How do I set the hex value to the bulb?
« Last Edit: September 30, 2017, 01:41:57 pm by Matsohl »
Vera Plus with (Hue, Fibaro, Qubino, IKEA, Nexa, Sonos, Telldus, Sensative etc.) and Arduino, ESP8266

Offline akbooer

  • Master Member
  • *******
  • Posts: 5869
  • Karma: +249/-69
  • "Less is more"
Re: Would really appreciate some help with a luup script
« Reply #4 on: September 30, 2017, 04:52:08 pm »
I notice that your serviceId is written as "urrn:...", whereas it should be "urn:...".
3x Vera Lite-UI5/Edge-UI7, 25x Fibaro, 23x TKB, 9x MiniMote, 2x NorthQ Power, 2x Netatmo, 1x Foscam FI9831P, 9x Philips Hue,
Razberry, MySensors Arduino, HomeWave, AltUI, AltHue, DataYours, Grafana, openLuup, ZWay, ZeroBrane Studio.