Customize standard map

I would like to put a few markers on the standard map.

I have an entity which has a list of POIs containing long and lat:

pois
- id: 1
  long: x
  lat: y
- id: 2
  long: x
  lat: y

Can the map only show entities or also attributes?

Map only shows individual entities or sources from geolocation integrations.

you can put anything you like on the map, but they have to be zones with a radius.

eg:

zone:
  - name: <name_here>
    longitude: x
    latitude: y
    radius: 1 # making it small for you
    icon: mdi:xxx

…and then just ignore it as a zone.

Or just create these template sensors:

template:
  - sensor:
    - name: poi_1
      state: not_home
      attributes:
        latitude: xxxx
        longitude: xxxx
    - name: poi_2
      state: not_home
      attributes:
        latitude: xxxx
        longitude: xxxx

and add them to your Map.
(and ofc you can CHANGE these POIs by some helpers in templates)

type: map
entities:
  - entity: sensor.poi_1
  - entity: sensor.poi_2
theme_mode: auto

Also, make these markers displayed with different labels by either using customized “friendly_names”:
image

Or use a custom card to have icons displayed:

type: custom:map-card
entities:
  - entity: sensor.poi_1
    display: icon
    color: red
  - entity: sensor.poi_2
    display: icon
    color: green
card_size: 10
2 Likes

nice - way better than mine! :+1:

Ok its only possible with a sensor not with attributes.

The issue is the POIS are dynamically and can change after a scan interval.
Maybe it’s easier to do it with an custom integration

And why not making a template sensor using your sensor as a source ?)))

1 Like

Because I cannot iterate over the array of the source or how should I do this?

If number of members in that array can be different - consider a manual creating “device_tracker” entities in automation:

  1. Triggered by your source sensor (when an array of POIs is changed).
  2. Enumerate this array: for every member call a “device_tracker.see” service with some “device_tracker.poi_i” (where “i” is a loop index).

If today you have 10 members in the array, and yesterday you had 8 members - you will create 2 more “device_tracker” entities today.
If tomorrow you have 7 members - you will still have 10 entities (and last 3 are considered as “outdated”). Then use “auto-entities + Map card” to filter out only “new” (not outdated) entities (use a size of that array to know a valid number).

1 Like

Ok thanks for the idea. Then I have now more question :slight_smile:

a) What happens if I have less sensor e.g. 10 sensor before and after the trigger 8? How can I invalid the other 2?
EDIT: ok you answered that.
I can try this

b) I think better is always to create complete new sensor(s) because also if the counter is the same the content could be changed (same I would do with a custom inegration, but also hit the same issue not sure how to create always complete new sensors).

Answered as well: that automation will REPOSITION these same 10 trackers.

BTW, which integration creates these poi-sensors?

Yes I can try that

It’s currently my (first) own integration. That’s why I’am playing around to create the sensors, but currently struggling to destroy or replace the created sensors.

I would keep it same way - create ONE sensor with an array of pois → then create trackers as was proposed.
Also, one more trick: before calling “see” service - delete these trackers from “known_devices.yaml” (manually or automatically: if only these trackers are stored here - just purge whole file) - then you will always have new trackers only ))))

If you’re writing an integration I believe correct way to do this would be to make use of the geolocation building block.

That will create and destroy sensors, and it gives an easy way for map card to plot all sensors of this integration by adding it to geo_location_sources.

This is working so far.

I have two variants of the sensor

e.g. sensor value 2

attributes

last_update: 2024-09-06T18:02:25.822820+00:00
warning_count: 2
warnings: 
- id: 'yyy'
  latitude: x
  longitude: y
  street: x StraĂźe
  vmax: '70'
- id: 'yyy'
  latitude: x
  longitude: y
  street: y StraĂźe
  vmax: '40'
  distance: 19.98461987605191

or

warning_1_id: 24663607935
warning_1_latitude: x
warning_1_longitude: x
warning_1_street: x StraĂźe
warning_1_vmax: 70
warning_1_distance: 19.511457259283993
warning_2_id: 24663607707
warning_2_latitude: y
warning_2_longitude: y
warning_2_street: y StraĂźe
warning_2_vmax: 40
warning_2_distance: 19.98461987605191

Use array. Easier to process. Also can be shown in flex-table-card.
Or “go strategic way” and rebuild the integration as was suggested above by HA developer.

1 Like

Is there an example how to build it from an own integration? I have all data currently in the single sensor. So what I need is just create/destroy the sensors for POI

For me both would be okay, if it works :wink:

Found here an example maybe I try this first:

EDIT: what I not get is, how can I remove _managed_devices after a restart? Is this persist somehow?

The example works so far that the entities are created and deleted again. They are also shown on the map. As expected but not after a restart. It’s a shame it would be too easy ;).

Another question: the entities have an mdi icon, can this be displayed on the map?