Interval length of binary sensor state

This seems like a duplicate of my quesion: Tracking time a sensor is on/true/state