Create a scene (multiple devices on/off with one command) that restores prior settings
This is an advanced scene scenario (requiring Indigo 7.4+), based on the basic scenes How-To, with some additional functionality. It is sometimes desirable to return a light or other device to a previous state when a “scene” is turned off. In this How-to, we'll describe how to restore the lights in a scene to their state prior to the scene getting activated. This How-to level of difficulty is Moderate.
Earlier versions of this how-to required scripts - but with Indigo 7.4+, you can do it completely through the UI.
What you need to start
- Some devices to control (typically lights, but could also be devices such as window shade controllers)
- Something to trigger the scene (typically a switch or remote)
Scenario Overview
To recap the scenes scenario: Joe has some nice wall sconce lights in his TV room that are controlled by an SwitchLinc and a table lamp connected through an ICON Lamp Module. He also has just installed some X10 controllable window shades (an X10 ON command lowers them, an X10 OFF command raises them in this example). He has a ControLinc that he wants to set up so that when he hits Button 1 ON, the sconces dim to 20%, the table lamp turns off, and the window shades go down. Here's the difference between the basic scenario and this one: when he hits Button 1 OFF, the sconces, the table lamp, and the window shades will return to their previous state. In other words, the room will look like it did before he pressed the Button 1 ON. This scenario will require Indigo 4.0 Pro since we'll need to use some AppleScript.
Steps to create this scenario
This scenario isn't really too difficult, but it does require a Python script, which we will provide here:
Create a variable for each device for which you want to restore the state
- Open the Variable window by selecting
Variable List
from theWindow
menu - Click on the
New…
button to create a new variable - Double click on the new variable's name (usually “variable”) and type in a new name - in this example I'm going to use “sconce_previous”
- Repeat steps 2 and 3 again, this time naming the variable “lamp_previous”
- Repeat steps 2 and 3 once more, this time naming the variable “shades_previous”
You now have 3 variables, named “sconce_previous”, “lamp_previous”, and “shades_previous”. These variables will hold the state that those devices were in prior to setting them to what they need to be for the scene.
Create ON Trigger Action
So, now we need to create 2 trigger actions so that when Joe presses the right buttons on his ControLinc, the actions listed in the scenario above happen correctly. The first one will be for the On command:
- Select
TRIGGERS
in the outline view on the left side (we're going to make these - Click the
New…
button above the trigger list - Name the trigger “Start watching a movie”
- Select
INSTEON Command Received
from theType:
popup - Click the
Device
radio button besideFrom:
if not already checked - Select the name of the ControLinc from the device popup next to the word
Device
- Select
On
on the popup next toReceived:
, andButton/Group 1
on the popup next to that - That specifies that this trigger will fire when the Button 1 ON command is received from the ControLinc - now select the
Actions
tab (you can skipCondition
for this example) - Select
Variable Actions→Insert Device State into Variable
- In the
Device
popup, select your sconce device - In the resulting config dialog (click
Edit Action Settings…
if one didn't automatically pop up), selectbrightness
for the state andsconce_previous
for the variable - Click the
Save
button - Click the
Add New
button at the lower left to add another action - don't worry, the one you just created isn't gone, it's just hidden - you can see all actions by clicking theShow All
button and you can cycle through all actions using thePrev
andNext
buttons next toShow:
. - Repeat steps 9-13 for the lamp device and the shades device (on the latter, you'll select
onOffState
) for the state assuming that you're using a on/off (relay) device to control your shades - That takes care of storing the states, now we want to actually change them to their desired states - click on the
Add New
button at the lower left side of the dialog again - Select
Device Actions→Light/Appliance Controls→Set Brightness
from theType:
popup - Select the device that represents the sconces from the
Device:
popup - Enter 20 in the text field next to
Amount:
- Now, add another for the lamp by clicking on the
Add New
button again - Select
Device Actions→Light/Appliance Controls→Turn Off
from theType:
popup - Select the device that represents the table lamp from the
Device:
popup - Now, add one more for the blinds by clicking on the
Add New
button again - Select
Control Light / Appliance
from theType:
popup - Select
Turn On
from theAction:
popup - Select the device that represents the blinds from the
Device:
popup
That's it! So, to recap, what we did was create a trigger action that will fire when Button 1 ON on the ControLinc is pressed. It executes 4 actions: runs a script that saves the state of each device into variables, sets the brightness of the sconces to 20%, turns off the table lamp, and lowers the blinds by sending them an ON command (note, if they are already down, nothing will happen). So, how do we reverse the process? Read on…
Create OFF Trigger Action
As you may have guessed, we need to create another trigger like the one above, except it reverses the process:
- Select
TRIGGERS
in the outline view on the left side (we're going to make these - Click the
New…
button above the trigger list - Name the trigger “Stop watching a movie”
- Select
INSTEON Command Received
from theType:
popup - Click the
Device
radio button besideFrom:
if not already checked - Select the name of the ControLinc from the device popup next to the word
Device
- Select
Off
on the popup next toReceived:
, andButton/Group 1
on the popup next to that - That specifies that this trigger will fire when the Button 1 Off command is received from the ControLinc - now select the
Actions
tab (again, skipCondition
for this example) - Select
Device Actions→Light/Appliance Controls→Match Brightness to Variable
from theType:
popup - Select
sconce_previous
from theVariable:
popup - Select the device that represents the sconces from the
Devices:
list - Click the
Save
button - Click the
Add New
button at the lower left to add another action - Select
Device Actions→Light/Appliance Controls→Match Brightness to Variable
from theType:
popup - Select
lamp_previous
from theVariable:
popup - Select the device that represents the lamp from the
Devices:
list - Click the
Save
button - Click the
Add New
button at the lower left to add another action - Select
Device Actions→Light/Appliance Controls→Match On State to Variable
from theType:
popup - Select
shades_previous
from theVariable:
popup - Select the device that represents the shades from the
Devices:
list - Click the
Save
button
Congratulations!
You've now created two scenes for Joe's TV room: one he'll use when watching a movie and another that returns the room to it's previous state. As you can probably see, there are other things you can do to make this scene even more useful: if you have an Infrared receiver, you could program a button on your current IR remote to trigger the actions. If you have A/V devices suported by a 3rd party plugin, you could add extra actions that would set the rest of your A/V equipment up so that it's ready to watch a movie.
A word about Action Groups
In a simple trigger action, there is probably only one action that you want to take. In the scenario that we just finished, though, we have several actions we want to perform (adjust 2 different lights and the window shades). Indigo let's you specify multiple actions in the “Create New Trigger Action” dialog, and that's how we did it here. If, however, you had multiple ways you wanted to trigger these actions (besides just buttons on a single ControLinc), then you would implement the actions in Action Groups. Feel free to read up on those at your leisure!