Rule to turn off virtual switch when the last light turns off

Hi all!
I tried searching for this but couldn't find my scenario, so thought I'd post. If this is solved somewhere else - feel free to link me!

In any case, here's my situation:
I have a virtual switch called "All Lights" which turns on when any light turns on. Strictly speaking, this is all I need to enable the solutions I need. But I would like to set a rule so that if the last light on turns off, the switch also turns off. Essentially, I want this switch to be on if any light is on and off if all lights are off.

I can't think how to do this in RM without creating rules for every potential scenario where each light is the "last" light. For example: Condition = All lights except Kitchen are off; Trigger = Kitchen turns off; Result = "All Lights" turns off.

Right now, it's not worth repeating all of those rules. But is there another kind of trigger or conditional statement I'm missing?

More context for what this solves (for me):

  1. Because I have different kinds of lighting, it's been historically difficult for Alexa to know what is a light and what isn't (despite me setting the type per device in the Alexa app). This means it has been frustrating and unreliable to use "Turn off the lights". So instead using this switch to control all lights via Alexa has been the most reliable and efficient way to get this done. (A much higher WAF too!)

  2. We regularly have house guests and sitters who don't need - or want - to know all of the available interactions with Alexa to use the "smart home". For this reason, we have a tablet we make available using Home Remote to let them interface with the smart devices. The virtual switch "All LIghts" is useful here too, also to turn off the lights.

However, if I turn off lights by room - when the last light turns off, "All Lights" might still be on because it hasn't itself been turned off. For #1 above that doesn't much matter at all (since we almost never use Alexa to say "turn on all lights"). But for #2 above it does create a confusing user experience.

TIA!

There are two answers, one for 2.3.0, and one for the new release 2.3.1 that is in beta.

For 2.3.0. the trigger should be any of those switches *changed*

The actions would be

Wait for Expression: All of those switches off
Turn off "All Lights"

The way that works is that each switch action of any of the switches cancels the pending wait, which then starts again. Only when all of them are actually off will it get past the wait.

In the upcoming 2.3.1. release, there is a new variant of trigger that allows "All" to be selected when there are multiple devices in the trigger. That trigger would be All Off. That won't trigger until all of the switches are off, essentially triggering on the last one to turn off.

4 Likes

Thank you so much! Worked perfectly :slight_smile: