Length of time a sensor has been in specific state

Take a look at this discussion - it looks like a similar issue to me:
Calculating days/hours per year below a certain temperature? - Energy - Home Assistant Community

And it provides one approach where you could draw on the existing history right away.

1 Like