Hello! Short question
Could anyone say how can I make this condition?
There is only one device_tracker at home
And no matter who.
Hello! Short question
Could anyone say how can I make this condition?
There is only one device_tracker at home
And no matter who.
You can use groups:
people_home:
name: Anyone home
entities:
- device_tracker.phone1
- device_tracker.phone2
- device_tracker.phone3
Status of the group is home if anyone is home.
Unless lost in translation that may not be what they were after
Sorry for being unclear
I need the condition to work only in situation, when 1 person is at home, not more.
And guys, how would I ask that correct? Do a little English lesson for me, please
Disregard, misread you request.
assuming they are all device trackers
- condition: template
value_template: >
{{ states.device_tracker | selectattr('state','eq','home') | list | length == 1 }}
Or if you want to check against a group of device trackers or on/off sensors.
- condition: template
value_template: >
{% set group = 'group.people_home' %}
{{ states | selectattr('entity_id','in', state_attr(group,'entity_id')) | selectattr('state','in',['on', 'home']) | list | length == 1 }}
Seems to work just fine! I used second one with group because I have 2 device trackers on 1 person.
Thank you!
Yeah that’s a good start. That’s the API. It can be cryptic though. And it doesn’t really cover much in relation to examples. I learned by reading that and cruising these forums. Learning python doesn’t hurt either because there are a lot of similarities, especially with object types.