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

  1. Open the Variable window by selecting Variable List from the Window menu
  2. Click on the New… button to create a new variable
  3. 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”
  4. Repeat steps 2 and 3 again, this time naming the variable “lamp_previous”
  5. 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:

  1. Select TRIGGERS in the outline view on the left side (we're going to make these
  2. Click the New… button above the trigger list
  3. Name the trigger “Start watching a movie”
  4. Select INSTEON Command Received from the Type: popup
  5. Click the Device radio button beside From: if not already checked
  6. Select the name of the ControLinc from the device popup next to the word Device
  7. Select On on the popup next to Received:, and Button/Group 1 on the popup next to that
  8. 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 skip Condition for this example)
  9. Select Variable Actions→Insert Device State into Variable
  10. In the Device popup, select your sconce device
  11. In the resulting config dialog (click Edit Action Settings… if one didn't automatically pop up), select brightness for the state and sconce_previous for the variable
  12. Click the Save button
  13. 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 the Show All button and you can cycle through all actions using the Prev and Next buttons next to Show:.
  14. 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
  15. 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
  16. Select Device Actions→Light/Appliance Controls→Set Brightness from the Type: popup
  17. Select the device that represents the sconces from the Device: popup
  18. Enter 20 in the text field next to Amount:
  19. Now, add another for the lamp by clicking on the Add New button again
  20. Select Device Actions→Light/Appliance Controls→Turn Off from the Type: popup
  21. Select the device that represents the table lamp from the Device: popup
  22. Now, add one more for the blinds by clicking on the Add New button again
  23. Select Control Light / Appliance from the Type: popup
  24. Select Turn On from the Action: popup
  25. 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:

  1. Select TRIGGERS in the outline view on the left side (we're going to make these
  2. Click the New… button above the trigger list
  3. Name the trigger “Stop watching a movie”
  4. Select INSTEON Command Received from the Type: popup
  5. Click the Device radio button beside From: if not already checked
  6. Select the name of the ControLinc from the device popup next to the word Device
  7. Select Off on the popup next to Received:, and Button/Group 1 on the popup next to that
  8. That specifies that this trigger will fire when the Button 1 Off command is received from the ControLinc - now select the Actions tab (again, skip Condition for this example)
  9. Select Device Actions→Light/Appliance Controls→Match Brightness to Variable from the Type: popup
  10. Select sconce_previous from the Variable: popup
  11. Select the device that represents the sconces from the Devices: list
  12. Click the Save button
  13. Click the Add New button at the lower left to add another action
  14. Select Device Actions→Light/Appliance Controls→Match Brightness to Variable from the Type: popup
  15. Select lamp_previous from the Variable: popup
  16. Select the device that represents the lamp from the Devices: list
  17. Click the Save button
  18. Click the Add New button at the lower left to add another action
  19. Select Device Actions→Light/Appliance Controls→Match On State to Variable from the Type: popup
  20. Select shades_previous from the Variable: popup
  21. Select the device that represents the shades from the Devices: list
  22. 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!

scenes_restore_state.txt · Last modified: 2020/04/02 21:40 (external edit)
 

© Perceptive Automation, LLC. · Privacy