audi_connect_ha icon indicating copy to clipboard operation
audi_connect_ha copied to clipboard

device_traker not working

Open alfry82 opened this issue 1 year ago • 4 comments

the device tracker item no longer appears after the update

alfry82 avatar Mar 25 '24 09:03 alfry82

Can you provide logs? It's working for me.

Kolbi avatar Mar 25 '24 14:03 Kolbi

this is what I have on mine:

2024-03-26 15:46:09.310 ERROR (MainThread) [custom_components.audiconnect.audi_connect_account] Unable to update the vehicle position of chasis_number: 'carCapturedTimestamp' Traceback (most recent call last): File "/config/custom_components/audiconnect/audi_connect_account.py", line 492, in update_vehicle_position "timestamp": resp["data"]["carCapturedTimestamp"], ~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^ KeyError: 'carCapturedTimestamp'

Adding the response:

'carCapturedTimestamp': datetime.datetime(2024, 3, 25, 19, 48, 34, tzinfo=datetime.timezone.utc)

xhemp avatar Mar 26 '24 15:03 xhemp

Need to have a deeper look into: https://github.com/audiconnect/audi_connect_ha/blob/f0b48c3059a339220e32ae71e88c47ea2c4c773b/custom_components/audiconnect/audi_connect_account.py#L482

Do you have this issue quite often? Had it once and I guess restarting helped to get it back running. As self.support_position ist set to True again.

Kolbi avatar Mar 28 '24 07:03 Kolbi

Need to have a deeper look into:

https://github.com/audiconnect/audi_connect_ha/blob/f0b48c3059a339220e32ae71e88c47ea2c4c773b/custom_components/audiconnect/audi_connect_account.py#L482

Do you have this issue quite often? Had it once and I guess restarting helped to get it back running. As self.support_position ist set to True again.

It wasn't working for a while (since last update, at least) and today, it just started working out of the blue, go figure...

xhemp avatar Mar 28 '24 18:03 xhemp

@alfry82 still not working on your side?

Kolbi avatar Apr 02 '24 13:04 Kolbi

` Logger: homeassistant.components.device_tracker Source: helpers/entity_platform.py:576 integration: Device Tracker (documentation, issues) First occurred: 08:04:22 (5 occurrences) Last logged: 13:01:31

Error adding entity None for domain device_tracker with platform audiconnect Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 576, in _async_add_entities await coro File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 725, in _async_add_entity device = dev_reg.async_get(self.hass).async_get_or_create( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/helpers/device_registry.py", line 561, in async_get_or_create raise HomeAssistantError( homeassistant.exceptions.HomeAssistantError: Can't link device to unknown config entry 00exx9f5xxab `

I updated to the latest version overnight - I am getting no device tracker now, and this entry in the log.

Great work everyone, I hope this helps.

shuntfield avatar Apr 03 '24 12:04 shuntfield

As the Audi API had some issues yesterday, just to confirm: This issue still remains with latest version?

Kolbi avatar Apr 04 '24 06:04 Kolbi

As the Audi API had some issues yesterday, just to confirm: This issue still remains with latest version?

@Kolbi yes, the problem still exists on my installation, even today after the Audi API problem it still returns the same error on device tracker with the latest version.

shuntfield avatar Apr 04 '24 11:04 shuntfield

I have just reverted back to 1.0.3 and device_tracker works in that version.

shuntfield avatar Apr 04 '24 11:04 shuntfield

Still curious because I'm not aware of any changes regarding device_tracker since 1.0.3 - I'm pretty sure if you now update to 1.1.0 again it will work?

Kolbi avatar Apr 04 '24 12:04 Kolbi

Still curious because I'm not aware of any changes regarding device_tracker since 1.0.3 - I'm pretty sure if you now update to 1.1.0 again it will work?

I have now installed 1.1.0 again from 1.0.3 and it works! Bizzare - OK I'll put that down to experience!

shuntfield avatar Apr 04 '24 12:04 shuntfield

@alfry82 can you provide an update if this is working in recent versions?

coreywillwhat avatar Apr 08 '24 21:04 coreywillwhat

Same here.

Since a couple of days no position is available for my car. Tried rollback/ update as requested. The Audi app shows the correct location information for my car.

Steps I have taken to get the device_tracker object back:

  1. removed the configuration from home-assistant.
  2. restart home-assistant.
  3. removed integration.
  4. restart home-assistant
  5. added integration (version 1.3.1)
  6. restart home-assistant.
  7. added my car.
  8. restart home-assistant

The device-overview reports no device_tracker object at all anymore. All other info is up-to-date and correct.

possm avatar Apr 10 '24 10:04 possm

Same here. Two Audi's, one reports correct location other not. Both show correctly in Audi app.

jacquesvzijp avatar Apr 10 '24 10:04 jacquesvzijp

Any interesting in the logs (debug log)?

Kolbi avatar Apr 10 '24 10:04 Kolbi

Edit:

[removed wait till redacted PR is integrated]

Wait till https://github.com/audiconnect/audi_connect_ha/pull/354 is implemented.

Kolbi avatar Apr 10 '24 11:04 Kolbi

I find uninstalling it or replacing with an earlier version then reinstalling the latest version resolves the problem. For now its working for me. I can try the debug log version if you need more people to try it?

shuntfield avatar Apr 10 '24 12:04 shuntfield

Same here.

Since a couple of days no position is available for my car. Tried rollback/ update as requested. The Audi app shows the correct location information for my car.

Steps I have taken to get the device_tracker object back:

  1. removed the configuration from home-assistant.
  2. restart home-assistant.
  3. removed integration.
  4. restart home-assistant
  5. added integration (version 1.3.1)
  6. restart home-assistant.
  7. added my car.
  8. restart home-assistant

The device-overview reports no device_tracker object at all anymore. All other info is up-to-date and correct.

Overnight, the device_tracker entity for my car showed up again... (version 1.3.1) For me the problem is solved atm

Is Audi messing with us? ;)

possm avatar Apr 11 '24 06:04 possm

2024-04-11 13:58:30.133 ERROR (MainThread) [homeassistant.components.device_tracker] Error adding entity device_tracker.audi_a6_avant_tfsi_e_position for domain device_tracker with platform audiconnect Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 580, in _async_add_entities await coro File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 890, in _async_add_entity await entity.add_to_platform_finish() File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1334, in add_to_platform_finish self.async_write_ha_state() File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 998, in async_write_ha_state self._async_write_ha_state() File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1119, in _async_write_ha_state state, attr, capabilities, shadowed_attr = self.__async_calculate_state() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1056, in __async_calculate_state state = self._stringify_state(available) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1004, in _stringify_state if (state := self.state) is None: ^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/components/device_tracker/config_entry.py", line 259, in state zone_state = zone.async_active_zone( ^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/components/zone/init.py", line 129, in async_active_zone zone_dist := distance( ^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/util/location.py", line 71, in distance result = vincenty((lat1, lon1), (lat2, lon2)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/util/location.py", line 94, in vincenty U1 = math.atan((1 - FLATTENING) * math.tan(math.radians(point1[0]))) ^^^^^^^^^^^^^^^^^^^^^^^ TypeError: must be real number, not str

Kolbi avatar Apr 11 '24 12:04 Kolbi

Please try version >= 1.4.0 and enable debug mode if you encounter the issue and provide us the specific lines from the logfile.

Kolbi avatar Apr 11 '24 12:04 Kolbi

Currently I get:

2024-04-12 14:09:54.323 DEBUG (MainThread) [custom_components.audiconnect.audi_connect_account] Starting update_vehicle_position for VIN: ************* 2024-04-12 14:09:54.323 DEBUG (MainThread) [custom_components.audiconnect.audi_connect_account] Attempting to retrieve stored position for VIN: ************* 2024-04-12 14:09:54.706 DEBUG (MainThread) [custom_components.audiconnect.audi_connect_account] Position currently not available for VIN: *************. Received 204 status.

Kolbi avatar Apr 12 '24 12:04 Kolbi

I am getting errors since the latest release (1.5.2):

2024-04-12 17:19:31.642 DEBUG (MainThread) [custom_components.audiconnect.audi_connect_account] Starting update_vehicle_position for VIN: *************9894 2024-04-12 17:19:31.642 DEBUG (MainThread) [custom_components.audiconnect.audi_connect_account] Attempting to retrieve stored position for VIN: *************9894 2024-04-12 17:19:32.144 ERROR (MainThread) [custom_components.audiconnect.audi_connect_account] An unexpected error occurred while updating vehicle position for VIN: *************9894. Error: 'carCapturedTimestamp'

ghostwind66 avatar Apr 12 '24 15:04 ghostwind66

hmm seems like your car isn't providing the timestamp it was last parked. Is your location still updated in HA regardless of this error?

coreywillwhat avatar Apr 12 '24 17:04 coreywillwhat

hmm seems like your car isn't providing the timestamp it was last parked. Is your location still updated in HA regardless of this error?

Nope. I have not had an update since last night

ghostwind66 avatar Apr 12 '24 19:04 ghostwind66

Apologies, just to clarify, has the car moved location and the updates aren't coming through on the tracker?

Only changes to device tracker are more logging to show exceptions/warnings in PR #354 . Its possible this issue was already occurring, but the error was never logged, so we're only just seeing it now.

API seems to be returning intermittent/mixed responses for the tracker, can you let us know if you continue to see the issue. Others seem to have the tracker coming in and out.

edit: I'll keep thinking about it though. Could be something in the code. I appreciate you reporting!

coreywillwhat avatar Apr 12 '24 19:04 coreywillwhat

Apologies, just to clarify, has the car moved location and the updates aren't coming through on the tracker?

That is correct. Movements do not generate any updates to the position. In HA, the position is just stated as "Unknown"

ghostwind66 avatar Apr 12 '24 20:04 ghostwind66

Thank you for confirming! In a matter of minutes, i had my car turned on and received 204 error:

Position currently not available for VIN: *************. Received 204 status.

I also had no timestamp reported and unknown entity state.

I've submitted a PR #374 to gracefully handle no timestamp or parktime. Its working for me. Hopefully this fixes it.

coreywillwhat avatar Apr 12 '24 21:04 coreywillwhat

Can you please test with latest v1.6.0 if issue still remaining?

Kolbi avatar Apr 16 '24 12:04 Kolbi

Can you please test with latest v1.6.0 if issue still remaining?

Hey, the issue seems to have been resolved with the new update. Thanks for fixing!

ghostwind66 avatar Apr 16 '24 13:04 ghostwind66

closing as the issue seems resolved. Please report any new (or old) issues you see!

coreywillwhat avatar Apr 16 '24 13:04 coreywillwhat