audiconnect / audi_connect_ha

Adds an audi connect integration to home assistant
MIT License
238 stars 97 forks source link

Data in the cloud does not update after lock/unlock actions #357

Closed tieskuh closed 6 months ago

tieskuh commented 6 months ago

After locking or unlocking the car, the new status doesn't reflect until the next update. It would be a nice feature to initiate a refresh after locking or unlocking the car. Thanks for all your effort!

coreywillwhat commented 6 months ago

Hi @tieskuh, thanks for reporting!

refresh_cloud_data currently is run 30 seconds after a successful/failed vehicle action command. We will likely reduce this lag time based on testing i've done.

That said, if you're not seeing that, can you provide logs after running the lock/unlock command and waiting 1 to 2 mins to be sure the cloud update is logged, or failure is shown?

My logs show successful cloud update after lock/unlock.

tieskuh commented 6 months ago

Hi @coreywillwhat

Thanks for your response.

There is indeed an error in my debug log. I'm using version 1.3.1

2024-04-12 00:15:59.328 DEBUG (MainThread) [custom_components.audiconnect.audi_connect_account] Sending command to unlock to vehicle wauzzzge0xxxxxxxx
2024-04-12 00:16:30.468 DEBUG (MainThread) [custom_components.audiconnect.audi_connect_account] Successfully unlocked vehicle wauzzzge0xxxxxxxx
2024-04-12 00:16:30.468 DEBUG (MainThread) [custom_components.audiconnect.audi_connect_account] Sending command to refresh data to vehicle wauzzzge0xxxxxxxx
2024-04-12 00:16:30.538 ERROR (MainThread) [custom_components.audiconnect.util] Unable to refresh vehicle data of wauzzzge0xxxxxxxx: 403, message='', url=URL('https://fal-3a.prd.eu.dp.vwg-connect.com/fs-car/bs/vsr/v1/Audi/DE/vehicles/WAUZZZGE0xxxxxxxx/requests')
2024-04-12 00:16:30.539 ERROR (MainThread) [custom_components.audiconnect.audi_account] Error refreshing vehicle data wauzzzge0xxxxxxxx
NoneType: None
2024-04-12 00:16:30.540 INFO (MainThread) [custom_components.audiconnect.audi_account] Trying cloud update in 30 seconds...
coreywillwhat commented 6 months ago

refresh_vehicle_data is known to not work (See #330), but the vehicle should still "check-in" to the cloud on its own. Did you see if the cloud update succeeded after the 30 seconds? There should have been logs for that as well.

FYI the delay for the cloud update will be reduced to 5 seconds in the next version.

tieskuh commented 6 months ago

Ah, I see. Here is some more logging. It does try it after 30 seconds indeed but it still reports as unlocked in the update. So not much we can do I guess...

2024-04-12 00:30:44.984 INFO (MainThread) [custom_components.audiconnect.audi_account] Successfully updated Audi Connect service
2024-04-12 00:30:45.899 DEBUG (MainThread) [custom_components.audiconnect.audi_connect_account] Sending command to lock to vehicle wauzzzge0xxxxxxxx
2024-04-12 00:30:56.788 DEBUG (MainThread) [custom_components.audiconnect.audi_connect_account] Successfully locked vehicle wauzzzge0xxxxxxxx
2024-04-12 00:30:56.788 DEBUG (MainThread) [custom_components.audiconnect.audi_connect_account] Sending command to refresh data to vehicle wauzzzge0xxxxxxxx
2024-04-12 00:30:56.854 ERROR (MainThread) [custom_components.audiconnect.util] Unable to refresh vehicle data of wauzzzge0xxxxxxxx: 403, message='', url=URL('https://fal-3a.prd.eu.dp.vwg-connect.com/fs-car/bs/vsr/v1/Audi/DE/vehicles/WAUZZZGE0xxxxxxxx/requests')
2024-04-12 00:30:56.854 ERROR (MainThread) [custom_components.audiconnect.audi_account] Error refreshing vehicle data wauzzzge0xxxxxxxx
NoneType: None
2024-04-12 00:30:56.854 INFO (MainThread) [custom_components.audiconnect.audi_account] Trying cloud update in 30 seconds...
2024-04-12 00:31:26.856 INFO (MainThread) [custom_components.audiconnect.audi_account] Trying cloud update now...
2024-04-12 00:31:26.856 INFO (MainThread) [custom_components.audiconnect.audi_account] Running update for Audi Connect service at 2024-04-11 22:31:26.856341+00:00
2024-04-12 00:31:27.286 DEBUG (MainThread) [custom_components.audiconnect.audi_services] audiconnect - Car Data: {'access': {'accessStatus': {'value': {'overallStatus': 'unsafe', 'carCapturedTimestamp': datetime.datetime(2024, 4, 11, 22, 30, 11, tzinfo=datetime.timezone.utc), 'doors': [{'name': 'bonnet', 'status': ['closed']}, {'name': 'frontLeft', 'status': ['unlocked', 'closed']}, {'name': 'frontRight', 'status': ['unlocked', 'closed']}, {'name': 'rearLeft', 'status': ['unlocked', 'closed']}, {'name': 'rearRight', 'status': ['unlocked', 'closed']}, {'name': 'trunk', 'status': ['unlocked', 'closed']}], 'windows': [{'name': 'frontLeft', 'status': ['closed']}, {'name': 'frontRight', 'status': ['closed']}, {'name': 'rearLeft', 'status': ['closed']}, {'name': 'rearRight', 'status': ['closed']}, {'name': 'roofCover', 'status': ['unsupported']}, {'name': 'sunRoof', 'status': ['unsupported']}], 'doorLockStatus': 'unlocked'}}}, 'charging': {'batteryStatus': {'value': {'carCapturedTimestamp': datetime.datetime(2024, 4, 11, 22, 29, 58, tzinfo=datetime.timezone.utc)
coreywillwhat commented 6 months ago

What vehicle model? You said its successful on the actual vehicle? i.e when you send unlock or lock the vehicle actually locks/unlocks? Trying to determine if the 'success' message is accurate or not.

coreywillwhat commented 6 months ago

have you tried any other commands? Do they reflect accurately after the update, such as start_climate_control?

tieskuh commented 6 months ago

I have an e-tron 55. It does indeed lock and unlock correctly all the time. I did some more testing and installed version 1.5.0. Sometimes it does work, sometimes it doesn't. It feels a bit random. It locks and unlocks correctly all the time but sometimes the update returns the old value. So I lock the car but the update returns an unlocked state. But like I said, not all the time. It works like half of the time.

tieskuh commented 6 months ago

have you tried any other commands? Do they reflect accurately after the update, such as start_climate_control?

I'll try that tomorrow!

coreywillwhat commented 6 months ago

Yeah let me know. The Q4 and the e-tron seem to have some differences than the rest of the vehicles. I expect this will continue with more e-tron class vehicles being released so its something to keep chipping away at. This seems like an instance where the vehicle isn't checking in with the cloud...which is strange. I'm wondering if the delay is different.

You could play with the UPDATE_SLEEP variable in the const.py. This will change the delay (in seconds) between a vehicle action success message and the cloud update. It's a fairly benign constant, so you could play with extending the delay and see what works.

If you aren't into that, no worries, like I said, we'll keep working at these things.

tieskuh commented 6 months ago

It tried changing that, but it doesn't seem to help delaying the update. After the next update the state is correct so it seems it takes a few minutes or a second update. And 50% of the time it does work immediatly. So I guess this will be a hard issue to debug and it seems to be a problem on Audi's side. Feel free to close the issue.

coreywillwhat commented 6 months ago

Its odd the vehicle isn't reporting its updates to the cloud soon after, but I agree, this does seem like an Audi Issue. I have this on a list already to add the update_sleep constant as a user option from the front end so you could play with it more easily from the front end, just not sure yet when I'll get around to implementing.

Thanks for reporting back on this. Closing for now, but report back if you have any developments from your end.