audiconnect / audi_connect_ha

Adds an audi connect integration to home assistant
MIT License
227 stars 98 forks source link

fix: Handle Device_Tracker missing timestamp gracefully #374

Closed coreywillwhat closed 5 months ago

coreywillwhat commented 5 months ago

Intermittent issues with device_tracker are reported in #307 . Updated Error logs are pointing to no timestamp being reported. Adding to gracefully handle this scenario.

I'd prefer to default to the last_update_time timestamp, but maybe in the future on a beta branch. Currently using None as default and its working for me. Looking at dashboard.py, None is also used by default for these values there.

https://github.com/audiconnect/audi_connect_ha/blob/master/custom_components/audiconnect/dashboard.py#L298-L326

I've tested hardcoding None into both values as below and the tracker is working as expected. It seems so long as lat/lon are provided it will work.

                self._vehicle.state["position"] = {
                    "latitude": resp["data"]["lat"],
                    "longitude": resp["data"]["lon"],
                    "timestamp": None,
                    "parktime": None,
                }