Dynamically define a zone around yourself

Hi everyone,

is there a way to dynamically define a zone around yourself based on your gps location?

I have a car with a gps module which is also tracked on home assistant, and would like to set it’s state to ‘nearby’ if it’s inside the zone around me. My phone updates my location with owntracks and the car updates it’s state on HA every 5 seconds.

Not sure you can do this, but you could create a waze sensor that returns the distance between car and phone:

- platform: waze_travel_time
  name: Lolo to Home
  origin: device_tracker.phone
  destination: device_tracker.car
  region: 'EU'

image

Thanks, i’ll check this out! I would ideally like to set the state so I can just have one icon for the car in the dashboard. I’m also running node red, if that helps.

not sure what you mean by that, but you can create a template binary_sensor that pulls the data out of the waze sensor attributes and return a true/false based on distance, then display that device in your dash…

33

Basically I would want to set the ‘away’ in the above image to ‘nearby’ if distance between me and the car is <100m. I thought about using zones to do this because then I can have notifications fire off if the state of the car changes from ‘away’ to ‘nearby’ and change the icon above to nearby.

I can also do this with distance, and prevent further notifications from firing by comparing the last state with the current one. This would involve 2 icons in the interface though ( the away icon and the new one with distance)

ok then create a template sensor (not binary):

- platform: template
  sensors:
    car_location:
      value_template: >
        {% if states.sensor.name_of _waze_sensor.attributes.distance | int <= 100 %}Nearby
        {% else %}Away
        {% endif %}

then add this entity to your dashboard?

Thanks, I modified the code as seen below and it works great! Is there a way to make the icon disappear when it’s set to away?

> sensor:
>   - platform: template
>     sensors:
>       distance:
>         friendly_name: test
>         value_template: >-
>           {% if distance('device_tracker.me', 'device_tracker.car')|float < 0.2 and is_state('device_tracker.me', 'not_home') %}Nearby
>           {% else %}Away
>           {% endif %}

as far as I know you can only hide groups, not individual entities.
Or if you want to take the plunge to lovelace, you can use a filter card, but in lovelace we don’t have the icons on top like we used to have in “regular” HA…
If you add your icon to a group and display the group, it won’t show up as an icon on top but in a card on the main area…

1 Like

If you integrate lovelace, you can hide individual entities using the entity_filter card. As for the regular UI, I believe @lolouk44 is correct when saying that only groups can be set visible/invisible.

1 Like

Thanks @petro I think a move to lovelace may not be what @Minsk11 wants if (s)he doesn’t want to lose the badges. I know I miss them in lovelace :wink:

Badges are in lovelace! Took a bit, but they are back:

OMG I’m so excited !!! Thanks @petro

Thanks! I’m looking into moving to lovelace, so there’s more reason to do it now.

@Minsk11, @lolouk44, I don’t think you can use visibility on badges yet though. Only in the condition card and entity-filter card:

it’s a start I guess.

While we’re on the subject, do you know if/when groups will be automatically expanded?
At the moment it shows the group name and its state instead of listing all entities in that group.
I know there’s a work around but I’d prefer keeping it as bog standard as possible

I do not know that. I think Lovelace is taking it’s sweet time getting up and running with the old interface options. I’ve noticed that I don’t use groups as much in lovelace because of all the cards display information differently. Picture-glances really turned my interface into a nice UI. Marry that with a few glance cards and I’ve got all the info I need without the hundreds of groups I had in the old UI.

Thanks, there are only a couple of views when I want the groups, and these are the group.all_xxx
For example I have a tab that solely lists all my automations, and the group.all_automations is great for that as it does not require any maintenance as I update/create/remove automations.
Everything else is listed as I want it…

Yeah, that’ll be a big config change then. Might want to wait. I wouldn’t be surprised if they add a native group card .

1 Like