Counting how many times a location switched to a specific value

Hi there :slight_smile:

For doing our tax, we need to provide an information on how many days in a year we went to our office, or worked in home office.

Now, I am thinking that it should be possible to do that with a counter …

  • I am tracking the location of myself and my wife.
  • it is either @home or the zone “office”
  • based on other information, such as : Workday / do we have holidays, etc. it should be possible to count how many times the location switched to “home” or to “office”…

BUT:
there are some additional rules that might need to apply:
→ location switched from “office” to “away” → and then back to office, within the same day should not be counted
→ location switched from “away → home” or “home → away → office → away → home” should only count for office
→ location stays on “home” for multiple days should count the “home” counter for each day…

The sensor should start at january first - and count until end of the year… a new cycle should then start… but the history needs to be stored, because I need the values from the previous year when making the tax…

Any Idea on how this could be done?

I’m doing very similar to this. You get it worked out?

Hi, Sorry - not really… I didn’t had the time to start looking into this yet … and I am not sure, If I will be able to do so in the next couple months, since this does not have a very high priority for me atm…

I am going to try to achieve this with history_stats…
The only thing which bothers me is “person is jumping between zone_1 and not_home”.
Probably this may be solved w/o using history_stats: automation is triggered by “person got to zone_1” with a defined “for”, then incrementing a counter (which is reset periodically by another automation).