Page 1 of 1

Possible to use an ELSE type statement in Schedule?

PostPosted: Mon Apr 24, 2017 6:34 am
by petematheson
I currently have a number of scheduled running to do various checks on the house.

The one I'm configuring now is checking if a room is in use, by checking if any of the lights are on, or a Harmony Activity is running, or the sonos is playing etc..
Currently I'm having to double up on all of my rules.

The first rule checks if ANY of the following devices are on.. and sets a variable to True (Is this room occupied?)
The second rule checks if ALL of the following devices are off.. and sets that variable to False.

Just thought it would be much simpler if we could use the first rule and just have an ... else set variable to false, rather than duplicating the whole schedule.
It would also mean making future tweaks is easier as I don't have to remember to add a new device into both schedules

Re: Possible to use an ELSE type statement in Schedule?

PostPosted: Mon Apr 24, 2017 9:51 am
by jay (support)
It's been requested before. I'd recommend using a single Python script as your action that determines what to do, then executes the appropriate action group (so you only have to edit the actions in one place for true and one place for false).

Re: Possible to use an ELSE type statement in Schedule?

PostPosted: Mon Apr 24, 2017 12:23 pm
by durosity
Yeah that’s how I do it.. more for triggers as I don’t do much scheduling.. but same principle. An example if it helps:

Code: Select all
dev = indigo.devices[964639587] # "Bedroom 2 - Master Switch"
if dev.states["command"] == "Mood 5":
   indigo.dimmer.brighten(828126709, by=50) # TURN UP SIDE LAMP
elif dev.states["command"] == "Mood 4":
   indigo.device.turnOff(828126709) # TURN OFF SIDE LAMP
elif dev.states["command"] == "Mood 3":
   indigo.actionGroup.execute(1206849764) # TURNS ON ELECTRIC BLANKET 30 MINS
elif dev.states["command"] == "Mood 2":
   indigo.device.toggle(1815938212) # TOGGLES ROLLER BLIND
elif dev.states["command"] == "Mood 1":
   indigo.device.toggle(1498113616) # TOGGLES VENETIAN BLIND
elif dev.states["command"] == "Group off":
   indigo.actionGroup.execute(453752047) # TURNS ALL LIGHTS OFF


On a side note.. matt & jay… it’d be AWESOME if you can make a GUI function for this.. it’s a right pain having to update all my little scripts every time I need to replace a device for whatever reason. It’s not a particularly common issue but when it does happen it usually takes me weeks to notice when there’s something I’ve not updated.

Re: Possible to use an ELSE type statement in Schedule?

PostPosted: Mon Apr 24, 2017 1:50 pm
by jay (support)
When you replace a device you should just edit the existing device rather than creating a new one and deleting the old one - that way it keeps the same ID and none of your scripts break... ;)

Re: Possible to use an ELSE type statement in Schedule?

PostPosted: Mon Apr 24, 2017 2:00 pm
by durosity
Hehe yeah it's sometimes not as simple as that though.. multifunction Z-Wave devices where I've removed a temp sensor and it won't resync without it for example.

Re: Possible to use an ELSE type statement in Schedule?

PostPosted: Mon Apr 24, 2017 2:34 pm
by jay (support)
Yeah, that's a problem. And it's on the list to look into, but it's not exactly easy... ;)