Show how often person has been in a zone - for a given time period

Hi!
This might end up being to complex to achieve, but i want to hear if any of you have done anything similier.

First the usecase:
My son has a parttime job at a grocery store, and somehow they forgot to record his working time, so he was asked about some specific days - if he had been on work those days.

Being a teenager - his memory doesnt serve him well :slight_smile:
so to help i - used the history section in home assistant
because i have created a zone, that covers the address of his workplace.
this way i was able to see the days - where he had been in the zone for over 2 hours.
And i could easily help.

Now - it is a bit cumbersome - looking into the history logs etc.
so i was thinking about making a script.
either i ha or in nodered.
i havent determined how to communicate it yet, but it could be either tts, notification or a text sensor.

now to the question:

is it possible to create an automation that looks into the history
and graps all records of person.xx when they spent at least xx amount of time in a give zone.xx
and then return the start zone time + end zone time.
in a given time period… start date - end date?

Best regards
Ronni

Did you get anywhere with this? It’s exactly what I’m looking for.

I’ve been messing around with custom db tables and have been trying to use Grafana to view the data, i.e. visit count to specific/all zone(s) by day/week/month.

No joy yet.

As a starting point, you can use the history sensor

But that will give you the number of time he was in the zone or the time spent in the zone.
For start date/end date, you can use 2 input_datetime helpers that you’ll use in you sensor.

If you want to be more precise, that will require some automation(s) and helper(s).

@jmoorey1, for you, the history sensor is what you need.

1 Like

Thanks for your reply Olivier.

I was hoping to be able to display the history of visits to zones in a dynamic chart, with ‘daily/weekly/monthly’ controls, similar to the charts in the energy dashboard. How would you suggest I prepare my data/sensor to be able to be used in this way? And do you know which chart/card I could use to display it?

Is it possible to use one sensor for variable lengths of time, or would I have to configure multiple sensors for specific windows, i.e. today, this week, this month, etc.?

The reason for asking is I want to be able to see the data over time, for example the number of visits to the office by week/month over the past year, but also want to see the number of times my wife or I collected our son from nursery last week.

Hi!
I never got any progress,
but the history stats actually seems pretty nice though.
my own thought (when i get time )
was to create a template sensor or a boolean that i could then update each time a specifik person entered the zone.

the problem is that the leaving and entering of zone are based on the
zone itself. and the zone has the information on who is in it.

The history sensor is taking a period, so you can define a sensor for today, this week, this month or even this year.

You can also try to do an automation that adds up to an input_number but then take always today and trigger it in the night as close as possible to midnight but not at midnight…
With the latest, you can define utility_meter (even if it is not a utility, you have to try)

utility_meter:
  zone_monthly:
    source: input_number.zone
    cycle: monthly
  zone_daily:
    source: input_number.zone
    cycle: daily
  zone_weekly:
    source: input_number.zone
    cycle: weekly

To try, not sure if HA will like that it is unit less.
If this works, you’ll have a statistic sensor that you can graph, like I did for my washing machine

image

chart_type: bar
period: month
days_to_show: 365
type: statistics-graph
entities:
  - entity: sensor.lave_linge_energy_monthly
    name: ' '
stat_types:
  - state
card_mod:
  style:
    .content statistics-chart $ ha-chart-base $: |
      .chartLegend {
        display: none;
      }
1 Like

Hi there,
I just stumble on this topic while looking for ways to store ZONEs events (entry/leave) for further analysis. I wish to have more time to do all I need in HA, but sometime I am forced to use the stuff (workaround) that works using other ways that I am more familiar with.

@hostrup not sure if Google maps is an option for you on your mobile, but Google does a GREAT job of keeping track of pretty much every location, time driven/walked/biked or others. Works on Android and iPhones (you just need Gmail account). At any time you can view these stats, and they provide basic graphs to go with it.

On the HA side you can use Zone as a trigger (or anything else for that matter NFC tag / light.switch) and create CSV file with timestamp for each event that you inquire. CSV file can be open in Excel and now your options are basically limitless (especially if you like Power Query) !
Zone → Notify → File
Based on the above I keep a track of my work hours, supplies inventory (NFC / QR codes help here too) , driving record for the kids and few others.
Ideas are endless just not the required time to implement everything that I want to do :grin:

I think this might interest you …