rbrouwer wrote:I have a virtual device consisting of 5 fibaro dimmers. I have a small python script that cycles a variable between 0, 25 and 100 each time it is run. I was wanting to then take the value of this variable, and update the brightness to each of the dimmers in the group to that value.
devId = 739620904 (Id of the dimmer group)
varId = 799897200
myVar = indigo.variables[varId]
newBrightness = int(myVar.value)
indigo.dimmer.setBrightness(devId, value = newBrightness)
Whilst the variable cycles nicely each time I press the assigned button, can't get the lights to work. I was wondering if this is the right approach.
I'd take a different approach. Although Matt & Jay seem to be looking to increase the abilities of Virtual Groups I don't think they can do what you think - I'm hoping I'm wrong here BTW
I think I'd write some processing code to set each of the lights in turn based on the variable setting. In my case I've called the variable DimmerGroupBrightness
- Code: Select all
# There are a couple of things that make me suggest this approach
#
# 1. I suspect that indigo doesn't see the virtual group as a dimmer so you can't set brightness unless Matt or Jay disagree
#
# 2. You generally have to get the devID number as I've shown rather than just the number itself as it's a reference to an object
# - I normally right click on the device in Indigo and select Copy Python Reference and then paste
# - it into my programmes
#
# This must be run from inside indigo
import indigo
# Change the variable 0, 25, 50, 100 etc...
# You've already got the code to do this and it works so I won't suggest anything
# Now act on the change
# Trigger - if the variable DimmmerGroupBrightness changes:
# Set up dimmer group in a list to make it easier to process later. You can add as many items here as you need
# Note that I've copied the Python Reference from indigo directly (Right click on the device and select Copy Python Reference)
dimmerGroup = []
dimmerGroup.append(indigo.devices[1925423536]) # "Living Room Light"
dimmerGroup.append(indigo.devices[46056323]) # "Small Living Room Light (Dual)"
dimmerGroup.append(indigo.devices[1037977303]) # "Office/Chillout Room Light"
#...
# Now get the variable value from indigo using the same technique I did with the device by right clicking on the variable name in the variable window
dimmerSetting = indigo.variables[460137250] # "DimmerGroupBrightness"
dimmerValue = int(dimmerSetting.value) # You're right that indigo saves this as a string so you have to convert it
# Now change the brightness settings for each dimmer in turn
for dimmerNumber in range(len(dimmerGroup)):
indigo.dimmer.setBrightness(dimmerGroup[dimmerNumber], value = dimmerValue)
I tried this as embedded Python code in a trigger that was looking for whenever the variable DimmerGroupBrightness changed and it worked fine for me
Each time I changed the DimmerGroupBrightness variable it changed the lights as well
Good luck and let me if you need any more help
Regards
Mike