Setting RGB Values for Hue Bulbs with Indigo Variables

Posted on
Wed Nov 01, 2017 4:06 pm
teejay6 offline
Posts: 44
Joined: Jan 31, 2011
Location: Menlo Park, CA

Setting RGB Values for Hue Bulbs with Indigo Variables

Hi:

I am stuck on a simple python script to set RGB values for Hue bulbs using Indigo variables.

The following script works just fine:
Code: Select all
redValue = 255
indigo.server.log("Red Value is set to " + str(redValue))


plug = indigo.server.getPlugin("com.nathansheldon.indigoplugin.HueLights")
if plug.isEnabled():
   plug.executeAction("setRGB", indigo.devices[1438718908].id, props={"red":redValue, "green":0, "blue":0})


When I try to substitute an Indigo Variable (that is set to 255) it doesn't work anymore:
Code: Select all
redValue = indigo.variables[1277411617] # "Red"
indigo.server.log("Red Value is set to " + str(redValue))


plug = indigo.server.getPlugin("com.nathansheldon.indigoplugin.HueLights")
if plug.isEnabled():
   plug.executeAction("setRGB", indigo.devices[1438718908].id, props={"red":redValue, "green":0, "blue":0})


The error message I get is:
Action Group Hue IRIS1C Red Python Script
Script Red Value is set to description :
folderId : 1786084393
globalProps : MetaProps : (dict)
id : 1277411617
name : Red
pluginProps : emptyDict : (dict)
readOnly : False
remoteDisplay : True
value : 255
Script Error embedded script: No registered converter was able to produce a C++ rvalue of type CCString from this Python object of type Variable
Script Error Exception Traceback (most recent call shown last):

embedded script, line 7, at top level
TypeError: No registered converter was able to produce a C++ rvalue of type CCString from this Python object of type Variable


I tried using int(indigo.variables[1277411617]), but that didn't work either.

Any tips would be appreciated. Thanks

Posted on
Wed Nov 01, 2017 6:10 pm
bkmar1192 offline
Posts: 274
Joined: Sep 12, 2015

Re: Setting RGB Values for Hue Bulbs with Indigo Variables

You are setting RedValue to the variable object not the value of the variable object. Should be RedValue = Indigo.variables[1277411617].value


Sent from my iPhone using Tapatalk

Posted on
Wed Nov 01, 2017 6:14 pm
jay (support) offline
Site Admin
User avatar
Posts: 18199
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Setting RGB Values for Hue Bulbs with Indigo Variables

You were close:

Code: Select all
redValue = int(indigo.variables[1277411617].value) # "Red"
indigo.server.log("Red Value is set to " + str(redValue))


plug = indigo.server.getPlugin("com.nathansheldon.indigoplugin.HueLights")
if plug.isEnabled():
   plug.executeAction("setRGB", 1438718908, props={"red":int(redValue), "green":0, "blue":0})


Notes:
  • You want to use the value of the variable (thus the .value at the top)
  • All variable values are strings, so you want to caste it to an int (see the int() call wrapping the variable value retrieval)
  • You don't need to get the device ID using the ID, because you already have the ID

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Wed Nov 01, 2017 6:19 pm
teejay6 offline
Posts: 44
Joined: Jan 31, 2011
Location: Menlo Park, CA

Re: Setting RGB Values for Hue Bulbs with Indigo Variables

Thank you so much. That really helps.

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 2 guests