jhansche / ha-teslafi

Home Assistant integration for TeslaFi-monitored vehicles
MIT License
13 stars 0 forks source link

Integration won't save API Key #24

Closed JarodOliver closed 5 months ago

JarodOliver commented 6 months ago

Hi there,

I've tried to search for other people experiencing this, but I wasn't able to find any. When I add the integration and paste in my TeslaFi API Key, it throws a "Unknown error occurred" error.

I tried to search through the logs, but I can't find any references to this integration. I must admit though that I'm about a week into my Home Assistant journey so I don't know where everything is located.

Many thanks.

TeslaFi_Error
jhansche commented 6 months ago

I've updated my development environment to 2024.3.0, just to confirm that it's working correctly on newer versions, and I'm not seeing any issues currently.

I'm going to need more information to be able to troubleshoot this.

AlisterGill commented 5 months ago

Same error here: Calling the API from a browser returns my VIN number / drives / etc. V2.4 Core 2024.3.3 Supervisor 2024.03.1 Operating System 12.1 Frontend 20240307.0

logs Logger: aiohttp.server Source: /usr/local/lib/python3.12/site-packages/aiohttp/web_protocol.py:421 First occurred: 20:47:27 (1 occurrences) Last logged: 20:47:27

Error handling request Traceback (most recent call last): File "/usr/local/lib/python3.12/site-packages/aiohttp/web_protocol.py", line 452, in _handle_request resp = await request_handler(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/aiohttp/web_app.py", line 543, in _handle resp = await handler(request) ^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/aiohttp/web_middlewares.py", line 114, in impl return await handler(request) ^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/components/http/security_filter.py", line 91, in security_filter_middleware return await handler(request) ^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/components/http/forwarded.py", line 100, in forwarded_middleware return await handler(request) ^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/components/http/request_context.py", line 25, in request_context_middleware return await handler(request) ^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/components/http/ban.py", line 79, in ban_middleware return await handler(request) ^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/components/http/auth.py", line 235, in auth_middleware return await handler(request) ^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/components/http/headers.py", line 31, in headers_middleware response = await handler(request) ^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/helpers/http.py", line 68, in handle result = await handler(request, request.match_info) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/components/http/decorators.py", line 72, in with_admin return await func(self, request, *args, *kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/components/config/config_entries.py", line 197, in post return await super().post(request, flow_id) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/components/http/data_validator.py", line 72, in wrapper result = await method(view, request, data, args, kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/helpers/data_entry_flow.py", line 111, in post result = await self._flow_mgr.async_configure(flow_id, data) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 359, in async_configure result = await self._async_configure(flow_id, user_input) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 405, in _async_configure result = await self._async_handle_step( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 551, in _async_handle_step result = await self.async_finish_flow(flow, result.copy()) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/config_entries.py", line 1183, in async_finish_flow title=result["title"],


KeyError: 'title'
jhansche commented 5 months ago

I don't think this helps, unfortunately. This only shows a Home Assistant error, but isn't showing anything from the teslafi integration. Since it looks like this is happening in HA, it's possible that it might be an issue in your config entry. You can try looking at your .storage/core.config_entries file and search for teslafi. If the entry is there, then it should also have a title property, containing the name of your vehicle. If it's not there, then the error is happening before it can even write the new entry, but I don't see a code path where I could return an entry that does not contain a title. Unless...

Calling the API from a browser returns my VIN number / drives / etc.

Try this again, and search the JSON data for "display_name". If that is not present, or its value is null, that could be the problem. It should be the name of your vehicle.


If that doesn't help, it may be useful to turn on debug logging for the integration. Normally you can do it from the integration page, but if you're encountering errors adding the integration in the first place, you won't be able to do that. Instead, you can configure the teslafi logger in your configuration.yaml file:

logger:
  default: info
  logs:
    custom_components.teslafi: debug

Reload Home Assistant, and try to add the integration again. Then back in System > Logs, click the "Load full logs" button at the bottom to see the full log file. Then look for anything teslafi related there.

If this still doesn't uncover some information I can use to debug or reproduce the issue, then I'm not sure how else I can help. It works for me, even after removing and readding.

AlisterGill commented 5 months ago

That will likely be the issue then. I never set up a name for my Tesla. I could never come up with anything witty enough so left it blank!

JarodOliver commented 5 months ago

Apologies for not replying sooner. I think that'll be my issue too because I never saw the point of giving my car a name! Thanks very much.

AlisterGill commented 5 months ago

Apologies for not replying sooner. I think that'll be my issue too because I never saw the point of giving my car a name! Thanks very much.

Yes - I named the car and it all works. Thanks all!

jhansche commented 5 months ago

I'll be honest: I didn't know that you could choose to leave it unnamed 😂 I thought that was forced when setting it up.

Since it affected both of you - I'll try to add a fallback name instead of just relying on the Tesla display name.