History stats stops working for app. 1 week

Thanks for pointing in the direction of SQL sensors. I will investigate that.

Regarding asynchronous events, the stats sensors update every minute and the lights are on for hours.
Which means that even though the stats sensors misses the edge, it will one minute later experience a full 1 minut periode of being continuously β€œon”.
And in my case it repeatedly misses every event during a full week on 17 independent lights. And in other periods (like now) never misses a single one.

No, the count resets to 0 every minute, completely unsynchronised to your light state timing. The light then has to change state for it to be counted again.