leeyuentuen / polestar_api

Polestar Api - Home Assistant Component
MIT License
112 stars 18 forks source link

API Status shows "Error" - no update until reload #48

Closed Ottmar0815 closed 6 months ago

Ottmar0815 commented 6 months ago

Hello,

after some time the API status shows "Error" and no data update will be done.

If i reload the integration it works fine again.

On the next occurance i will activate debug log and then i will post it here.

Greetings

Ottmar0815 commented 6 months ago

It seems that the SoC was updated although this "error".

Sorry, the entity "Last updated battery data" showed an update from SoC but the entity "Battery level" (and all others) hasn't changed.

leeyuentuen commented 6 months ago

yes i've notice this issue. i'm going to debug this issue and see if i can solve this

Ottmar0815 commented 6 months ago

"Error" hasn't occurred again, but the data isn't updating again.

Ottmar0815 commented 6 months ago

Now the Error occured again.

Log:

=============== Log Begin ===============

2023-12-30 03:00:20.368 DEBUG (MainThread) [custom_components.polestar_api.pypolestar.polestar] {'data': {'getBatteryData': {'averageEnergyConsumptionKwhPer100Km': 26, 'batteryChargeLevelPercentage': 53, 'chargerConnectionStatus': 'CHARGER_CONNECTION_STATUS_CONNECTED', 'chargingCurrentAmps': None, 'chargingPowerWatts': None, 'chargingStatus': 'CHARGING_STATUS_IDLE', 'estimatedChargingTimeMinutesToTargetDistance': None, 'estimatedChargingTimeToFullMinutes': 0, 'estimatedDistanceToEmptyKm': 180, 'estimatedDistanceToEmptyMiles': 110, 'eventUpdatedTimestamp': {'iso': '2023-12-29T20:21:58.000Z', 'unix': '1703881318', 'typename': 'EventUpdatedTimestamp'}, 'typename': 'Battery'}}} 2023-12-30 03:00:34.521 DEBUG (MainThread) [custom_components.polestar_api.pypolestar.polestar] {'data': {'getOdometerData': {'averageSpeedKmPerHour': 50, 'eventUpdatedTimestamp': {'iso': '2023-12-28T14:08:28.000Z', 'unix': '1703772508', 'typename': 'EventUpdatedTimestamp'}, 'odometerMeters': 43860500, 'tripMeterAutomaticKm': 0.5, 'tripMeterManualKm': 104.8, 'typename': 'Odometer'}}} 2023-12-30 03:00:39.532 ERROR (MainThread) [homeassistant.helpers.entity] Update for sensor.polestar_2_estimate_distance_to_empty_miles fails Traceback (most recent call last): File "/usr/local/lib/python3.11/site-packages/anyio/streams/tls.py", line 133, in _call_sslobject_method result = func(*args) ^^^^^^^^^^^ File "/usr/local/lib/python3.11/ssl.py", line 921, in read v = self._sslobj.read(len) ^^^^^^^^^^^^^^^^^^^^^^ ssl.SSLWantReadError: The operation did not complete (read) (_ssl.c:2580)

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/usr/local/lib/python3.11/site-packages/anyio/_core/_tasks.py", line 115, in fail_after yield cancel_scope File "/usr/local/lib/python3.11/site-packages/httpcore/_backends/anyio.py", line 34, in read return await self._stream.receive(max_bytes=max_bytes) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/anyio/streams/tls.py", line 198, in receive data = await self._call_sslobject_method(self._ssl_object.read, max_bytes) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/anyio/streams/tls.py", line 140, in _call_sslobject_method data = await self.transport_stream.receive() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/anyio/_backends/_asyncio.py", line 1103, in receive await self._protocol.read_event.wait() File "/usr/local/lib/python3.11/asyncio/locks.py", line 213, in wait await fut asyncio.exceptions.CancelledError: Cancelled by cancel scope 7f87f1bf10

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/usr/local/lib/python3.11/site-packages/httpcore/_exceptions.py", line 10, in map_exceptions yield File "/usr/local/lib/python3.11/site-packages/httpcore/_backends/anyio.py", line 32, in read with anyio.fail_after(timeout): File "/usr/local/lib/python3.11/contextlib.py", line 155, in exit self.gen.throw(typ, value, traceback) File "/usr/local/lib/python3.11/site-packages/anyio/_core/_tasks.py", line 118, in fail_after raise TimeoutError TimeoutError

The above exception was the direct cause of the following exception:

Traceback (most recent call last): File "/usr/local/lib/python3.11/site-packages/httpx/_transports/default.py", line 66, in map_httpcore_exceptions yield File "/usr/local/lib/python3.11/site-packages/httpx/_transports/default.py", line 366, in handle_async_request resp = await self._pool.handle_async_request(req) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/httpcore/_async/connection_pool.py", line 262, in handle_async_request raise exc File "/usr/local/lib/python3.11/site-packages/httpcore/_async/connection_pool.py", line 245, in handle_async_request response = await connection.handle_async_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/httpcore/_async/connection.py", line 103, in handle_async_request return await self._connection.handle_async_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/httpcore/_async/http11.py", line 133, in handle_async_request raise exc File "/usr/local/lib/python3.11/site-packages/httpcore/_async/http11.py", line 111, in handle_async_request ) = await self._receive_response_headers(**kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/httpcore/_async/http11.py", line 176, in _receive_response_headers event = await self._receive_event(timeout=timeout) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/httpcore/_async/http11.py", line 212, in _receive_event data = await self._network_stream.read( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/httpcore/_backends/anyio.py", line 31, in read with map_exceptions(exc_map): File "/usr/local/lib/python3.11/contextlib.py", line 155, in exit self.gen.throw(typ, value, traceback) File "/usr/local/lib/python3.11/site-packages/httpcore/_exceptions.py", line 14, in map_exceptions raise to_exc(exc) from exc httpcore.ReadTimeout

The above exception was the direct cause of the following exception:

Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 698, in async_update_ha_state await self.async_device_update() File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 959, in async_device_update await self.async_update() File "/config/custom_components/polestar_api/sensor.py", line 530, in async_update await self._device.async_update() File "/config/custom_components/polestar_api/polestar.py", line 50, in async_update await self.polestarApi.get_ev_data(self.vin) File "/config/custom_components/polestar_api/pypolestar/polestar.py", line 131, in get_ev_data await call_api(lambda: self._get_battery_data(vin)) File "/config/custom_components/polestar_api/pypolestar/polestar.py", line 122, in call_api await func() File "/config/custom_components/polestar_api/pypolestar/polestar.py", line 79, in _get_battery_data result = await self.get_graph_ql(params) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/polestar_api/pypolestar/polestar.py", line 154, in get_graph_ql result = await self._client_session.get(url, params=params, headers=headers) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/httpx/_client.py", line 1757, in get return await self.request( ^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/httpx/_client.py", line 1530, in request return await self.send(request, auth=auth, follow_redirects=follow_redirects) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/httpx/_client.py", line 1617, in send response = await self._send_handling_auth( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/httpx/_client.py", line 1645, in _send_handling_auth response = await self._send_handling_redirects( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/httpx/_client.py", line 1682, in _send_handling_redirects response = await self._send_single_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/httpx/_client.py", line 1719, in _send_single_request response = await transport.handle_async_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/httpx/_transports/default.py", line 365, in handle_async_request with map_httpcore_exceptions(): File "/usr/local/lib/python3.11/contextlib.py", line 155, in exit self.gen.throw(typ, value, traceback) File "/usr/local/lib/python3.11/site-packages/httpx/_transports/default.py", line 83, in map_httpcore_exceptions raise mapped_exc(message) from exc httpx.ReadTimeout ....

2023-12-31 12:38:47.088 WARNING (MainThread) [custom_components.polestar_api.pypolestar.polestar] Auth Exception: Error getting resume path

============== Log End ============

leeyuentuen commented 6 months ago

let's take look at the new beta if this solved the auth issue here: https://github.com/leeyuentuen/polestar_api/releases/tag/1.2.7

leeyuentuen commented 6 months ago

@Ottmar0815 ☝️

Ottmar0815 commented 6 months ago

Tested the beta. With API-Status "OK" all entities switched to "unknown" 11 hours ago. Reloaded the integration, now it works fine again.

leeyuentuen commented 6 months ago

Tested the beta. With API-Status "OK" all entities switched to "unknown" 11 hours ago. Reloaded the integration, now it works fine again.

in the log still the same error?

Ottmar0815 commented 6 months ago

in the log still the same error?

No, this time only this info was in the logs:

2024-01-01 21:27:44.467 WARNING (MainThread) [custom_components.polestar_api.polestar] Read Timeout on update data

leeyuentuen commented 6 months ago

@Ottmar0815 seems same issue like here: https://github.com/leeyuentuen/polestar_api/issues/43#issuecomment-1873823097

maybe try use override the DNS record with that other IP and see if that still happend

leeyuentuen commented 6 months ago

to get a better overview:

duplicated issue. continue in this issue: https://github.com/leeyuentuen/polestar_api/issues/43