Time tracking sensor

Hello there,
I’ve seen that a similar question has been asked already but the answer was not clear at all, so maybe it would be useful to clarify how to do it.
So basically I have a sensor that tracks my presence at home, and has two states: home and away.
I want another sensor that, based on the previous, can count how many hours for day I am away.
It should store just one value per day (the amount of hours away at 23.59.59 of each day) and then reset itself, so I can draw a graph, something like: monday: 10 - tuesday: 9,8 etc. etc.
I have no idea on how to do it, can you please help me?

Thanks in advance

Perhaps this is of help:

Thanks for your answer but no, it does not seem to be what I need, I need something that is resetted everyday at midnight or at least that stores its values everyday at 23.59.59.
Thanks again

You will probably need to fiddle with a history statistiscs sensor anyway. No out of the box solution.