fars-fede-fire / volvoaaos

Home Assistant custom component for Volvo AAOS vehicles
MIT License
8 stars 2 forks source link

Unable to add integration #40

Closed timknowlden closed 10 months ago

timknowlden commented 10 months ago

System Health details

Unraid server running ha core inside docker

Checklist

Describe the issue

I use my volvo email address for user and the password. I've entered the vccapikey but i get an error when trying to add integration

Reproduction steps

1. 2. 3. ...

Debug logs

None

Diagnostics dump

No response

fars-fede-fire commented 10 months ago

What does your log say?

timknowlden commented 10 months ago

What does your log say?

This is as far as it allows me to go setting up. Screenshot_20240119_190133_Home Assistant

fars-fede-fire commented 10 months ago

Can you please attach the log? Else it is impossible to find the error.

timknowlden commented 10 months ago

`Logger: aiohttp.server Source: /usr/local/lib/python3.11/site-packages/aiohttp/web_protocol.py:421 First occurred: 9:16:03 PM (1 occurrences) Last logged: 9:16:03 PM

Error handling request Traceback (most recent call last): File "/usr/local/lib/python3.11/site-packages/aiohttp/web_protocol.py", line 452, in _handle_request resp = await request_handler(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/aiohttp/web_app.py", line 543, in _handle resp = await handler(request) ^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/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 85, in security_filter_middleware return await handler(request) ^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/components/http/forwarded.py", line 227, in forwarded_middleware return await handler(request) ^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/components/http/request_context.py", line 28, in request_context_middleware return await handler(request) ^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/components/http/ban.py", line 80, in ban_middleware return await handler(request) ^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/components/http/auth.py", line 233, 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/components/http/view.py", line 149, in handle result = await handler(request, request.match_info) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/components/http/decorators.py", line 63, in with_admin return await func(self, request, *args, *kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/components/config/config_entries.py", line 177, 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 110, in post result = await self._flow_mgr.async_configure(flow_id, data) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 293, in async_configure result = await self._async_handle_step( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 389, in _async_handle_step result: FlowResult = await getattr(flow, method)(user_input) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/volvoaaos/config_flow.py", line 75, in async_step_user return await self.async_step_select_vin() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/volvoaaos/config_flow.py", line 99, in async_step_select_vin response = await connected_vehicle.list_vehicles() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/volvoaaos/volvo.py", line 169, in list_vehicles response = await self._request(url=url, headers=headers) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/volvoaaos/volvo.py", line 47, in _request response.raise_for_status() File "/usr/local/lib/python3.11/site-packages/aiohttp/client_reqrep.py", line 1059, in raise_for_status raise ClientResponseError( aiohttp.client_exceptions.ClientResponseError: 401, message='Unauthorized', url=URL('https://api.volvocars.com/connected-vehicle/v2/vehicles') `

fars-fede-fire commented 10 months ago

Thanks! I will take a look at it in a couple of days...

timknowlden commented 10 months ago

Thanks! I will take a look at it in a couple of days...

Okay no problem

timknowlden commented 10 months ago

Hi, did you get a chance to take a look @fars-fede-fire the username is that my volvo app email and password, or developer account where the vccapikey is created? Ive tried both anyway.

fars-fede-fire commented 10 months ago

I have tried change some at the initial setup. But I don not think that it is your problem. The only way I can recreate your problem is when I intentionally type a wrong email, password or vcc-api-key...

When setting up the integration you have to use the same email and password as when you are using the mobile app.

fars-fede-fire commented 10 months ago

I did some more testing with creating a new application and vcc-api-key which gave your error even when testing from Volvos own site.

Can you please try https://developer.volvocars.com/apis/energy/v1/specification/ and see if it returns the same error or if you actually get the correct data?

timknowlden commented 10 months ago

I have tried change some at the initial setup. But I don not think that it is your problem. The only way I can recreate your problem is when I intentionally type a wrong email, password or vcc-api-key...

When setting up the integration you have to use the same email and password as when you are using the mobile app.

Yes I used my email and password that I use to login to the volvo android app.

I'm copying and pasting the apikey, but perhaps it's not recognising it?

The volvo developer app I've set up using my Google account, have also tried github, both of these are not the same details I login to my volvo app though

timknowlden commented 10 months ago

I did some more testing with creating a new application and vcc-api-key which gave your error even when testing from Volvos own site.

Can you please try https://developer.volvocars.com/apis/energy/v1/specification/ and see if it returns the same error or if you actually get the correct data?

These are all energy, my car is an xc60 b5 mild hybrid

Screenshot_20240123_104733_Brave

fars-fede-fire commented 10 months ago

From that screenshot it looks like you are not authorised when trying to call the api from within Volvos homepage. Is that correct?

timknowlden commented 10 months ago

Possible volvo fault then as its a valid vccapikey copied from the application.

Am I correct in thinking that server response is the actual response, the responses are the possible responses that could be receieved?

fars-fede-fire commented 10 months ago

Yes, that is correct.

You can try to contact the Volvo dev team to hear why your vcc api key is not working.

I am closing this issue as the error is not caused by the integration. But please share if you get a response from Volvo or there are any other problems!

timknowlden commented 10 months ago

Yes, that is correct.

You can try to contact the Volvo dev team to hear why your vcc api key is not working.

I am closing this issue as the error is not caused by the integration. But please share if you get a response from Volvo or there are any other problems! API

I have tried again now on the computer and get a response on the volvo sandbox..

V1 Energy API also works on volvo developer

fars-fede-fire commented 10 months ago

Interesting... What happens if you reinstall the integration and use the same credentials? What errors do you get in the log now?

timknowlden commented 10 months ago

Interesting... What happens if you reinstall the integration and use the same credentials? What errors do you get in the log now?

I have reinstalled just now and still have the same error, However Since trying on Volvo Website its also giving me a 401 error again. I have emailed them as Its so hit and miss when it does and doesn't work.

timknowlden commented 10 months ago

Log:


Source: /usr/local/lib/python3.11/site-packages/aiohttp/web_protocol.py:421
First occurred: 2:51:59 PM (1 occurrences)
Last logged: 2:51:59 PM

Error handling request
Traceback (most recent call last):
  File "/usr/local/lib/python3.11/site-packages/aiohttp/web_protocol.py", line 452, in _handle_request
    resp = await request_handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/aiohttp/web_app.py", line 543, in _handle
    resp = await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/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 85, in security_filter_middleware
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/forwarded.py", line 227, in forwarded_middleware
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/request_context.py", line 28, in request_context_middleware
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/ban.py", line 80, in ban_middleware
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/auth.py", line 233, 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/components/http/view.py", line 149, in handle
    result = await handler(request, **request.match_info)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/decorators.py", line 63, in with_admin
    return await func(self, request, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/config/config_entries.py", line 177, 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 110, in post
    result = await self._flow_mgr.async_configure(flow_id, data)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 320, in async_configure
    result = await self._async_handle_step(
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 416, in _async_handle_step
    result: FlowResult = await getattr(flow, method)(user_input)
                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/volvoaaos/config_flow.py", line 75, in async_step_user
    return await self.async_step_select_vin()
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/volvoaaos/config_flow.py", line 99, in async_step_select_vin
    response = await connected_vehicle.list_vehicles()
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/volvoaaos/volvo.py", line 169, in list_vehicles
    response = await self._request(url=url, headers=headers)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/volvoaaos/volvo.py", line 47, in _request
    response.raise_for_status()
  File "/usr/local/lib/python3.11/site-packages/aiohttp/client_reqrep.py", line 1059, in raise_for_status
    raise ClientResponseError(
aiohttp.client_exceptions.ClientResponseError: 401, message='Unauthorized', url=URL('https://api.volvocars.com/connected-vehicle/v2/vehicles')