Can Alexa dim 2 different lights in a Action Group

Posted on
Mon Sep 25, 2017 2:07 pm
siclark offline
Posts: 1960
Joined: Jun 13, 2017
Location: UK

Can Alexa dim 2 different lights in a Action Group

The spotlights in my kitchen are on 2 circuits, and I have a qubino dimmer on each. I can get Alexa to turn both on together as I have setup an Action Group for the lights, one for on and one for off. I have created one for the Dim command, but how do I put the Dim variable that is updated by Alexa into the Set Brightness control for each light?
Or is this something I will finally have to look at Python for?

Thanks

Posted on
Mon Sep 25, 2017 2:26 pm
jay (support) offline
Site Admin
User avatar
Posts: 18200
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Can Alexa dim 2 different lights in a Action Group

Use the Match Brightness action on a trigger that fires whenever the light that's controlled by the Alexa changes.

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Mon Sep 25, 2017 3:08 pm
siclark offline
Posts: 1960
Joined: Jun 13, 2017
Location: UK

Re: Can Alexa dim 2 different lights in a Action Group

Thanks, I had thought about that but there will be times when I want one off and the other dimmed for example. Can I set brightness to equal a variable in script?

Posted on
Mon Sep 25, 2017 4:01 pm
jay (support) offline
Site Admin
User avatar
Posts: 18200
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Can Alexa dim 2 different lights in a Action Group

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)

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 3 guests