Yes:
- Code: Select all
brightness = int(indigo.variables[VARIDHERE].value) # ID of the variable that has the brightness
indigo.dimmer.setBrightness(DIMMERIDHERE, value=brightness)
repeat the second line for each dimmer by inserting the correct ID. If you enter something that's not an integer in the variable value, you'll get an error like:
- Code: Select all
Trigger Set brightness to var value
Script Error embedded script: invalid literal for int() with base 10: 'asdfs'
Script Error Exception Traceback (most recent call shown last):
embedded script, line 1, at top level
ValueError: invalid literal for int() with base 10: 'asdfs'
And, in the spirit of learning more about Python scripts: you can add some error checking to your script to make errors more clear:
- Code: Select all
my_var = indigo.variables[1237552327]
try:
brightness = int(my_var.value)
indigo.dimmer.setBrightness(1367948060, value=brightness)
except:
indigo.server.log("Variable '{}' does not contain a valid integer ({})".format(my_var.name, my_var.value), isError=True, type="Set Brightness Trigger")
Which will result in this in the Event Log when there's a non-integer value in the variable:
- Code: Select all
Trigger Set brightness to var value
Set Brightness Trigger Error Variable 'brightness' does not contain a valid integer (al;ksjdflasdkjf)