pypolestar / polestar_api

Polestar API - Home Assistant Component
MIT License
154 stars 28 forks source link

Unexpected error when creating the API -Polestar Account in the web works #190

Open alexeckh opened 3 weeks ago

alexeckh commented 3 weeks ago

Hi,

i had prior installed the integration. After deletion i would install it again. i got the following error: "Unexpected error when creating the API." Polestar Account in the web works and shows my car in the web.

Protocol:

Logger: custom_components.polestar_api.config_flow Quelle: custom_components/polestar_api/config_flow.py:39 Integration: polestar_api (Dokumentation, Probleme) Erstmals aufgetreten: 16:55:06 (1 Vorkommnisse) Zuletzt protokolliert: 16:55:06

Unexpected error creating device Traceback (most recent call last): File "/config/custom_components/polestar_api/config_flow.py", line 39, in _create_device await device.init() File "/config/custom_components/polestar_api/polestar.py", line 34, in init await self.polestarApi.init() File "/config/custom_components/polestar_api/pypolestar/polestar.py", line 54, in init carData = await self._get_vehicle_data() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/polestar_api/pypolestar/polestar.py", line 144, in _get_vehicle_data result = await self.get_graph_ql(params) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/polestar_api/pypolestar/polestar.py", line 242, in get_graph_ql raise PolestarNotAuthorizedException("Unauthorized Exception") custom_components.polestar_api.pypolestar.exception.PolestarNotAuthorizedException: Unauthorized Exception

jschlyter commented 3 weeks ago

Did you change password for your account?

alexeckh commented 3 weeks ago

No

Am 1. November 2024 09:18:39 MEZ schrieb Jakob Schlyter @.***>:

Did you change password for your account?

-- Reply to this email directly or view it on GitHub: https://github.com/pypolestar/polestar_api/issues/190#issuecomment-2451491644 You are receiving this because you authored the thread.

Message ID: @.***>

alexeckh commented 3 weeks ago

Tried 1.6.15: it works, 1.8.x prerelease not

alexeckh commented 2 weeks ago

Now both versions didn’t work. When I install 1.6.15 I get the message ‚Kein Token in der Antwort gefunden. Bitte überprüfe Deine Anmeldeinformationen.‘ At 1.8.0 ‚API unexpected failure‘

jschlyter commented 2 weeks ago

Please retest with https://github.com/pypolestar/polestar_api/releases/tag/1.9.0

alexeckh commented 2 weeks ago

issue persists error message: 'API unexpected failure'

jschlyter commented 2 weeks ago

Are there anything else in the logs from Home Assistant?

alexeckh commented 2 weeks ago

Dieser Fehler wurde von einer benutzerdefinierten Integration verursacht

Logger: custom_components.polestar_api.config_flow Quelle: custom_components/polestar_api/config_flow.py:47 Integration: polestar_api (Dokumentation, Probleme) Erstmals aufgetreten: 15:09:23 (2 Vorkommnisse) Zuletzt protokolliert: 15:10:02

Unexpected error creating device Traceback (most recent call last): File "/config/custom_components/polestar_api/pypolestar/polestar.py", line 235, in _query_graph_ql result = await client.execute( ^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/gql/client.py", line 1639, in execute raise TransportQueryError( gql.transport.exceptions.TransportQueryError: {'message': 'User not authenticated', 'path': ['getConsumerCarsV2'], 'extensions': {'code': 'UNAUTHENTICATED', 'exception': {'stacktrace': ['AuthenticationError: User not authenticated', ' at ayn (/var/task/src/functions/mystar/handler.js:1568:2188838)', ' at uyn (/var/task/src/functions/mystar/handler.js:1568:2190110)', ' at Cr (/var/task/src/functions/mystar/handler.js:1568:2212332)', ' at getConsumerCarsV2 (/var/task/src/functions/mystar/handler.js:1568:2214029)', ' at TFr.r.resolve (/var/task/src/functions/mystar/handler.js:287:6609)', ' at CBe (/var/task/src/functions/mystar/handler.js:83:5200)', ' at kG (/var/task/src/functions/mystar/handler.js:83:4784)', ' at yEr (/var/task/src/functions/mystar/handler.js:83:4308)', ' at IBe (/var/task/src/functions/mystar/handler.js:83:2354)', ' at g (/var/task/src/functions/mystar/handler.js:287:40983)', ' at RUr (/var/task/src/functions/mystar/handler.js:287:40154)', ' at process.processTicksAndRejections (node:internal/process/task_queues:95:5)', ' at async TQe (/var/task/src/functions/mystar/handler.js:288:2270)'], 'message': 'User not authenticated', 'locations': [{'line': 1, 'column': 36}], 'path': ['getConsumerCarsV2']}, 'serviceName': 'mystar'}}

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

Traceback (most recent call last): File "/config/custom_components/polestar_api/config_flow.py", line 47, in _create_device await device.async_init() File "/config/custom_components/polestar_api/polestar.py", line 150, in async_init await self.polestar_api.async_init() File "/config/custom_components/polestar_api/pypolestar/polestar.py", line 69, in async_init if not (car_data := await self._get_vehicle_data(verbose=verbose)): ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/polestar_api/pypolestar/polestar.py", line 204, in _get_vehicle_data result = await self._query_graph_ql( ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/polestar_api/pypolestar/polestar.py", line 251, in _query_graph_ql raise PolestarNotAuthorizedException( custom_components.polestar_api.pypolestar.exception.PolestarNotAuthorizedException: User not authenticated

alexeckh commented 2 weeks ago

DNS [INFO] 127.0.0.1:51114 - 30119 "AAAA IN pc-api.polestar.com. udp 48 true 2048" - - 0 30.000239631s [ERROR] plugin/errors: 2 pc-api.polestar.com. AAAA: dial tcp 1.1.1.1:853: i/o timeout [INFO] 127.0.0.1:40860 - 10368 "A IN pc-api.polestar.com. udp 48 true 2048" - - 0 30.000278989s [ERROR] plugin/errors: 2 pc-api.polestar.com. A: dial tcp 1.1.1.1:853: i/o timeout [INFO] 127.0.0.1:35519 - 56463 "AAAA IN pc-api.polestar.com. udp 48 true 2048" - - 0 30.00100264s [ERROR] plugin/errors: 2 pc-api.polestar.com. AAAA: dial tcp 1.1.1.1:853: i/o timeout [INFO] 127.0.0.1:34751 - 10771 "A IN pc-api.polestar.com. udp 48 true 2048" - - 0 30.001007593s [ERROR] plugin/errors: 2 pc-api.polestar.com. A: dial tcp 1.1.1.1:853: i/o timeout [INFO] 127.0.0.1:57561 - 51810 "AAAA IN pc-api.polestar.com. udp 48 true 2048" - - 0 30.000898013s [ERROR] plugin/errors: 2 pc-api.polestar.com. AAAA: dial tcp 1.1.1.1:853: i/o timeout [INFO] 127.0.0.1:52240 - 18659 "A IN pc-api.polestar.com. udp 48 true 2048" - - 0 30.000841767s [ERROR] plugin/errors: 2 pc-api.polestar.com. A: dial tcp 1.1.1.1:853: i/o timeout [INFO] 127.0.0.1:48196 - 59660 "A IN pc-api.polestar.com. udp 48 true 2048" - - 0 30.000760944s [ERROR] plugin/errors: 2 pc-api.polestar.com. A: dial tcp 1.0.0.1:853: i/o timeout [INFO] 127.0.0.1:43767 - 63814 "AAAA IN pc-api.polestar.com. udp 48 true 2048" - - 0 30.00085577s [ERROR] plugin/errors: 2 pc-api.polestar.com. AAAA: dial tcp 1.0.0.1:853: i/o timeout [INFO] 127.0.0.1:59963 - 25644 "AAAA IN pc-api.polestar.com. udp 48 true 2048" - - 0 30.000937339s [ERROR] plugin/errors: 2 pc-api.polestar.com. AAAA: dial tcp 1.0.0.1:853: i/o timeout [INFO] 127.0.0.1:36422 - 797 "A IN pc-api.polestar.com. udp 48 true 2048" - - 0 30.001029576s [ERROR] plugin/errors: 2 pc-api.polestar.com. A: dial tcp 1.0.0.1:853: i/o timeout [INFO] 127.0.0.1:42710 - 30848 "AAAA IN pc-api.polestar.com. udp 48 true 2048" - - 0 30.001181723s [ERROR] plugin/errors: 2 pc-api.polestar.com. AAAA: dial tcp 1.0.0.1:853: i/o timeout [INFO] 127.0.0.1:39317 - 58075 "A IN pc-api.polestar.com. udp 48 true 2048" - - 0 30.001179835s [ERROR] plugin/errors: 2 pc-api.polestar.com. A: dial tcp 1.0.0.1:853: i/o timeout

jschlyter commented 2 weeks ago

Have you removed your car from the integration and created a new one?

alexeckh commented 2 weeks ago

i have deleted the 'old' integration, then restart and after that try to install the new one. That fails, so that actual there is no integration in the HA UI

wouterhardeman commented 2 weeks ago

@jschlyter I think this is due to an update to the API done today. getConsumerCarsV2 is now under the mystar-v2 endpoint and not in the my-star endpoint anymore.

image

jschlyter commented 2 weeks ago

I get correct responses for getConsumerCarsV2 from both APIv1 and APIv2, so there's no harm moving to v2 only

ZChenzy commented 1 week ago

Hey man can you cut a release please? I would love to use this integration and am being blocked by the same login failure thank you :)

jschlyter commented 1 week ago

Will make a release as soon as #236 and #241 is reviewed and merged, should be today or tomorrow.

jschlyter commented 1 week ago

I've also made a pre-release available as https://github.com/pypolestar/polestar_api/releases/tag/1.10.0b1

alexeckh commented 1 week ago

@jschlyter : thanks for your support and work on that. Pre-release 1.10.0b1 didn‘t work for me. Same error message.

jschlyter commented 1 week ago

With the pre-release version you can download diagnostics for the integration and, if you like, share with me via email and I'll take a look.

alexeckh commented 1 week ago

Sure, will do. How does it works when the integration can’t be installed? Pls advise

jschlyter commented 1 week ago

If a new device can't be created, enable debug logs and send me the logs.

alexeckh commented 1 week ago

ok have sent you a mail. Thanks!