#so, I am pretty sure I know what this is
1 messages ยท Page 1 of 1 (latest)
I based it on my own entities
which are following the following naming convention:
sensor.<zone name>_<person/device_tracker object id>_distance
so that <person/device_tracker object_id> part should be the same as the result for nearest, which is the name of that entity
so the slugified name of the entity should not differ from the object id
maybe i am missing out on where object_id is?
still not tracking
auh, object id is just the entity name
beyond the distance and direct of travel entities, i only have sensor.home_nearest_device so hass is listening for sensors that dont exist? that is what is confussing me
the entity_id consists of domain.object_id
if a device is created, you can access it that way as well by filtering based on device_class
found a bug in the integration when I wanted to test something
I think the neares_device entity always uses the home zone
so maybe you are both saying thst {{ direction }}
{{ distance }} should be unknown? or you are saying it is a way to generate different sensors to use in other places? this may just be beyond my understanding?
or maybe my example helped you find s bug?๐
distance should not be unkown, direction of travel could be
I wanted to test something, but found I bug while doing that
but this is what it is listening for:
Entity: sensor.home_k_m_d_direction_of_travel
Entity: sensor.home_k_m_d_distance
Entity: sensor.home_nearest_device
so this is the template:
{% set zone = 'thuis' %}
{% set nearest = states('sensor.{}_nearest_device'.format(zone)) | slugify %}
{% set direction = states('sensor.{}_{}_direction_of_travel'.format(zone, nearest)) %}
{% set distance = states('sensor.{}_{}_distance'.format(zone, nearest)) %}
{{ nearest }}
{{ direction }}
{{ distance }}
okay
that helps
just a direction of travel and distance entity for each device tracker and sensor.home_nearest_device
yes, but what is the entity id of the distance entity
I can explain with my example
I could finally do my test properly
So:
- I have an device_tracker with entity_id:
device_tracker.carand friendly nameAuto
I created the proxity config entry using that device tracker
so this, home_k_m_d_direction_of_travel, is grouping object ids of 3 different direction of travel entities
wait
Can you tell me this:
- the entity_id of the device tracker you used
- the friendly name of the device tracker you used
ah, I think we're getting there ๐
the problem is, the nearest_device sensor shows the friendly name of the device tracker
if that doesn't match the object_id of the device tracker, the template above will fail
auh, ok, yes, i ised customize.yaml to rename all the entities
the entities are created based on the object id
wait a sec
{% set zone = 'thuis' %}
{% set nearest = states('sensor.{}_nearest_device'.format(zone)) %}
{% set nearest_object_id = states
| selectattr('domain', 'in', ['person', 'device_tracker'])
| selectattr('name', 'eq', nearest)
| map(attribute='object_id')
| first
%}
{% set direction = states('sensor.{}_{}_direction_of_travel'.format(zone, nearest_object_id)) %}
{% set distance = states('sensor.{}_{}_distance'.format(zone, nearest_object_id)) %}
{{ nearest }}
{{ nearest_object_id }}
{{ direction }}
{{ distance }}
this should work
to me, it looks like it is substituting the results of the state of sensor.home_nearest_device
sensor.home_nearest_device displays the friendly name of the nearest device_tracker/person
but the integration uses the object_id of the person/device_tracker entities when creating the entity_ids for the distance and direction_of_travel entities
that produced the same results except for it capitalized the {{nearest}] and put commas instead of slugifying everything else is unknown
maybe it is because i have three differnt entities at home so my nearest is basically three different names
so then it generates entities that dont exist
K, M, D
ah that's it
Should have known that, becasue I've noticed that
moment
{% set zone = 'thuis' %}
{% set nearest = states('sensor.{}_nearest_device'.format(zone)) %}
{% set nearest_object_id = states
| selectattr('domain', 'in', ['person', 'device_tracker'])
| selectattr('name', 'eq', nearest.split(',')[0])
| map(attribute='object_id')
| first
%}
{% set direction = states('sensor.{}_{}_direction_of_travel'.format(zone, nearest_object_id)) %}
{% set distance = states('sensor.{}_{}_distance'.format(zone, nearest_object_id)) %}
{{ nearest }}
{{ nearest_object_id }}
{{ direction }}
{{ distance }}
so if only one person is close to the zone, it should work. it would seem that is a decice tracker had arrived, it wouldnt be part,of newrest
all unknown now. if i am helping you, we can continue. if you are just helping me, i was really just trying to see if the template would be useful ๐คฃ
just made a change
in here or in beta or both?
here
did you add one device tracker in the config of the proximity integration, or did you add 3?
No first item, sequence was empty.
and all unknown
i added 5
three of which are home
okay, and 3 are at home
so they report in the nearest
are you sure you have the version above?
can you screenshot devtools > template for me
auh, hold on
i forgot to change zone to my zone
so now it reports
K, M, D
k
unknown
unknown
If this creates a device, that's probably going to be the best route to go.
identifiers on the device should contain the original object_id or some indication what zone it's using
the proximity integration doesn't create a device?
but it creates entities?
Yeah, I'm not sure how we can ensure that everything is related. That's a miss-step in my opinion.
This should be brought up in the beta channel
because now users can't change the entity_id's or relate the entities in any way other than an assumption.
even if you use integration entities, you're still SOL when you have more than one proximity set up.
Yes i'ts not a physical device, but we have to have a way to relate them via templates.
So it does
do device_attr('sensor.thius...', 'indentifiers')
that's why that whole section is called devices and services
which are different services compared to devtools > services
right, so you're trying to piece together the service, correct?
did we ever add something to get a config entry attribute?
if not, this might be a good time to consider that
config_entry then get the original entity_id. Pretty sure that's a field
for each device_tracker/person it creates the distance and direction_of_travel entity
with naming convention sensor.[slugified name of zone]_[object_id of person/device_tracker]_distance
not sure why it uses name for the zone, and object_id for the device tracker
but it does
because other zones would create the same entity_id if we just used the object_id
then, for each config entry it has a sensor.[slugified name of zone]_nearest_device
in which it has a comma seperated string with the friendly names of the device_trackers/person entities nearest (or in) the zone
so, what I tried to do with the template above, is to determine the distance and direction of travel of the device_tracker/person nearest to zone
so I take the (first) name of the nearest_device sensor
and try to find the matching object id
(which potentially could go wrong, as names are not unique)
you could create regex to filter the zones first
but if I could the actual device_tracker/persons used for the device attributes, that could improve it of course
In my first version I just slugified the name, but that doesn't work if the name doesn't match the object_id
{% set fmat = '^(' ~ states.zones | map(attribute='name') | join('|') ~ ')' %}
{{ states.sensor | selectattr('object_id', 'search', fmat) }}
^ that's what I was saying
have @fading monolith put that into his system and look at the list
{% set fmat = '^(' ~ states.zone | map(attribute='name') | map('slugify') | join('|') ~ ')' %}
{{ states.sensor | selectattr('object_id', 'search', fmat) | map(attribute='entity_id') | list }}
Sry this ^
that might shed the light on what's happening
oh zones, should be zone ๐คฃ
Yah
wait, an alternative to what I had, is to take all distance sensors, and take the smallest
you'd still need to match the zone name because I would assume that 2 zones with 2 people could have varying results
for a single zone, sure
yeah, but that was the idea in the end, to show the distance and direction of the entity nearest to the zone
to replicate how it's shown in the old style proximity integration
state was the name of the nearest entity, and the distance and direction of the nearest entity were 2 attributes
no wait
state was the distance
Marius shared a screenshot yesterday
but that was zillions of posts ago
sorry to be a pain, but nearest device outputs the object_id?
ugh
this seems poorly thought out
I think it needs further discussion
it's a major breaking change with little recourse to get old functionality back
well, in case 2 entities are both as near (or both _ in_ the zone) it's a comma seperate string with both names
Sorry. At the gym. And arguing language. Will get back to you
yeah I already mentioned that I expect negative feedback from the community
this will be massive negative feedback
I really stopped participating in opinion stuff for hass. This one drug me down. That why I try to deal specifically with errors these days
Today was a mistake ๐คฃ
I appreciate you twos help.
Bad English ๐คฃ. But on a treadmill
{% set zone = 'thuis' %}
{% set ns = namespace(object=None, distance=None) %}
{% for s in expand(integration_entities('proximity'))
| selectattr('entity_id', 'search', 'sensor.'~zone ~'.*_distance')
| selectattr('state', 'is_number')
%}
{% if loop.first or s.state | float < ns.distance %}
{% set ns.object = s.entity_id | regex_replace('sensor.'~zone~'_|_distance', '') %}
{% set ns.distance = s.state | float %}
{% endif %}
{% endfor %}
{{ ns.distance }}
{{ states('sensor.{}_{}_direction_of_travel'.format(zone, ns.object)) }}
@fading monolith can you test this when you're back?
Yes
I am not jumping in the beta discussion. I agree with the 2 new nearest entities but is there a way to add logic that says nearest but not in @restive geyser
Or we can just template that pretty easy?
What do you mean? Iโm not 100% familiar with old or new versions of the integration
the logic for that is the same as for the old one
so that's not backwards incompatible
you can do it with templates, take a list of device_trakcers/person entites, reject those which are home, and use closest() on the remaining ones
{{ closest('zone.home', states.person | rejectattr('state', 'eq', 'home') | map(attribute='entity_id')) }} this will give the state object of the closes person not at home, and none if everyone is at home
๐
That worked with an output of:
0.0
arrived