Adding a switch to existing automation

Hi all,

I've previously set up the following rule to turn some devices when when my TV is turned off:

Everything is working great - thanks to help from this forum.
I've now added a flashed sonoff m5 switch and programmed it to control the very same lights - which also works great.

The issue I am having is that when I for example turn the lights on with the new sonoff switch, the TV automation will turn them off - but the sonoff switch indicates that they are still on.

What am I doing wrong guys?

The lights in question are 2 Kasa bulbs, set up in group and controlled via a virtual dimmer.
The Sonoff switch is configured to turn the dimer on / off

First, in your screen shot of your rule, which device label is 1) the virtual dimmer, 2) your Kasa bulbs, 3) your physical devices (i.e., are the Ikea outlets actual outlet plugs, and finally 4) your label for the Sonoff Switch?

Is the Lounge Light Switch your Sonoff Switch? If it is not, then . . .

Assuming that the Sonoff Switch is the same switch you had problems with integrating with HE in another thread due to flashing with the incorrect version of Tasmota (one without HTTPHook), and that you got this sorted out by re-flashing it with the correct Tasmota version (one WITH HTTPHook so that it now correctly reports the its proper state), looking at your rule as written, the Sonoff Switch will need to also be turned off when you turn off your TV.

If the Lounge Light Switch is your Sonoff Switch, then there is probably no need to have a nested IF conditional since sending another OFF signal to the Sonoff (assuming it is already OFF) does not really add any real significant overhead to your hub.

Yep, that's me - thanks for stopping by again!

1/2. "Lounge small lights" - ( virtual dimmer? / Kasa light bulbs group )
3. "Outlets" - these are 2 ikea smart plugs controlling plug in lights
4. "Lounge light switch" - small lights - is the sonoff from earlier thread

Prior to adding the switch the rule was as above, but without the last 2 lines ( If condition ) and was working fine.
The lights are on a timer to come on at 18.00 and tv turns them off when turned off.
The rule still works, turns the lights off and now also turns the sonoff off - I am assuming the addition off the second if added some delay.

The issue I seem to be really having is that when the timer turns the lights on from an off state, the sonoff is being bypassed and not notified of the change - same in reverse, but at least the above rule fixed the TV option.

To get the sonoff working as a physical light switch, I've used this basic rule:
image

I know I am missing something simple, but just don't know what.

Hi again! Glad you were able to get things working by reflashing Tasmota with HTTPHook.

Might check to make sure that your timer rule is turning on your lights via the Sonoff switch, and not turning on your lights directly. I have had a similar situation when I had a set of smart lights controlled by direct HE control, as well as by virtual switches, as well as by physical switches. Must take extra steps to make sure that all the ON states are “coordinated” via additional rules. At least make sure that whenever the lights are turned on, a separate signal is also sent to your Sonoff to turn it on, in addition to turning off the Sonoff when the lights are turned off in any manner (physical, virtual or directly via Zigbee, Wifi or Z-wave).

I ran into a somewhat similiar situation trying to get my dashboard tiles to accurately reflect the state of some of my water valve controllers as they could be turned on and off by a variety of means (leak sensors, button controller, Alexa voice commands, etc).

I think this is why your TV option works since you have added a separate action to address the Sonoff. Again, I’m no expert with RM rules but I did stay at a Holiday Inn once!