Setting LightA to the same brighness as LightB in a rule?

I have a rule that changes LightA to a particular color to indicate the status of my front gate, and this part works great.

However, I want LightA to match the brightness level of the room, which may be altered for other reasons. When my rule fires to change the color of LightA can I query the brightness of LightB and use that when setting LightA? If so, how, exactly?

Note that I do not want a rule that triggers on the brightness of LightB changing and then changing the brightness of LightA. What I’m trying to avoid is that if LightB is dimmed below a certain amount (e.g. 25%) and LightA will remain at 25%.

I have Premium, fyi.

Never mind, I figured it out. I created two variables, $LivingRoomBrightness and $LivingRoomOnOffState and in my rule I populate both variables from an adjacent light in the room, as shown here:

Then, if the brightness is less than 25% or the adjacent light is off I set the $LivingRoomBrightness to 25%.

Then further down the rule when I set the status light’s brightness I use the $LivingRoomBrightness variable.

I was going to share more images but as a new user it only allows me to include a single image.

Create a Number variable “$LightB”

Then this rule should mirror Light A if it is equal to or greater than 25

The approach @JKB121 mentioned would be the preferred approach as it’s event driven and is able to use the value that is changing and causing the rule to Trigger within the Flow so you can snapshot the event value to a variable (rather than having to query your smart home hub for the status).

Two different high level approaches are:

  • Setup simple utility rules that just snapshot the value to a variable; Then use separate rules that use the Variable changing as a trigger and updates the other light.
  • Combine the logic into one rule – for example, if you had the trigger as the Light - level changing you could directly use the $context.event.value in a command to setLevel() to directly pass it over to the other device.

The approach @JKB121 mentioned uses something called Context Variables which are documented here:

1 Like