Duration of stay in certain zones

Hello,
via the Person functionality (via mobile app) I have the location history tracked and documented. For this purpose, I have stored different zones (e.g. home, work).
Is it possible to use the historical data and display how long I was in which zone per month or per defined time range?
Do you have a tip for this?

It seems to me that it would have been easier to realize if I had a counter that counts up the hours.
Thanks and best regards
Christian

You would need to set your recorder to keep 31 days of data if you want a whole month, then you could use the History Stats sensor.

Here is an example that sums up all the hours per month (as tom_l mentioned your recorder needs to be set up correctly):

Under your sensor:

- platform: history_stats
  name: Hours in the office
  entity_id: person.valentin
  state: "Valentin Büro" # you need to specify a zone to track
  type: time
  start: "{{ now().replace(day=1, hour=0, minute=0, second=0, microsecond=0 ) }}" #current month
  end: "{{ now() }}"