123
Senior Member
Premise's Scenes: flexible, powerful, and sometimes a source of frustration! You make a Scene that is supposed to turn on lights and then turn them off but sometimes they don't all turn off. Why? How can Scenes be forced to do what you want?
Background
When you play a Scene, you set the state of a group of items. For example, a single Scene can turn on a TV, dim lights, turn up the thermostat, and set the volume to a desired level. A Scene can even include other Scenes (as well as Timers and Variables). However, I'll bet most people use Scenes to control a group of lights.
A Scene can have one of two types of "Behavior":
Set
"Set" behavior means a Scene will set all its items to a specified state. Enable the Scene's "Play" property, the item states are set and then the scene stops playing. "Set" behavior makes a Scene simply act like a macro: trigger it and it does its magic.
Set-Restore
Set-Restore behavior means a Scene will set all its items to a specified state while it is playing. When the scene stops playing, all its items are restored to their initial state. Enable Play, the item states are set. Disable Play, all items revert to their initial state.
"Initial state" does not necessarily mean off! Let's assume you have a Set-Restore Scene that turns on two lights. Initially, one light is on and the other is off. The Scene plays and turns on both lights. When the Scene ends, one light is turned off but the light that was initially on will remain on.
Why did Premise's designers make Set-Restore work this way? Because Set-Restore Scenes can be nested. Here's an example:
Solution
SceneStateEx extends Premise's SceneState class and adds a new property called "ForceRestoreToOff". Enable this property and when a Set-Restore Scene finishes playing it will turn off all Devices having a PowerState or State property. In practice this means it will turn off all Lighting and Appliance objects included in the Scene.
Simply import the SceneStateEx module and then review your list of Set-Restore Scenes. Enable the ForceRestoreToOff property for each Scene that ought to turn things off when it is finished playing. SceneEx records its activities in the debug log so if you have DebugView running you can see precisely what happens after a Scene stops playing.
Now a word about Tasks. Tasks appear in Builder's Schedule section. Each Task is a Scene combined with a Schedule. Given that it is basically a Scene, each Task will also feature the ForceRestoreToOff property.
Background
When you play a Scene, you set the state of a group of items. For example, a single Scene can turn on a TV, dim lights, turn up the thermostat, and set the volume to a desired level. A Scene can even include other Scenes (as well as Timers and Variables). However, I'll bet most people use Scenes to control a group of lights.
A Scene can have one of two types of "Behavior":
Set
"Set" behavior means a Scene will set all its items to a specified state. Enable the Scene's "Play" property, the item states are set and then the scene stops playing. "Set" behavior makes a Scene simply act like a macro: trigger it and it does its magic.
Set-Restore
Set-Restore behavior means a Scene will set all its items to a specified state while it is playing. When the scene stops playing, all its items are restored to their initial state. Enable Play, the item states are set. Disable Play, all items revert to their initial state.
"Initial state" does not necessarily mean off! Let's assume you have a Set-Restore Scene that turns on two lights. Initially, one light is on and the other is off. The Scene plays and turns on both lights. When the Scene ends, one light is turned off but the light that was initially on will remain on.
Why did Premise's designers make Set-Restore work this way? Because Set-Restore Scenes can be nested. Here's an example:
- Everything in the Home Theater room is off.
- Play the WatchMovie Scene and A/V equipment is turned on, lights dim, thermostat is adjusted, etc
- This evening you want a darker room so you manually dim the lights.
- While you are watching a movie, the phone rings and activates the PauseMovie Scene.
- The DVD player is paused, the lights brighten, etc.
- You answer the call. The moment you hang up (on-hook), you automatically stop the PauseMovie Scene.
- The DVD player resumes playing and the lights return to their original brightness which happens to be the level you had set manually and not what is dictated by the WatchMovie Scene.
- It is overcast outside and your home's interior is dimmer than usual. You turn on the lights in the Family room. You leave all others off.
- It is close to sunset and the Evening Scene plays. It turns on many lights including the ones in the Family room.
- At bedtime the Evening Scene stops playing and restores all lights to their initial state. That means most everything is turned off, except the Family room lights because they were already on when the Evening Scene started. In this case, we don't want the Evening Scene to restore the initial state, we want it to force all lights off.
Solution
SceneStateEx extends Premise's SceneState class and adds a new property called "ForceRestoreToOff". Enable this property and when a Set-Restore Scene finishes playing it will turn off all Devices having a PowerState or State property. In practice this means it will turn off all Lighting and Appliance objects included in the Scene.
Simply import the SceneStateEx module and then review your list of Set-Restore Scenes. Enable the ForceRestoreToOff property for each Scene that ought to turn things off when it is finished playing. SceneEx records its activities in the debug log so if you have DebugView running you can see precisely what happens after a Scene stops playing.
Now a word about Tasks. Tasks appear in Builder's Schedule section. Each Task is a Scene combined with a Schedule. Given that it is basically a Scene, each Task will also feature the ForceRestoreToOff property.