Has anybody developed a way to track each person and how long they’re in each zone?
Something like…
User-1
- ZoneA = 27 minutes
- ZoneB = 14 hours, 15 minutes
- ZoneC = 4 hours
User-2
- ZoneA = 58 minutes
- ZoneB = 9 hours, 55 minutes
- ZoneC = 6 hours
Has anybody developed a way to track each person and how long they’re in each zone?
Something like…
User-1
User-2
Yes!
For example, this will measure per day, resetting at midnight:
- platform: history_stats
name: Something
entity_id: person.xxx
state: THE_STATE_TO_TRACK
type: time
start: "{{ now().replace(hour=0, minute=0, second=0) }}"
end: "{{ now() }}"
More info: Prevent zone automation from triggering when briefly entering zone - #5 by Didgeridrew.
Thanks!
That looks helpful…
Does that mean I’ll have to set the state: THE_STATE_TO_TRACK for each zone?
I think so: A sensor for each person, and value per zone.
Just to come back to this to see if I have this correct, I would need to create multiple for each person AND zone?
As something like this will calculate when they’re at all those places?
PersonA
-Zone ‘home’
- platform: history_stats
name: Person A - Zone home
entity_id: person.a
state: >
- home
- away
- work
type: time
start: "{{ now().replace(hour=0, minute=0, second=0) }}"
end: "{{ now() }}"
So needs to be something like this…
PersonA
-Zone ‘home’
- platform: history_stats
name: Person A - Zone home
entity_id: person.a
state: >
- home
type: time
start: "{{ now().replace(hour=0, minute=0, second=0) }}"
end: "{{ now() }}"
PersonA
-Zone ‘away’
- platform: history_stats
name: Person A - Zone away
entity_id: person.a
state: >
- away
type: time
start: "{{ now().replace(hour=0, minute=0, second=0) }}"
end: "{{ now() }}"
PersonA
-Zone ‘work’
- platform: history_stats
name: Person A - Zone work
entity_id: person.a
state: >
- work
type: time
start: "{{ now().replace(hour=0, minute=0, second=0) }}"
end: "{{ now() }}"
PersonB
-Zone ‘home’
- platform: history_stats
name: Person B - Zone home
entity_id: person.b
state: >
- home
type: time
start: "{{ now().replace(hour=0, minute=0, second=0) }}"
end: "{{ now() }}"
PersonB
-Zone ‘away’
- platform: history_stats
name: Person B - Zone away
entity_id: person.b
state: >
- away
type: time
start: "{{ now().replace(hour=0, minute=0, second=0) }}"
end: "{{ now() }}"
PersonB
-Zone ‘work’
- platform: history_stats
name: Person B - Zone work
entity_id: person.b
state: >
- work
type: time
start: "{{ now().replace(hour=0, minute=0, second=0) }}"
end: "{{ now() }}"
That’s what I had in mind. I don’t know if it could be simplified.
This doesn’t work for me. My time always stays at 0. The zones are correcty tracked in the person entity, but I can’t extract the hours per day. Does the state have to be exactly called as the zone name? I tried “work” and “Arbeit” (as my zone is actually called).
Same for me, tracking time stays on 0.0?
hi,
I do this on my side in my sensors.yaml: