It's late and I'm tired...and I had an automation that used motion lightening and rule machine to do the following
So when motion is detected and it's within those parameters of modes, then turn lights on, but then I had a section to say if the TV is on then disable turning off and also a switch to turn off lights.
I then had a rule machine to turn off the virtual switch when the lamps (side lights) turn on.
for whatever reason I deleted my groups (by mistake) and it messed up some rules, so I recreated them from screenshots I'd taken and it no longer works. Lounge Lights turn on and stay on if TV is on (which is good), but when the lamps turn on the lounge lights stay on...Now if I remove the 'Disable off turning off' option it works again, but I had it exactly he same as before.
I think this would be best built out using RM rules.
Something like this...
Rule 1
Trigger:
Motion Sensor Change
Action:
IF Motion Active and Mode is Day, Evening, Night, and Lounge Lights are Off THEN
Turn On Lounge Lights
Else IF Motion is Inactive and Mode is Day, Evening, Night, and Lounge Lights are ON and TV Virtual Switch is Off THEN
Turn Off Lounge Lights Delay 5 minutes (Cancelable)
Else
Cancel Delayed Actions
END IF
RULE 2
Trigger:
Lamp Lights change
Action:
If Lamps turn ON and Lounge Lights are ON THEN
Turn Off Lounge Lights
Else
Turn On Lounge Lights
End IF
Rule 3
Trigger:
If Power switch TV Changes
Action:
If power switch >= 10 THEN
Turn on TV Virtual Switch
Else
Turn Off TV Virtual Switch
End If