Trigger if any device with 'Light' in the name turns on?

Posted on
Wed Jun 14, 2017 11:05 am
blysik offline
Posts: 213
Joined: Jan 06, 2015

Trigger if any device with 'Light' in the name turns on?

I'm trying to optimize a "turn off all the lights" action.

I've created a action which executes this python:
Code: Select all
import time

for dev in indigo.devices.iter():
    if 'Light' in dev.name and dev.onState and dev.name != 'House Lighting':
        indigo.device.turnOff(dev)
        time.sleep(1)
indigo.variable.updateValue(260947379, 'off')


(That variable is named HouseLightingStatus.)

This is used triggered by a Virtual Device named House Lighting. Now the harder part:

I would like the HouseLightingStatus variable to be set to 'on', if any device with 'Light' in the name is turned on (minus House Lighting). Finally, if the last device with 'Light' in the name is turned off, I'd like the variable to be set to 'off.'.

Is this possible? Thinking about it more, do I have to maybe brute force this, and just run some python every minute that maintains this variable state? Suggestions appreciated, thanks!

Posted on
Wed Jun 14, 2017 11:29 am
jay (support) offline
Site Admin
User avatar
Posts: 18199
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Trigger if any device with 'Light' in the name turns on?

Just use a Device Group and include the lights you're interested in.

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Wed Jun 14, 2017 12:23 pm
blysik offline
Posts: 213
Joined: Jan 06, 2015

Re: Trigger if any device with 'Light' in the name turns on?

Ah! I totally forgot about those. Thanks. Setting that up now. This will definitely allow a cleaner approach.

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 5 guests