Triggered by your source sensor (when an array of POIs is changed).
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).
Ok thanks for the idea. Then I have now more question
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).
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.
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.
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
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?