Re: Auto Company Modes for the Fingscan Plugin
Posted: Mon Oct 17, 2016 11:19 am
I reread the thread and see my mistake. You never said there were any commingled devices--looks like I inferred that. SO we don't need to worry about 'onOffState'' at all. No wonder you were confused by that bit. Sorry about that.
- Code: Select all
company_devices = [] # A blank list to start with
folder_id = 1314917481 # the ID of your default folder
variable_id = 1961258112 # the ID of your tracking variable
# Loop through Indigo devices
for dev in indigo.devices.itervalues():
# Is the device in the default folder?
if dev.folderId == folder_id:
try:
# Add the device's status to the list
company_devices.append(dev.states['status'])
except:
pass
# Test the list. If any of the statuses in the list are 'Up', set the variable to 'on'. Otherwise, set it to 'off'.
if any(x == 'Up' for x in company_devices) :
indigo.variable.updateValue(variable_id, 'on')
else:
indigo.variable.updateValue(variable_id, 'off')