RM: Need help with a condition

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.

Suggestions?

1 Like

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.

Sounds great!

I have NO idea how to do that.

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.

1 Like

THat sounds good too.
What is the RESTORE feature?
And what state would I capture?

In the evening the lamps are usually on at 35%, so would dim for watching TV
In the day, they would not be on, so need them to stay off afterwards

Use a variable:

Go to Settings->Hub Variables and add a new one like this:
image

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".

1 Like

Okay. Trying to follow this.
Not sure in the example where I would add the lightsOn variable? or How? Conditional action, correct?

I have this:

You're getting SO CLOSE... now it's time to get rid of that unneeded IF-THEN:

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:

I think you'll be pleased.

Just forgot to add the Unmute Sonos pair command.
Otherwise, everything works great!!

Question, though: why did I need the local variable of lightsOn?

IMHO, you do not need to employ variables for any part of this automation.

You didn't with the route you took. A variable could have been used with your existing rules to make them do what you want.

Or, like you did, you could've rewritten the rule.