I have a rule setup for both Watching TV and Finished watching TV.
The one that I am having difficulty with is the one that runs when I am finished watching TV:
I do not want the lights in the lamps to dim IF in fact they were not on to begin with.
If they were on, they would have dimmed when the TV watching started, and therefore restoring afterwards (since they were already on) would be alright.
A simple solution would be a boolean hub variable, set to true by the first rule if the lights were already on, then use that as a condition in this rule to determine whether or not to dim the lights.
I'm going to recommend an alternative approach, since it works for me:
Combine both rules (and later, delete the "Over" rule), as follows:
(A) Do a CAPTURE action so the Lamps levels get remembered by RM;
(B) Do the watching TV stuff;
(C) Add a WAIT FOR EVENT ( Power of TV reports <= 7.0 ... )
(D) Off: TV, RESTORE Lamps, etc.
Go to Settings->Hub Variables and add a new one like this:
In your TV on rule, add an action that says "if(lights are on) THEN set variable to true"
In your TV off rule, add an action that says "if(variable is true) THEN dim lights"
Rule Change:
Trigger:
TV On
ACTIONS:
Capture: Lights
IF(lights are on) THEN dim lights
Wait for event: Power for TV plug reports <= 7 and stays
Restore: Lights
Capture will store the state of the lights (on/off, current brightness, etc). When you do a restore, it restores what was captured (if they were off, then turn them off; if they were on, turn them on and set the level back to what it was). The capture and restore functions will also capture color/color temp.
CAPTURE (and its companion Action, RESTORE) can be found among the many Actions offered in Rule Machine 5.1. Here's the docs for Capture/Restore.
What this accomplishes is letting you put the Lamp(s) back the way they were when you first sit down to watch television. If they were Off initially, they'll be restored to "Off".
And, if you really want to put the cherry on top, make that CAPTURE line the very first action, and add 'Floor Lamp' and 'Hallway Main Lights' to it (as well as the final RESTORE line), for this final result: