Advanced template sensor help

I’m looking to build a template sensor that will tell me how long a light has been on in the last 24 hours (or really how long some sensor has been some defined value today).

I’m able to see when the device’s status was last changed, but I’m not sure this is possible, hints?

Have you seen the History Statistics sensor? It seems to give you close to what you want

1 Like

This is exactly what I needed! Thanks!!