nathan-gs / ha-map-card

A Map Card for Home Assistant
https://community.home-assistant.io/t/map-card-a-slightly-improved-map-card/693088
MIT License
15 stars 4 forks source link

does not always draw trackers and history #29

Closed Hiekkaharju closed 1 month ago

Hiekkaharju commented 1 month ago

there is some issue with initial drawing, In some cases, at least right after dashboard edit, no indication of any trackers or history is drawn. On a browser e.g. f5 refresh fixes this. Apparently -on android companion app- also just dashboard tab change from the view with the card to another and then back leaves the data undrawn. I'm not aware of any refresh that would fix, exept restarting whole HA companion app.

nathan-gs commented 1 month ago

The history is loaded async, so it could be it's just slow.

nathan-gs commented 1 month ago

It should be solved in v0.8.2.

nathan-gs commented 1 month ago

I added unsubscribe logic hopefully solving this.

Hiekkaharju commented 1 month ago

Sorry but this seems to still exist. And now I checked also "from the view with the card to another and then back" with browser and that also fails (view= "tabs" on a dashboard. When going to another dashboard and then returning works = from sidebar.

nathan-gs commented 1 month ago

Can you take a look at the Browser console to see if you see any error?

Hiekkaharju commented 1 month ago

1st: I'm no web developer, I just and just knew where to find the console :) Please don't expect much... Not really any errors. [Violation] 'requestAnimationFrame' handler took ###ms comes, but it also comes with F5 refresh succesful draw. When leaving the view, I see unsubscribe notices. But only with F5 or dashbord change I see "First render.." and subscribe notices, not by just a view change

Hiekkaharju commented 1 month ago

I might have figured this out. Adding this.firstRenderWithMap = true; to e.g. place where this.map.remove(); is done, seems to fix the issue.

nathan-gs commented 1 month ago

Very interesting @Hiekkaharju! I just noticed I might have the same issues in certain cases. Will try your work around!

nathan-gs commented 1 month ago

Can you test with v0.9.0?

Hiekkaharju commented 1 month ago

Seems to work. Thanks again :)

OT + FYI: I see you added fallback coordinates. If I read the code correctly they will be used only if longitude/latitude is empty. I've a device which returns -1,-1 as coordinates if it can't get a fix. I don't know if that's common. I've already earlier made an automation which replaces those -1,-1 with fixed coordinates using see-service, so I do not need support for -1 fallback, but somone else might.

nathan-gs commented 1 month ago

Problem is -1,-1 however unlikely is a valid coordinate. Would be better to set it to null.

nathan-gs commented 1 month ago

It would not be hard to check for this. WDYT @Hiekkaharju?

Hiekkaharju commented 1 month ago

Based on your previous reply, if I were you, I would leave it for now and if someone else later asks for it, take this as a +1

edit: I decided to add info that the -1,-1 I have seen is generated by an esphome device. Thus it's likelihood in HA enviroment is bigger than that of some random device.