Average power value only when switch is on

I’m using low-voltage outdoor lights and have replaced the mechanical timer with a smart plug and a few automations - so far, so good, it all works fine.

I looked at the power consumption on March 10th and saw that there was a drop over night when one of the LED path lights went out and came back - found the fault and fixed it.

Over the weekend I saw another power drop (from another kind of bulb) and was wondering, if I could set up an automation to notify me if & when that happens again:

I could, of course, simply say ‘Send notification when the numeric value for power drops below 54’ - but where would be the fun in that :grinning:

So I’m thinking, if there is a way to send a notification when the power value drops e.g. 5% below the long time average value?
As I understand it, setting up a simple a trigger based on the history_stats platform would use the zero values during the day, when the lights are off, as part of calculating the mean, correct?
If that’s correct, my mean calculations would be off - unless there is a way to exclude certain values e.g. everything below 10W from the calculation of the mean value.

Any ideas how to tackle this?
Or any other ways to achieve the same goal?