The practice of disabling and enabling automations in other automations isn’t generally considered an optimal design. It is better to add a condition so that it only executes when you want it to.
When you programmatically enable/disable automations rather than controlling them with their own conditional logic, you loses the ability to definitively and reliably disable them. Sometimes you need to manually disable an automation because it isn’t working properly. If you have other automations that can enable it outside your control, you can’t be certain it will stay off.
the light automation have is, if motion is detected after 9:30pm then 2 lights will turn on (like a night light for navigating the kitchen area) as it it usually dark. However, if my wife is watching the tv with the lights off inside this time frame, i don’t want the me walking past the sensor or her moving off the couch etc to activate the lights as per the original automation. its a bit niche
so i have tried this and it doesn’t trigger the lights to come on when the tv is not playing media. so i changed it to the below and it “works” but its always detected. so it wont turn the lights on when i walk past? its very hard to descirbe i guess.
sorry, let me make sure i understand what you want…
if the tv is playing, you essentially want the motion detectors to be disabled. so that it doesn’t turn on or off. but if the tv is not playing, you want the motion detectors to operate normally. is that right? anything else?
if that’s right, then i apologize i misunderstood the original request. i’d still use the helper sensor, but i’d use this template. i had the playing state exactly inverted:
{{ states('binary_sensor.hue_motion_sensor_5_motion') and states('media_player.living_room_tv') != 'playing' }}