Hi,
I am would like to create a sensor which will at the end of the calendar month contain the amount of time the nanny spent in our house, to help me pay her right for when she stays longer.
Her phone connects to the network, so I am tracking when she is present, so in the end I need to do some stats on person.nanny
.
The problem is that she goes in and out durign the day, her phone sometimes disconnects etc, so I am interested in ony tracking the time between her first appearance and her last in that day. My idea is as follows:
- Have an automation write the current time into an
input_datetime.first
whenever person.nanny goes from off to on. Condition this on aninput_boolean.not_here_yet
which will get set to false once this automation gets triggered and reset back to on at midnight - Have an automation write the current time into an
input_datetime.last
whenever person.nanny goes on to off. - have a template sensor
sensor.nanny_hours
tracking the time difference betweeninput_datetime.last
andinput_datetime.first
, with some logic to set it to zero after midnight - have a history sensor sum the total
sensor.nanny_hours
since the first day of the month
Is this optimal? Or is there some smarter way of doing it (e.g. just with a template sensor with some triggers?)
Thanks for suggestions!