Repository navigation
Preserve Leaflet map on dynamic entity configuration updates - #219
KevinBodwell wants to merge 4 commits into
Conversation
|
This is a real problem — Not merging yet:
Once tests are in I'll merge this. It will make the Blitzortung / |
…-entity-config-update # Conflicts: # src/components/MapCard.test.js # src/services/render/EntitiesRenderService.js # src/services/render/EntitiesRenderService.test.js
|
I hit the same rebuild with auto-entities on a feed that changes every few seconds, and fixed it the same way in my own copy of the card: reconcile in place, keep an entity whose config is unchanged, recreate one whose config changed, and fully clean up one that left (marker, circle, GeoJSON and history stream). On your review points: mine has the tests you asked for (unchanged entity kept, changed entity recreated, removed entity cleaned up, plus @KevinBodwell, if you're still working on this, you're welcome to the tests for #219. If you'd rather hand it off, I can open a PR built on yours, with your commit kept. Whichever you prefer. |
Preserve entity configuration tests alongside upstream zoom control tests.
I use ha-map-card with auto-entities to display frequently changing geo_location data, most notably Blitzortung lightning strikes. New strikes are added as they arrive, and existing strikes move through different size/color groups as they age before eventually disappearing. Because auto-entities updates the card configuration whenever that generated entity list changes, ha-map-card was rebuilding the entire Leaflet map for each of those updates. During active weather this could mean repeatedly recreating the base tile layer for every new strike or age transition, causing unnecessary tile requests, visible map refreshes, and loss of the efficiency Leaflet normally provides by keeping the underlying map in place while only changing its data layers. The goal of this change is to let dynamic entity sets update normally—adding, changing, and removing markers—without recreating the underlying map when the map configuration itself has not changed.
During testing, repeated failed entity creation exposed that each warning created a new Leaflet attribution control. Warning controls are now reused and duplicate messages suppressed.
Example config:
In this setup, new lightning entities are continuously added, existing entities move between age-based style groups, and old entities are removed, causing auto-entities to repeatedly call setConfig() on the same map-card.