manos
(Manos)
January 2, 2023, 7:17pm
1
Hello,
I have the follow template sensor on my configuration.yaml
- platform: template
sensors:
home_parents:
unique_id: home_parents
unit_of_measurement: 'Parents'
value_template: "{{ [ states.device_tracker.mobilephone1,states.device_tracker.mobilephone2,states.device_tracker.mobilephone3,states.device_tracker.mobilephone4 ] | selectattr('state', 'eq', 'home') | list | count }}"
This code returns how many people are at my home. I would like to modify this or a new template sensor that returns how many people are at my home more than X minutes.
for example I want a counter / number with the persons that are more than 1 hour.
What is the source integration for the device trackers?
You may need to alter the consider_home
value or use a manually configured device tracker to accomplish what you want.
Device Tracker
manos
(Manos)
January 2, 2023, 8:07pm
3
If you are just starting out you should use the current format for template sensors instead of the legacy format.
{{expand('device_tracker.mobilephone1',
'device_tracker.mobilephone2',
'device_tracker.mobilephone3',
'device_tracker.mobilephone4')
| selectattr('state', 'eq', 'home')
| selectattr('last_changed', 'lt', now()-timedelta(minutes=60))
| list | count}}
One thing to keep in mind is that the last_changed
property updates on restart, so any sensor based on it will not be accurate after restart either.