I know the history stats sensor can do this but I have a special requirement that I don’t think it can accommodate. I’d like to measure from the first time the person is home to the last time they are home as assume all of that time in between is at home even though they will come and go.
Should this just be some manual datetime inputs that are set and then just do some math at 11:59?
For the first time you could do a binary sensor and a date/time sensor. Both are triggered by an automation with a conditional rule on the binary sensor (if binary sensor has been triggered before then do not set the date/time sensor) and a second automation to reset the binary sensor at night.
The last time is a simple date time sensor which only resets at midnight.
Now you can calculate the time between the two date time sensors to determine the time for your use case.