Volvo Cars integration

It’s the core integration version. When I said “weeks”, I forgot I’d installed it that recently — looking at some screenshots I took of the iPhone authentication, it was just one week :grinning:

It’s possible it was Volvo doing some scheduled maintenance over the weekend — perhaps if I’d left it alone, it would have been working again this morning, but trying to reauthenticate destroyed the existing token and left me having to reauthenticate a second time once the backend was back with us.

There wasn’t anything about maintenance on Volvo’s login page, but that doesn’t mean they weren’t doing any, of course…

Great work, the onboarding without the OTP was flawless.
Patiently using it alongside volvo2mqtt until the features I need have been added. Thanks!

1 Like

An update: it’s showing “authentication expired” again, and now when I try to reconnect, I get another “request for approval” screen. I click “allow access” and I see this:

and this in the integration’s settings:

I’ve tried regenerating the API keys at Volvo’s end, but there does not seem to be a way of changing them in the integration. I’m not sure whether re-authenticating is the way you’re supposed to do this, but it needs to be possible (keys can get compromised and need to be cycled!)

I’m now trying deleting the integration and starting afresh. Hopefully this will delete all the saved settings as well and I can start over…

Nope. Same error as before. Does deleting an integration delete all its settings?

If I publish the application on the Volvo portal, giving over a load of personal information that I did not want to give out, and follow the instructions, then I just get this instead:

Is there anyone out there who has got it to work, and stay working, and can tell me how they did it?

See: Issue 151062
Also do not forget to read the documentation!

1 Like

I tried that, but entered my instance in place of my.home-assistant.io. In my defence, it looks like a placeholder :grin:

Working now — thanks!

Excellent! But the most important button is missing, “Start Engine”. Everything else is there :neutral_face:

Correct, it’s a known issue, read the details here: https://github.com/thomasddn/ha-volvo-cars/issues/32

The button will be available in the core integration, eventually.

1 Like

Hi! Calling for help from someone with a combustion engine. I’m working on the buttons for the core integration and the reviewer questioned if we can use a switch instead of a button for the start/stop engine.

I’m not sure if the Engine status changes to Running when the engine is remotely started.

So I’d like to ask if you can start the engine via the official Volvo app and then after a few minutes check the integration to see if the Engine status has been changed to Running. Please also check the other way around: stopping the engine remotely should change the state to Not running.

Thanks a million!

Just checked, and indeed the binary sensor switches to on in the HACS version of the integration. Same thing happens when it stops, the sensor turns off again. Side note, my car is a plugin hybrid, so it might be different with a combustion only.

1 Like

2019 XC90 (combustion). I just tested with the HACS version and after 15 minutes the Engine status never changed. I swear this used to work though.

I know it did actually - I don’t use the remote starter much in the summer. It’s more of a winter thing for me. I have an automation that alerts me if the engine starts and the garage door is closed (and the car is home etc) - and I know it’s triggered before (a number of times) when starting the car in the morning.

1 Like

Just checking, was the engine actually running?

The more test results I receive, the better I can make the buttons or switch work as intended. So, don’t wait on anyone else please! :wink:

I tested again today with the same result. I confirmed the engine did start.

I’m wondering if maybe something strange happened because of timing?
I had just arrived home before testing, so the engine had only been off for maybe 3-5 minutes before starting it via remote start.

I remote started the car around 9:20-9:23-ish and let it run for the full 15 minutes.

HACS:

Core:

Side note: I have noticed the core module (which I configured yesterday), seems to become unavailable more often than the HACS version.

Thanks again for your insights! The different behaviour could very well be due to the different engine type, like @clw suggested.

The interruptions could be caused by (temporarily) failing API calls. Whereas the HACS version would keep the current value, the core version reports unavailable. It’s up for debate which one is better.

If you could provide debug logs of such occurrences, I might find a way around it (depending on the root cause).

I can’t connect I get the following error:
Unable to retrieve vehicles.

Napló: homeassistant.components.volvo.config_flow
Forrás: components/volvo/config_flow.py:113
integráció: Volvo (dokumentáció, problémák)
Először fordult elő: 16:13:54 (2 előfordulás)
Utoljára naplózva: 16:14:37

Unable to retrieve vehicles
Traceback (most recent call last):
  File "/usr/local/lib/python3.13/site-packages/aiohttp/client.py", line 770, in _request
    resp = await handler(req)
           ^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.13/site-packages/aiohttp/client.py", line 725, in _connect_and_send_request
    conn = await self._connector.connect(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        req, traces=traces, timeout=real_timeout
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/usr/local/lib/python3.13/site-packages/aiohttp/connector.py", line 642, in connect
    proto = await self._create_connection(req, traces, timeout)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.13/site-packages/aiohttp/connector.py", line 1209, in _create_connection
    _, proto = await self._create_direct_connection(req, traces, timeout)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.13/site-packages/aiohttp/connector.py", line 1550, in _create_direct_connection
    transp, proto = await self._wrap_create_connection(
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    ...<7 lines>...
    )
    ^
  File "/usr/local/lib/python3.13/site-packages/aiohttp/connector.py", line 1283, in _wrap_create_connection
    return await self._loop.create_connection(*args, **kwargs, sock=sock)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.13/asyncio/base_events.py", line 1201, in create_connection
    transport, protocol = await self._create_connection_transport(
                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    ...<2 lines>...
        ssl_shutdown_timeout=ssl_shutdown_timeout)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.13/asyncio/base_events.py", line 1234, in _create_connection_transport
    await waiter
asyncio.exceptions.CancelledError

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

Traceback (most recent call last):
  File "/usr/local/lib/python3.13/site-packages/volvocarsapi/api.py", line 398, in _async_request
    async with self._client.request(
               ~~~~~~~~~~~~~~~~~~~~^
        method, url, headers=headers, json=body, timeout=_API_REQUEST_TIMEOUT
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    ) as response:
    ^
  File "/usr/local/lib/python3.13/site-packages/aiohttp/client.py", line 1488, in __aenter__
    self._resp: _RetType = await self._coro
                           ^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.13/site-packages/aiohttp/client.py", line 622, in _request
    with timer:
         ^^^^^
  File "/usr/local/lib/python3.13/site-packages/aiohttp/helpers.py", line 685, in __exit__
    raise asyncio.TimeoutError from exc_val
TimeoutError

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

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/volvo/config_flow.py", line 113, in async_step_api_key
    await self._async_load_vehicles(api)
  File "/usr/src/homeassistant/homeassistant/components/volvo/config_flow.py", line 241, in _async_load_vehicles
    vins = await api.async_get_vehicles()
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.13/site-packages/volvocarsapi/api.py", line 245, in async_get_vehicles
    body = await self._async_request(hdrs.METH_GET, url, operation="vehicles")
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.13/site-packages/volvocarsapi/api.py", line 442, in _async_request
    raise VolvoApiException(ex.__class__.__name__, operation) from ex
volvocarsapi.models.VolvoApiException: ('TimeoutError', 'vehicles')

It seems you are experiencing timeout errors. Was (or is) your network or HA server under heavy load? If not, try rebooting your router and/or server.

Also check if firewall rules or adblocking are not blocking the request.

The following is my experience
If HA needs to be restarted because a component has been updated, none of the Volvo integrations will connect afterwards.
Load, firewall rules do not change and load does not increase during this time.
Then I restart my router (pfsense) and it works again.

Would you mind sharing which model you have exactly? E.g. XC60 PHEV MY22. Of all the vehicles that have been tested, you’re the only one that sees the status changing when starting remotely.

I’ll just be quick here. I’ve tried this custom integration and the ‘official’ integration (both written by you) and I went back and forth MANY times trying to get this to work. At first, the biggest problem was the entities not showing up when switching from one to the other. Never could sort that out because a bigger problem arose. The CPU utilization creeps up steadily over time until Home Assistant simply becomes unusable. For me, takes about an hour. Deleting the integration resolves the CPU immediately. I’ll try again in a few months but for now, I have to park it. I appreciate your effort and hope you get this work.

Sorry to hear that. Other than making about 12 parallel API requests and parsing the result, there is nothing special about this integration that is CPU intensive.

Maybe it could become a problem on slow network/hardware, where requests take longer to process than the set interval.

I can have a look what the problem is, if you want. Enable debug logging, wait for HA to become unstable, stop debug logging, and then send me the logs at https://www.dropbox.com/request/SdxkVf0OIWJCDjgcKtRj.