WTH are there no long term statistics for binary sensors?

Long term statistics are very useful, because they allow you to keep your database size small while keeping relevant information for a long time. Currently long term statistics only work on numeric sensors, storing a min, max and avg value per hour.

I would like to see long term statistics on binary sensors, storing for how long a binary sensor was active in a given time frame. A window sensor could for example store a window-open-time and window-closed-time per hour. It would then be possible to add those up to calculate for example how long the window was open the last 4 weeks.

This could then also be extended to other stateful entities, such as persons, allowing me to check for example how much time I spent at the office in the last year.

Oooh. Good one. I have wanted this before when comparing my “fan needed” binary sensor to humidity past my keep days date.

In theory this could also be translated to any on/off entity platform/domain