Help creating an automation?

Hi everyone.
I have 2 smart bulbs and one light switch.

I need it to work this way:
If any bulb turns ON >>> turn ON switch.
If both bulbs turn OFF >>> turn OFF switch.
If one bulb turns OFF, other is ON >>> keep other ON and switch ON

If switch turns ON >>> turn both bulbs ON.
If switch turns OFF >>> turn both bulbs OFF.

now the problem is that this rule:
If any bulb turn ON >>> turn ON switch
triggers this rule:
If switch turns ON >>> turn both bulbs ON.

so I can’t have only ONE light on.

Appreciate any help:)

Kind of hard to understand your setup. What is “one light switch”, a virtual switch on a HASS dashboard, or some physical hardware? If the latter, how does that actually work/what actions does it support? I have a hard time imagining a physical light switch which someone put a motor in to flip into the correct position, but hey anything is possible if you’re willing to pay for it I guess…

Also post your automation code.

1 Like

You basically described how a light group works by default:

If any of the individual members is ON, then the state of the group is ON, otherwise it’s OFF when all the members are off.

You can use the state of the group as a virtual switch, but note that if one of the bulbs is already ON, you won’t be able to switch the group ON because it is already in that state.

1 Like

i have managed to get it working. thanks for the helpers.

now i have another question:
I have the sonoff T5 switch and i paired it successfully with HA with the sonoff LAN integration.
how do i set swiping left or right on the switch as a trigger in an automation?
image

also im still not sure what “attributes” mean, when i click on this field there are no options popping up, do I need to fill it manually?

Attributes are shown in Developer tools on the left bar of your HA dashboard (Dev tools > States tab > use the filter to find your T5).

You might also see some Logbook entries in the device page while you’re swiping - there’s a dedicated logbook section on the right of the device page which updates in realtime.

1 Like

Not unless you know what you’re doing. Read this:

TL;DR: entities have one state and zero or more attributes. You can use the attributes in automations, but more often than not it’s the state you want.

It’s a common cause of questions on here — people can’t work out why their automation isn’t working, and it turns out they’ve filled in the attribute field because they didn’t want to leave it empty.

2 Likes

thank you guys.
so when im creating an automation, where do i fill in the log entry of the swipe with the log name “slide_1” or “slide_2”?

I just read about the group integration. Thanks for alerting me to it.

But I don’t think it helps in the case a bulb goes on which triggers the switch which then triggers both lights to go on.

My question is, “How did a light come on if not by the light switch?” There must be another entity that is turning on the light. The entity could be a timer, another switch, motion, etc. but any any case, another entity.

At the time the entity that causes the light to turn on, toggle a toggle helper. (This toggle helper indicates that the light was turned on by an entity other than the light switch.) Then turn on the light switch. The light-switch-was-turned-on automation would check the toggle helper and if set, then not turn on the lights and instead, reset the toggle helper

Also look into Trigger Conditions

I hope this gets you down the road a bit.

1 Like

When I wrote that, there was still an open question as to whether the switch was a physical or a virtual one. Setting the T5 (physical) switch to mirror the group state (virtual switch) would cover both scenarios.

No, a light can also be turned on via HA from a dashboard card, script or via an automation - that’s ignoring the fact it can also be turned on externally to HA (via Alexa/Google or something else).

The group state achieves this without needing to create a toggle helper for the individual lights. It’ll work consistently whether you have 2 lights or 100 and negates the need to add a toggle helper for each one.


its not triggering