alandtse / tesla

Tesla custom integration for Home Assistant. This requires a refresh token be generated by third-party apps to login.
Apache License 2.0
601 stars 99 forks source link

Failed to setup: could not authenticate #1053

Open usuryadevara opened 1 month ago

usuryadevara commented 1 month ago

Is there an existing issue for this?

I have read about the Fleet API and understand I may need to use it

Version of the Tesla component

3.24.1

Version of the Tesla car software

2024.32.7

Model

Model y 2021 LR

Current Behavior

I followed the instructions https://github.com/alandtse/tesla/wiki/Proxy-setup-with-DuckDNS-and-NGinx multiple times and have same issue

Expected Behavior

I should be able to see and control the tesla.

Debug logs

2024-10-14 12:31:21.564 WARNING (SyncWorker_0) [homeassistant.loader] We found a custom integration hacs which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant
2024-10-14 12:31:21.566 WARNING (SyncWorker_0) [homeassistant.loader] We found a custom integration average which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant
2024-10-14 12:31:21.566 WARNING (SyncWorker_0) [homeassistant.loader] We found a custom integration tesla_custom which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant
2024-10-14 12:31:28.790 ERROR (MainThread) [homeassistant.components.automation] Automation with alias 'EV_Battery_below' failed to setup conditions and has been disabled: Unknown device '322d00bd1327c12f2a7be379c7ce50d2'
2024-10-14 12:31:28.818 ERROR (MainThread) [homeassistant.components.automation] Automation with alias 'Tesla_ENvoy_automation_modified' failed to setup conditions and has been disabled: Unknown device '322d00bd1327c12f2a7be379c7ce50d2'
2024-10-14 12:31:28.835 ERROR (MainThread) [homeassistant.components.automation] Automation with alias 'Demo_run_envoy_TSLA' failed to setup conditions and has been disabled: Unknown device '322d00bd1327c12f2a7be379c7ce50d2'
2024-10-14 12:31:29.741 WARNING (MainThread) [homeassistant.util.loop] Detected blocking call to load_default_certs with args (<ssl.SSLContext object at 0x7fa09984f9d0>, <Purpose.SERVER_AUTH: _ASN1Object(nid=129, shortname='serverAuth', longname='TLS Web Server Authentication', oid='1.3.6.1.5.5.7.3.1')>) inside the event loop by custom integration 'tesla_custom' at custom_components/tesla_custom/__init__.py, line 174: controller = TeslaAPI( (offender: /usr/local/lib/python3.12/ssl.py, line 713: context.load_default_certs(purpose)), please create a bug report at https://github.com/alandtse/tesla/issues
For developers, please see https://developers.home-assistant.io/docs/asyncio_blocking_operations/#load_default_certs
Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "/usr/src/homeassistant/homeassistant/__main__.py", line 223, in <module>
    sys.exit(main())
  File "/usr/src/homeassistant/homeassistant/__main__.py", line 209, in main
    exit_code = runner.run(runtime_conf)
  File "/usr/src/homeassistant/homeassistant/runner.py", line 189, in run
    return loop.run_until_complete(setup_and_run_hass(runtime_config))
  File "/usr/local/lib/python3.12/asyncio/base_events.py", line 674, in run_until_complete
    self.run_forever()
  File "/usr/local/lib/python3.12/asyncio/base_events.py", line 641, in run_forever
    self._run_once()
  File "/usr/local/lib/python3.12/asyncio/base_events.py", line 1990, in _run_once
    handle._run()
  File "/usr/local/lib/python3.12/asyncio/events.py", line 88, in _run
    self._context.run(self._callback, *self._args)
  File "/usr/src/homeassistant/homeassistant/setup.py", line 165, in async_setup_component
    result = await _async_setup_component(hass, domain, config)
  File "/usr/src/homeassistant/homeassistant/setup.py", line 461, in _async_setup_component
    await asyncio.gather(
  File "/usr/src/homeassistant/homeassistant/setup.py", line 463, in <genexpr>
    create_eager_task(
  File "/usr/src/homeassistant/homeassistant/util/async_.py", line 45, in create_eager_task
    return Task(coro, loop=loop, name=name, eager_start=True)
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 742, in async_setup_locked
    await self.async_setup(hass, integration=integration)
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 594, in async_setup
    result = await component.async_setup_entry(hass, self)
  File "/config/custom_components/tesla_custom/__init__.py", line 174, in async_setup_entry
    controller = TeslaAPI(

2024-10-14 12:31:45.107 WARNING (MainThread) [homeassistant.config_entries] Config entry '[email]@hotmail.com' for tesla_custom integration could not authenticate
2024-10-14 12:31:45.322 WARNING (MainThread) [custom_components.hacs] You have 'alexarch21/history-explorer-card' installed with HACS this repository has been removed from HACS, please consider removing it. Removal reason (Repository is archived)
2024-10-14 12:31:50.736 WARNING (MainThread) [homeassistant.util.loop] Detected blocking call to load_verify_locations with args (<ssl.SSLContext object at 0x7fa095c0b5d0>,) inside the event loop by custom integration 'tesla_custom' at custom_components/tesla_custom/config_flow.py, line 155: req = httpx.get( (offender: /usr/local/lib/python3.12/site-packages/httpx/_config.py, line 149: context.load_verify_locations(cafile=cafile)), please create a bug report at https://github.com/alandtse/tesla/issues
For developers, please see https://developers.home-assistant.io/docs/asyncio_blocking_operations/#load_verify_locations
Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "/usr/src/homeassistant/homeassistant/__main__.py", line 223, in <module>
    sys.exit(main())
  File "/usr/src/homeassistant/homeassistant/__main__.py", line 209, in main
    exit_code = runner.run(runtime_conf)
  File "/usr/src/homeassistant/homeassistant/runner.py", line 189, in run
    return loop.run_until_complete(setup_and_run_hass(runtime_config))
  File "/usr/local/lib/python3.12/asyncio/base_events.py", line 674, in run_until_complete
    self.run_forever()
  File "/usr/local/lib/python3.12/asyncio/base_events.py", line 641, in run_forever
    self._run_once()
  File "/usr/local/lib/python3.12/asyncio/base_events.py", line 1990, in _run_once
    handle._run()
  File "/usr/local/lib/python3.12/asyncio/events.py", line 88, in _run
    self._context.run(self._callback, *self._args)
  File "/usr/local/lib/python3.12/site-packages/aiohttp/web_protocol.py", line 556, in start
    task = asyncio.Task(coro, loop=loop, eager_start=True)
  File "/usr/local/lib/python3.12/site-packages/aiohttp/web_protocol.py", line 477, in _handle_request
    resp = await request_handler(request)
  File "/usr/local/lib/python3.12/site-packages/aiohttp/web_app.py", line 559, in _handle
    return await handler(request)
  File "/usr/local/lib/python3.12/site-packages/aiohttp/web_middlewares.py", line 117, in impl
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/security_filter.py", line 92, in security_filter_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/forwarded.py", line 83, in forwarded_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/request_context.py", line 26, in request_context_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/ban.py", line 85, in ban_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/auth.py", line 242, in auth_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/headers.py", line 32, in headers_middleware
    response = await handler(request)
  File "/usr/src/homeassistant/homeassistant/helpers/http.py", line 73, in handle
    result = await handler(request, **request.match_info)
  File "/usr/src/homeassistant/homeassistant/components/http/decorators.py", line 81, in with_admin
    return await func(self, request, *args, **kwargs)
  File "/usr/src/homeassistant/homeassistant/components/config/config_entries.py", line 222, in post
    return await super().post(request, flow_id)
  File "/usr/src/homeassistant/homeassistant/components/http/data_validator.py", line 74, in wrapper
    return await method(view, request, data, *args, **kwargs)
  File "/usr/src/homeassistant/homeassistant/helpers/data_entry_flow.py", line 122, in post
    result = await self._flow_mgr.async_configure(flow_id, data)
  File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 370, in async_configure
    result = await self._async_configure(flow_id, user_input)
  File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 417, in _async_configure
    result = await self._async_handle_step(
  File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 520, in _async_handle_step
    result: _FlowResultT = await getattr(flow, method)(user_input)
  File "/config/custom_components/tesla_custom/config_flow.py", line 84, in async_step_user
    return await self.async_step_credentials()
  File "/config/custom_components/tesla_custom/config_flow.py", line 118, in async_step_credentials
    data_schema=self._async_schema(api_proxy_enable=self.use_proxy),
  File "/config/custom_components/tesla_custom/config_flow.py", line 155, in _async_schema
    req = httpx.get(

2024-10-14 12:34:14.006 ERROR (MainThread) [firebase_messaging.fcmpushclient] Unexpected exception during read
Traceback (most recent call last):
  File "/usr/local/lib/python3.12/site-packages/firebase_messaging/fcmpushclient.py", line 661, in _listen
    elif msg := await self._receive_msg():
                ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/firebase_messaging/fcmpushclient.py", line 280, in _receive_msg
    r = await self.reader.readexactly(1)  # type: ignore[union-attr]
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/asyncio/streams.py", line 752, in readexactly
    await self._wait_for_data('readexactly')
  File "/usr/local/lib/python3.12/asyncio/streams.py", line 545, in _wait_for_data
    await self._waiter
  File "/usr/local/lib/python3.12/asyncio/selector_events.py", line 978, in _read_ready__get_buffer
    nbytes = self._sock.recv_into(buf)
             ^^^^^^^^^^^^^^^^^^^^^^^^^
ConnectionResetError: [Errno 104] Connection reset by peer
2024-10-14 12:35:33.974 WARNING (MainThread) [homeassistant.util.loop] Detected blocking call to load_verify_locations with args (<ssl.SSLContext object at 0x7fa09472d5d0>, '/share/tesla/selfsigned.pem') inside the event loop by custom integration 'tesla_custom' at custom_components/tesla_custom/config_flow.py, line 260: controller = TeslaAPI( (offender: /usr/local/lib/python3.12/site-packages/teslajsonpy/controller.py, line 140: ssl_context.load_verify_locations(api_proxy_cert)), please create a bug report at https://github.com/alandtse/tesla/issues
For developers, please see https://developers.home-assistant.io/docs/asyncio_blocking_operations/#load_verify_locations
Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "/usr/src/homeassistant/homeassistant/__main__.py", line 223, in <module>
    sys.exit(main())
  File "/usr/src/homeassistant/homeassistant/__main__.py", line 209, in main
    exit_code = runner.run(runtime_conf)
  File "/usr/src/homeassistant/homeassistant/runner.py", line 189, in run
    return loop.run_until_complete(setup_and_run_hass(runtime_config))
  File "/usr/local/lib/python3.12/asyncio/base_events.py", line 674, in run_until_complete
    self.run_forever()
  File "/usr/local/lib/python3.12/asyncio/base_events.py", line 641, in run_forever
    self._run_once()
  File "/usr/local/lib/python3.12/asyncio/base_events.py", line 1990, in _run_once
    handle._run()
  File "/usr/local/lib/python3.12/asyncio/events.py", line 88, in _run
    self._context.run(self._callback, *self._args)
  File "/usr/local/lib/python3.12/site-packages/aiohttp/web_protocol.py", line 556, in start
    task = asyncio.Task(coro, loop=loop, eager_start=True)
  File "/usr/local/lib/python3.12/site-packages/aiohttp/web_protocol.py", line 477, in _handle_request
    resp = await request_handler(request)
  File "/usr/local/lib/python3.12/site-packages/aiohttp/web_app.py", line 559, in _handle
    return await handler(request)
  File "/usr/local/lib/python3.12/site-packages/aiohttp/web_middlewares.py", line 117, in impl
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/security_filter.py", line 92, in security_filter_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/forwarded.py", line 210, in forwarded_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/request_context.py", line 26, in request_context_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/ban.py", line 85, in ban_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/auth.py", line 242, in auth_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/headers.py", line 32, in headers_middleware
    response = await handler(request)
  File "/usr/src/homeassistant/homeassistant/helpers/http.py", line 73, in handle
    result = await handler(request, **request.match_info)
  File "/usr/src/homeassistant/homeassistant/components/http/decorators.py", line 81, in with_admin
    return await func(self, request, *args, **kwargs)
  File "/usr/src/homeassistant/homeassistant/components/config/config_entries.py", line 222, in post
    return await super().post(request, flow_id)
  File "/usr/src/homeassistant/homeassistant/components/http/data_validator.py", line 74, in wrapper
    return await method(view, request, data, *args, **kwargs)
  File "/usr/src/homeassistant/homeassistant/helpers/data_entry_flow.py", line 122, in post
    result = await self._flow_mgr.async_configure(flow_id, data)
  File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 370, in async_configure
    result = await self._async_configure(flow_id, user_input)
  File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 417, in _async_configure
    result = await self._async_handle_step(
  File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 520, in _async_handle_step
    result: _FlowResultT = await getattr(flow, method)(user_input)
  File "/config/custom_components/tesla_custom/config_flow.py", line 96, in async_step_credentials
    info = await validate_input(self.hass, user_input)
  File "/config/custom_components/tesla_custom/config_flow.py", line 260, in validate_input
    controller = TeslaAPI(

2024-10-14 12:36:09.607 WARNING (MainThread) [homeassistant.config_entries] Config entry '[email]@hotmail.com' for tesla_custom integration could not authenticate
2024-10-14 12:36:28.817 WARNING (MainThread) [homeassistant.components.simplisafe] Reconnecting to websocket
2024-10-14 12:36:49.049 ERROR (MainThread) [firebase_messaging.fcmpushclient] Unexpected exception during read
Traceback (most recent call last):
  File "/usr/local/lib/python3.12/site-packages/firebase_messaging/fcmpushclient.py", line 661, in _listen
    elif msg := await self._receive_msg():
                ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/firebase_messaging/fcmpushclient.py", line 280, in _receive_msg
    r = await self.reader.readexactly(1)  # type: ignore[union-attr]
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/asyncio/streams.py", line 752, in readexactly
    await self._wait_for_data('readexactly')
  File "/usr/local/lib/python3.12/asyncio/streams.py", line 545, in _wait_for_data
    await self._waiter
  File "/usr/local/lib/python3.12/asyncio/selector_events.py", line 978, in _read_ready__get_buffer
    nbytes = self._sock.recv_into(buf)
             ^^^^^^^^^^^^^^^^^^^^^^^^^
ConnectionResetError: [Errno 104] Connection reset by peer
2024-10-14 12:39:24.062 ERROR (MainThread) [firebase_messaging.fcmpushclient] Unexpected exception during read
Traceback (most recent call last):
  File "/usr/local/lib/python3.12/site-packages/firebase_messaging/fcmpushclient.py", line 661, in _listen
    elif msg := await self._receive_msg():
                ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/firebase_messaging/fcmpushclient.py", line 280, in _receive_msg
    r = await self.reader.readexactly(1)  # type: ignore[union-attr]
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/asyncio/streams.py", line 752, in readexactly
    await self._wait_for_data('readexactly')
  File "/usr/local/lib/python3.12/asyncio/streams.py", line 545, in _wait_for_data
    await self._waiter
  File "/usr/local/lib/python3.12/asyncio/selector_events.py", line 978, in _read_ready__get_buffer
    nbytes = self._sock.recv_into(buf)
             ^^^^^^^^^^^^^^^^^^^^^^^^^
ConnectionResetError: [Errno 104] Connection reset by peer
2024-10-14 12:41:03.701 DEBUG (MainThread) [custom_components.tesla_custom.config_flow] Running in supervised environment
2024-10-14 12:41:03.789 DEBUG (MainThread) [custom_components.tesla_custom.config_flow] Found addon: c03d64a7_tesla_http_proxy
2024-10-14 12:41:10.334 DEBUG (MainThread) [custom_components.tesla_custom.config_flow] Credentials successfully connected to the Tesla API
2024-10-14 12:41:10.348 DEBUG (MainThread) [custom_components.tesla_custom] Trusting CA: {'subject': ((('countryName', 'TR'),), (('localityName', 'Gebze - Kocaeli'),), (('organizationName', 'Turkiye Bilimsel ve Teknolojik Arastirma Kurumu - TUBITAK'),), (('organizationalUnitName', 'Kamu Sertifikasyon Merkezi - Kamu SM'),), (('commonName', 'TUBITAK Kamu SM SSL Kok Sertifikasi - Surum 1'),)), 'issuer': ((('countryName', 'TR'),), (('localityName', 'Gebze - Kocaeli'),), (('organizationName', 'Turkiye Bilimsel ve Teknolojik Arastirma Kurumu - TUBITAK'),), (('organizationalUnitName', 'Kamu Sertifikasyon Merkezi - Kamu SM'),), (('commonName', 'TUBITAK Kamu SM SSL Kok Sertifikasi - Surum 1'),)), 'version': 3, 'serialNumber': '01', 'notBefore': 'Nov 25 08:25:55 2013 GMT', 'notAfter': 'Oct 25 08:25:55 2043 GMT'}
2024-10-14 12:41:10.391 DEBUG (MainThread) [teslajsonpy.controller] 552 endpoints loaded
2024-10-14 12:41:10.393 DEBUG (MainThread) [teslajsonpy.connection] Token expiration in -20011 days, 11:18:50
2024-10-14 12:41:10.393 DEBUG (MainThread) [teslajsonpy.connection] Oauth expiration detected
2024-10-14 12:41:10.393 DEBUG (MainThread) [teslajsonpy.connection] Refreshing access token with refresh_token
2024-10-14 12:41:10.895 DEBUG (MainThread) [teslajsonpy.connection] Unable to refresh sso oauth token
2024-10-14 12:41:10.895 DEBUG (MainThread) [teslajsonpy.connection] Auth returned {'error': 'login_required', 'error_description': 'The refresh_token is invalid', 'referenceID': '462a385b-d2fa-4bd0-bcea-bf83355b9c70-1728924070794. For more information, visit: https://developer.tesla.com/docs/fleet-api#help-and-support'}
2024-10-14 12:41:11.989 DEBUG (MainThread) [teslajsonpy.connection] Token expiration in -20011 days, 11:18:49
2024-10-14 12:41:11.989 DEBUG (MainThread) [teslajsonpy.connection] Oauth expiration detected
2024-10-14 12:41:11.989 DEBUG (MainThread) [teslajsonpy.connection] Refreshing access token with refresh_token
2024-10-14 12:41:12.217 DEBUG (MainThread) [teslajsonpy.connection] Unable to refresh sso oauth token
2024-10-14 12:41:12.218 DEBUG (MainThread) [teslajsonpy.connection] Auth returned {'error': 'login_required', 'error_description': 'The refresh_token is invalid', 'referenceID': 'f774a9f3-f346-4424-98a9-e9f1c3eb1b14-1728924072116. For more information, visit: https://developer.tesla.com/docs/fleet-api#help-and-support'}
2024-10-14 12:41:14.382 DEBUG (MainThread) [teslajsonpy.connection] Token expiration in -20011 days, 11:18:46
2024-10-14 12:41:14.382 DEBUG (MainThread) [teslajsonpy.connection] Oauth expiration detected
2024-10-14 12:41:14.382 DEBUG (MainThread) [teslajsonpy.connection] Refreshing access token with refresh_token
2024-10-14 12:41:14.569 DEBUG (MainThread) [teslajsonpy.connection] Unable to refresh sso oauth token
2024-10-14 12:41:14.569 DEBUG (MainThread) [teslajsonpy.connection] Auth returned {'error': 'login_required', 'error_description': 'The refresh_token is invalid', 'referenceID': 'f943d8e2-0724-4b02-b7fc-6fab18ddd63e-1728924074517. For more information, visit: https://developer.tesla.com/docs/fleet-api#help-and-support'}
2024-10-14 12:41:18.572 DEBUG (MainThread) [teslajsonpy.connection] Token expiration in -20011 days, 11:18:42
2024-10-14 12:41:18.572 DEBUG (MainThread) [teslajsonpy.connection] Oauth expiration detected
2024-10-14 12:41:18.572 DEBUG (MainThread) [teslajsonpy.connection] Refreshing access token with refresh_token
2024-10-14 12:41:18.906 DEBUG (MainThread) [teslajsonpy.connection] Unable to refresh sso oauth token
2024-10-14 12:41:18.906 DEBUG (MainThread) [teslajsonpy.connection] Auth returned {'error': 'login_required', 'error_description': 'The refresh_token is invalid', 'referenceID': '3f88f059-2dba-40a1-9651-636aa4428c8d-1728924078841. For more information, visit: https://developer.tesla.com/docs/fleet-api#help-and-support'}
2024-10-14 12:41:25.394 DEBUG (MainThread) [teslajsonpy.connection] Token expiration in -20011 days, 11:18:35
2024-10-14 12:41:25.394 DEBUG (MainThread) [teslajsonpy.connection] Oauth expiration detected
2024-10-14 12:41:25.395 DEBUG (MainThread) [teslajsonpy.connection] Refreshing access token with refresh_token
2024-10-14 12:41:25.629 DEBUG (MainThread) [teslajsonpy.connection] Unable to refresh sso oauth token
2024-10-14 12:41:25.629 DEBUG (MainThread) [teslajsonpy.connection] Auth returned {'error': 'login_required', 'error_description': 'The refresh_token is invalid', 'referenceID': 'dbed51d5-7605-4e12-a20c-01df5dea6955-1728924085577. For more information, visit: https://developer.tesla.com/docs/fleet-api#help-and-support'}
2024-10-14 12:41:25.630 WARNING (MainThread) [homeassistant.config_entries] Config entry '[email]@hotmail.com' for tesla_custom integration could not authenticate
2024-10-14 12:41:28.933 WARNING (MainThread) [homeassistant.components.simplisafe] Reconnecting to websocket
2024-10-14 12:41:59.078 ERROR (MainThread) [firebase_messaging.fcmpushclient] Unexpected exception during read
Traceback (most recent call last):
  File "/usr/local/lib/python3.12/site-packages/firebase_messaging/fcmpushclient.py", line 661, in _listen
    elif msg := await self._receive_msg():
                ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/firebase_messaging/fcmpushclient.py", line 280, in _receive_msg
    r = await self.reader.readexactly(1)  # type: ignore[union-attr]
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/asyncio/streams.py", line 752, in readexactly
    await self._wait_for_data('readexactly')
  File "/usr/local/lib/python3.12/asyncio/streams.py", line 545, in _wait_for_data
    await self._waiter
  File "/usr/local/lib/python3.12/asyncio/selector_events.py", line 978, in _read_ready__get_buffer
    nbytes = self._sock.recv_into(buf)
             ^^^^^^^^^^^^^^^^^^^^^^^^^
ConnectionResetError: [Errno 104] Connection reset by peer

Anything else?

No response

usuryadevara commented 1 month ago

I want to update that i followed the instructions but same issue.

Here is what i did: I was able to access this Tesla HTTP Proxy add-on login with my tesla account, 1) have muti factor authentication setup with google authenticator 2) Setup the Tesla-endpoint Allowed origin https://centtsla.duckdns.org and https://centtsla.duckdns.org/callback and was able to generate the token from URL and configure the token inTesla custom integration plugin from HACS (use fleet API proxy, emailid of what i use for tesla login, refresh token from tesla-endpoint generated. Rest domain and all proxy url and certs left defaults.

Please let me know what else i need to try?

skipishere commented 1 month ago

The error message implies you've not given it the correct refresh token as there is an error message saying The refresh_token is invalid

usuryadevara commented 1 month ago

Feom that tesla add on page I was able to authenticate with tesla http proxy login page and copied the token from.

I tried atleast 40 times. It's generating token ok.

jopocop commented 3 weeks ago

I had exact same issue: 2024-10-26 21:14:09.421 DEBUG (MainThread) [teslajsonpy.connection] Token expiration in -20023 days, 2:45:51 2024-10-26 21:14:09.421 DEBUG (MainThread) [teslajsonpy.connection] Oauth expiration detected 2024-10-26 21:14:09.422 DEBUG (MainThread) [teslajsonpy.connection] Refreshing access token with refresh_token 2024-10-26 21:14:09.683 DEBUG (MainThread) [teslajsonpy.connection] Unable to refresh sso oauth token 2024-10-26 21:14:09.683 DEBUG (MainThread) [teslajsonpy.connection] Auth returned {'error': 'login_required', 'error_description': 'The refresh_token is invalid', 'referenceID': 'd11f01b5-5335-47ad-b938-a125db2dd980-1739966349570. For more information, visit: https://developer.tesla.com/docs/fleet-api#help-and-support'}

Then I noticed that I'm using my local address to create the token. And tried with the duckdns.org address. Things changed to unexpected direction. Tesla Custom Integration still says: "Failed to set up: Check the logs"

And the log says: 2024-10-26 21:28:49.875 DEBUG (MainThread) [teslajsonpy.connection] Token expiration in -20023 days, 2:31:11 2024-10-26 21:28:49.875 DEBUG (MainThread) [teslajsonpy.connection] Oauth expiration detected 2024-10-26 21:28:49.875 DEBUG (MainThread) [teslajsonpy.connection] Refreshing access token with refresh_token 2024-10-26 21:28:50.164 DEBUG (MainThread) [teslajsonpy.connection] Saved new auth info {'access_token': 'xxxxxxxxxxxxxxxx', 'refresh_token': 'xxxxxxxxxxxxxxx', 'expires_in': 1730006929} 2024-10-26 21:28:50.164 DEBUG (MainThread) [teslajsonpy.connection] Successfully refreshed oauth 2024-10-26 21:28:50.165 DEBUG (MainThread) [teslajsonpy.connection] get: https://3f232c9f-tesla-http-proxy/api/1/products {} 2024-10-26 21:28:50.231 DEBUG (MainThread) [teslajsonpy.connection] 412: {"error":"Account xxxxxxxxxxxxxxxxxxxxx must be registered in the current region https://fleet-api.prd.eu.vn.cloud.tesla.com, please see https://developer.tesla.com/docs/fleet-api/endpoints/partner-endpoints#register"} [the above section total 5 times] 2024-10-26 21:29:05.621 ERROR (MainThread) [custom_components.tesla_custom] Unable to communicate with Tesla API: UNKNOWN_ERROR_412

And a bit above that: 2024-10-26 21:28:49.859 DEBUG (MainThread) [custom_components.tesla_custom] Trusting CA: {'subject': ((('countryName', 'TR'),), (('localityName', 'Gebze - Kocaeli'),), (('organizationName', 'Turkiye Bilimsel ve Teknolojik Arastirma Kurumu - TUBITAK'),), (('organizationalUnitName', 'Kamu Sertifikasyon Merkezi - Kamu SM'),), (('commonName', 'TUBITAK Kamu SM SSL Kok Sertifikasi - Surum 1'),)), 'issuer': ((('countryName', 'TR'),), (('localityName', 'Gebze - Kocaeli'),), (('organizationName', 'Turkiye Bilimsel ve Teknolojik Arastirma Kurumu - TUBITAK'),), (('organizationalUnitName', 'Kamu Sertifikasyon Merkezi - Kamu SM'),), (('commonName', 'TUBITAK Kamu SM SSL Kok Sertifikasi - Surum 1'),)), 'version': 3, 'serialNumber': '01', 'notBefore': 'Nov 25 08:25:55 2013 GMT', 'notAfter': 'Oct 25 08:25:55 2043 GMT'}

...I am located in Finland. Any idea why the car is registered in Turkey? Or rather, how to fix this one? I'm the first owner of the car, 1.5y old MY - or at least that was my belief until today :)

jopocop commented 3 weeks ago

Googling, it seems like others have Turkey there as well, so that might not be the actual cause. Problem persists:

DEBUG (MainThread) [teslajsonpy.connection] 412: {"error":"Account xxxxxxxxxxxxxxxxxxxxx must be registered in the current region https://fleet-api.prd.eu.vn.cloud.tesla.com, please see https://developer.tesla.com/docs/fleet-api/endpoints/partner-endpoints#register"}