Smart switch controlling 6 smart bulbs (complex use case)

This is a quite complex use case, and probably too specific to my house, but it might be interesting for some as it combines both Apilio and Smart Life automations.

Devices:

  • 6 smart bulbs surrounding my house (Smart Life / Tuya compatible)
  • 1 smart switch (no wire between the switch and the bulbs) (Smart Life / Tuya compatible)

What I want to achieve:

  • Smart bulbs can be turned on by different ways, e.g. Alexa turning on only the 2 bulbs illuminating my pool, my alarm system turning on all smart bulbs upon detecting motion outside, etc.
  • If any smart bulb is on, the smart switch must be on (blue status light on). Only when all smart bulbs are off, the smart switch must be off (blue status light off)
  • When the smart switch is on (blue status light on), pressing on it should turn all smart bulbs off
  • When the smart switch is off (blue status light off), pressing on it should turn all smart bulbs on

How I did it:
:point_right: Apilio: I created 6 non-trigger conditions: Smart_bulb_1_off to Smart_bulb_6_off
:point_right: Apilio: I created 1 trigger condition: Turn_smart_switch_on
:point_right: AUTOMATION #1 in Apilio: I created a logicblock called ‘Turn_on_all_bulbs_if_I_press_on_smart_switch’:

  • Condition linking: Smart_bulb_1_off AND Smart_bulb_2_off AND … Smart_bulb_3_off AND Turn_smart_switch_on
  • Action: Trigger routine in Smart Life (Tuya) which turns all smart bulbs on

:point_right: AUTOMATION #2 in Smart Life: I created an automation:

  • Condition: (Smart bulb 1 is ON) OR (Smart bulb 2 is ON) or… (Smart bulb 6 is ON)
  • Action: Turn on Smart Switch

:point_right: AUTOMATION #3 in Smart Life: I created an automation:

  • Condition: (Smart bulb 1 is OFF) AND (Smart bulb 2 is OFF) AND… (Smart bulb 6 is OFF)
  • Action: Turn off Smart Switch

:point_right: AUTOMATION #4 in Smart Life: I created an automation:

  • Condition: (Smart switch is OFF)
  • Action: Trigger routine in Smart Life (Tuya) which turns all smart bulbs off

As you can imagine, there is some cross triggering between some of these automations. For example, if you press on the smart switch when it is ON, then AUTOMATION #4 is triggered => All smarts bulbs go off => AUTOMATION #3 is triggered

Thus you need to be very careful when designing the automations to avoid endless loops

:stop_sign::scream: For advanced users:
At first, I tried to implement AUTOMATION #1 with Smart Life like this:
AUTOMATION #1 in Smart Life:

  • Condition: (Smart bulb 1 is OFF) AND (Smart bulb 2 is OFF) AND… (Smart bulb 6 is OFF) AND (Smart switch is ON)
  • Action: Trigger routine in Smart Life (Tuya) which turns all bulbs on

But this does not work. If any smart bulb is on and I turn all smart bulbs via, for example, Alexa, then this automation detects that all smart bulbs are off but smart switch is on, and turns all bulbs back on. I’d need AUTOMATION #3 to be evaluated and executed before AUTOMATION #1, but you can’t control that.

That’s why I implemented AUTOMATION #1 with Apilio and that’s also why the 6 conditions controlling smart bulbs are “non-trigger” conditions. Otherwise I’d run into the same issue.

3 Likes

Thanks @teknofilo, very nice (complex) use case! Are you happy with how it’s working though - have any edge cases appeared yet or is it doing everything perfectly?

It is working as expected. Now we can easily see from inside the house if any smart bulb outside is on (in that case, smart switch has a blue light) and, if so, we can easily turn all bulbs off by pressing on the smart switch button.

Additionally, if we are going out to the garden for a short time, we can simply press on the smart switch to turn all smart bulbs on at once, and then press again when we are back inside to turn them off. If we plan to stay outside for a long time, we usually ask Alexa to turn those smart bulbs in the area where we are going to stay.

2 Likes

Would be great to have thought control devices next so we don’t need to keep pressing buttons!

1 Like