Dim lights when playing media - cancel or delay

Hey I recently got my lights to dim when playing media with Kodi and to return to regular brightness when playback is stopped or paused. The problem I have is with short videos I have my lights constantly changing brightness. So if I watch a video on youtube thats 1 minute long its a bit annoying to have the lights constantly changing.

Im not sure how to go about resolving this. Im wondering if I can add a delay to the lights returning to regular brightness and have a cancel condition if the media player returns to the playing state. Or perhaps there is a better way?

What if you used an inpout_boolean to set whether you actually want the lights to behave that way? I do something similar and use Alexa to enable/disable. When I (or the kids) want it, “Alexa, turn on movie lights”. I have “movie lights” set to switch back to “off” when my amp gets turned off (capturing that event outside of HASS using Girder, but you could probably rig something similar).

I’ve been doing this but using the Harmony-API as a trigger instead of the media player. When I trigger an activity on the Harmony Hub, I have my lights come up full then after a 2 minute delay they slowly fade down, like a real theater. This way it only comes back up to full if I switch activities, like from watching TV to watching FireTV or Chromecast.

If you’re using Hue lights, there’s a kodi plugin script.kodi.hue.ambilight which works better than a HA-based automation (less delay).
There’s also an option to ignore videos shorter than a certain length, which is what you’re asking for.
I think there are multiple forks of this plugin around - I’m using the one by mpolednik which works with the current v16.x Kodi release (haven’t tested any of the v17 betas yet).

Sebastian