audiconnect / audi_connect_ha

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

Location update is lost during the last updates #400

Closed synack666 closed 3 months ago

synack666 commented 4 months ago

Describe the bug during the last updates the location update is not working anymore, the car is always at home To Reproduce

Your Vehicle Details Model: S4 Year: 2018

Kolbi commented 4 months ago

Can you please provide a log?

Logfile How to enable audiconnect debugging? Settings > Integrations > Audi Connect > Enable Debug Logging Run service refresh_cloud_data Disable Debug Logging

synack666 commented 4 months ago

2024-04-18 074516.450 DEBUG (MainTh.txt

Kolbi commented 4 months ago
2024-04-18 07:45:24.531 DEBUG (MainThread) [custom_components.audiconnect.audi_connect_account] POSITION: Starting update_vehicle_position for VIN: *************2845
2024-04-18 07:45:24.531 DEBUG (MainThread) [custom_components.audiconnect.audi_connect_account] POSITION: Attempting to retrieve stored vehicle position for VIN: *************2845
2024-04-18 07:45:25.266 DEBUG (MainThread) [custom_components.audiconnect.audi_connect_account] POSITION: Vehicle position data received for VIN: *************2845, lat: ##.######, lon: ##.#####, timestamp: 2024-04-17 18:56:35+00:00, parktime: 2024-04-17 18:56:35+00:00
2024-04-18 07:45:25.267 DEBUG (MainThread) [custom_components.audiconnect.audi_connect_account] POSITION: Vehicle position updated successfully for VIN: *************2845

It seems location was successfully updated?

synack666 commented 4 months ago

Yes, it looks like this in the log, but when I drive somewhere and park 10 kilometers away, for example, HA still says that I am at home, i.e. my car

Kolbi commented 4 months ago

Can you then check the gps location in the device_tracker if it's still the home gps location or has the coordinates 10 kilometers away?

synack666 commented 4 months ago

will try, not so easy cause only with mobile

synack666 commented 4 months ago

Screenshot 2024-04-19 070609

today next try, yesterday i get the debug on mobile but dont be able to save ist, funny thing, back at home, car in garage, the location toggle

synack666 commented 4 months ago

Hi! test today, the position gets an update but then jumps back and forth between home and somewhere else, after a while it calms down. at the same time in the app the position remains unchanged. now the car is standing in front of the house, does not move and is recognized as absent and home again. but i don't see any constant position updates in the log. very strange

synack666 commented 4 months ago

log from today

2024-04-19 09:43:06.350 DEBUG (MainThread) [custom_components.audiconnect.audi_connect_account] POSITION: Starting update_vehicle_position for VIN: *************2845
2024-04-19 09:43:06.350 DEBUG (MainThread) [custom_components.audiconnect.audi_connect_account] POSITION: Attempting to retrieve stored vehicle position for VIN: *************2845
2024-04-19 09:43:07.900 DEBUG (MainThread) [custom_components.audiconnect.audi_connect_account] POSITION: Timestamp not available for vehicle position data of VIN: *************2845.
2024-04-19 09:43:07.900 DEBUG (MainThread) [custom_components.audiconnect.audi_connect_account] POSITION: Vehicle position data received for VIN: *************2845, lat: ##.######, lon: ##.######, timestamp: None, parktime: None
2024-04-19 09:43:07.900 DEBUG (MainThread) [custom_components.audiconnect.audi_connect_account] POSITION: Vehicle position updated successfully for VIN: *************2845
2024-04-19 10:50:54.409 ERROR (MainThread) [homeassistant.components.device_tracker] Platform audiconnect does not generate unique IDs. ID Audi S4 Avant Position already exists - ignoring device_tracker.audi_s4_avant_position
2024-04-19 11:11:12.215 DEBUG (MainThread) [custom_components.audiconnect.audi_connect_account] POSITION: Starting update_vehicle_position for VIN: *************2845
2024-04-19 11:11:12.215 DEBUG (MainThread) [custom_components.audiconnect.audi_connect_account] POSITION: Vehicle position support is disabled for VIN: *************2845. Exiting update process.
arandax commented 4 months ago

I've lost the sensor, it's not present anymore in the integration after I deleted and re-added the HUB

synack666 commented 4 months ago

i am back to 1.6.1 as a trial and the problem has disappeared

Kolbi commented 4 months ago

2024-04-19 10:50:54.409 ERROR (MainThread) [homeassistant.components.device_tracker] Platform audiconnect does not generate unique IDs. ID Audi S4 Avan

what have you done between 09:43 and 10:50?

I wonder what happens if timestampd and parktime is None like in your example but position is set.... https://github.com/audiconnect/audi_connect_ha/blob/5055bc34b14e99fda066ce9975da9e8c98ee99da/custom_components/audiconnect/audi_connect_account.py#L628

i am back to 1.6.1 as a trial and the problem has disappeared

Yeah some would now happen if you upgrade to v1.6.3 again I guess. Both versions seem to have the same bug but starting Home-Assistant new should help to get self.support_position to True again until the next failure.

I found a bug and corrected it immediately and pushed v1.6.4 - it could be related to your issue. Because we stopped position update by accident if climater support is not possible: https://github.com/audiconnect/audi_connect_ha/pull/403/

Kolbi commented 4 months ago

I found the confirmation in your logs:

2024-04-18 07:45:25.431 DEBUG (MainThread) [custom_components.audiconnect.audi_connect_account] ClientResponseError with status 403 while updating climater for VIN: *****2845. Disabling climater support.

Exactly what I though climater support was not available for your vehicle and disabled the position update per accident. This bug was introduced with v1.6.0 : https://github.com/audiconnect/audi_connect_ha/pull/379 :)

synack666 commented 4 months ago

just updated, will see

synack666 commented 4 months ago

what have you done between 09:43 and 10:50?

I was in the garage for service

synack666 commented 4 months ago

ok, seems like fixed for me thanks a lot for support (fast and good) i close here

synack666 commented 4 months ago

Unfortunately I have to realize that it is not fixed after all, one day it worked without any problems, after that the car is permanently at home again.

coreywillwhat commented 4 months ago

At this point I'm thinking it may be an API issue. I have also noticed GPS location doesn't always update for me either, but then other days it does work. The only thing left is to evaluate the raw data in your logs. We currently redact the GPS coordinates for obvious reasons, but i will add a PR for a commented line which will allow the user to remove the comment and display the raw data in the logs. User can then compare the raw GPS data coordinates to their expected vehicle position. If the data provided by Audi is incorrect to where the vehicle is actually positioned, this is an Audi API issue and we won't be able to address it further.

See #407 PR.

Kolbi commented 4 months ago

I also have some issues with the position API. My car still seems to be on the place it was yesterday. In the device_tracker the old GPS coordinates there present.

Changed code that I have full log with GPS coordinate, restarted HA and now everything is alright.... sadly no log file... in the next event I try to catch the log file. And then we will see if API gives us wrong information (and after HA restart the correct one?!?) or if there is still a bug somewhere we are not aware currently.

Kolbi commented 4 months ago

At this point I'm thinking it may be an API issue. I have also noticed GPS location doesn't always update for me either, but then other days it does work. The only thing left is to evaluate the raw data in your logs. We currently redact the GPS coordinates for obvious reasons, but i will add a PR for a commented line which will allow the user to remove the comment and display the raw data in the logs. User can then compare the raw GPS data coordinates to their expected vehicle position. If the data provided by Audi is incorrect to where the vehicle is actually positioned, this is an Audi API issue and we won't be able to address it further.

See #407 PR.

Added PR - next version will contain this debug method or update to master via HACS.

synack666 commented 4 months ago

try to catch infos/logs today

coreywillwhat commented 4 months ago

Thank you @synack666 ! Just be sure to follow the instructions in #407 to enable the unredacted data in your logs.

You don't need to provide the data to us, but please verify the GPS coordinates are accurate from the Audi API using Google maps or other map software.

synack666 commented 4 months ago

Screenshot 2024-04-24 125109

ok, here wo go, this try everything was ok, location changed... next try this evening i use this data for position, ist was correct

synack666 commented 4 months ago

I have now looked closely for 2 days, in the app everything is ok, in HA after a restart it also works, so for one day, after that the change of location is no longer accepted, in the GEO data the position remains.

coreywillwhat commented 4 months ago

Hi @synack666 thanks for doing some extensive testing. So the GPS coordinates returned in the logs always remained the same? and you either have active polling set to run frequently enough that it would capture the changes in your coordinates while you are out of the house, or you are running the refresh_cloud_data service call when the vehicle is in a different location?

synack666 commented 4 months ago

what can i say, now it has been running for three days without any problems, current version is installed

i have previously compared the app with ha and checked the geo with maps, long enough somewhere else so that an update should have come, door on or so has also come

Should i close here?

Kolbi commented 3 months ago

Today I had:

POSITION: ClientResponseError with status 502 for VIN: *****. Disabling vehicle position support.

Need to try to fetch debug log later.

synack666 commented 3 months ago

i close here, it works for a couple of days without problems, thnx for support.