Volvo2Mqtt: Connect your AAOS Volvo 🚙

Fist of all, thank you @Dielee for this awesome add-on.
I’m here to mention I’ve implemented TA trip statistics with this pull request.
It works by adding additional sensors
image
I’m using trip fuel cons to calculate my carbon footprint of the trip and lifetime of the car with utility meters. It is possible without TA stats using Average Fuel Cons, but TA fuel cons gives much more accurate results, especially when driving in mixed conditions with city traffic.
In case you can’t wait for pull aproval you can use my repo as I do for now.

1 Like

Looks like the issue for US users is here though I could be wrong. In any case l’ve created my own sensor as a work around.

units = {
“en_GB”: {
“divider”: 1.60934,
“electric_range”: {“unit”: LENGTH_MILES},
“odometer”: {“unit”: LENGTH_MILES},
“average_speed”: {“unit”: SPEED_MILES_PER_HOUR},
“distance_to_empty”: {“unit”: LENGTH_MILES},
“distance_to_service”: {“unit”: LENGTH_MILES}
},
“en_US”: {
“divider”: 1.60934,
“electric_range”: {“unit”: LENGTH_MILES},
“odometer”: {“unit”: LENGTH_MILES},
“average_speed”: {“unit”: SPEED_MILES_PER_HOUR},
“distance_to_empty”: {“unit”: LENGTH_MILES},
“distance_to_service”: {“unit”: LENGTH_MILES}
}
}

Any reason I might not see the OTP show up in entities once I start the service? Is there a reenumerate?

edit: solved:
After you install Mosquitto service, you have to enable the MQTT discovered integration to see the published sensors like the OTP. Derp.

Is there a way to do the mqtt post to the broker as per the documentation 6b? http://ha_url/developer-tools/service redirects to action in the latest

edit: working with chatgpt as suggested above… seems doable, but I dont need it anymore once I added the MQTT integration.

Core 2024.12.0
Supervisor 2024.11.4
Operating System 14.0
Frontend 20241127.4
Volvo2MQTT: 1.10.5
Mosquitto: 6.4.1

Any progress controlling the electric charging? I’d love to be able to start/stop the electric AC charging on my European 2025 XC90 T8. Happy to donate via Ko-fi and help with debugging cc @Dielee.

2 Likes

I am interested as well !

2 Likes

Just to put it out there, my 2024 Volvo V60 began to work in Canada despite the API saying Canada is not a supported region.

I have a issue where I cant get my VCCAPIKEY to get working. I rebooted the Volvo2Mqtt beacuse I could not get the loaction to work and that affected my automations. I have changed the VCCAPIKEY both the primay and the secondary but I still get this issue from the log.
also renew the api key on the

Dec 10 14:56:08 volvo2mqtt [106] - INFO: Starting volvo2mqtt version v1.10.5
Dec 10 14:56:08 volvo2mqtt [106] - INFO: Using login from token file
Dec 10 14:56:08 volvo2mqtt [106] - INFO: Refreshing credentials
Dec 10 14:56:08 volvo2mqtt [106] - WARNING: VCCAPIKEY… isn’t working! Access denied due to invalid token. The sub claim contains an array instead of a plain string.
Dec 10 14:56:08 volvo2mqtt [106] - WARNING: VCCAPIKEY … isn’t working! Access denied due to invalid token. The sub claim contains an array instead of a plain string.
Dec 10 14:56:08 volvo2mqtt [106] - DEBUG: [{‘key’: ‘…’, ‘extended’: True, ‘extended_until’: None, ‘in_use’: False}, {‘key’: ‘…’, ‘extended’: True, ‘extended_until’: None, ‘in_use’: False}]
Dec 10 14:56:08 volvo2mqtt [106] - WARNING: No working VCCAPIKEY found, waiting 10 minutes. Then trying again!

Found it,
I had to delete the token file in de addon ,
First stop the addon go to : \addons\volvo2mqtt\token,
the delete the .token file start the addon, and i wil ask for a new token to put in the OTP Field

2 Likes

Any one else have a problem with tire status? Looked at the debug logging and it looks like the API is returning a value “unspecified”.

In the logs i could also see that the statuses of all lights is now supported.

1 Like

Yup me too, tires went “unspecified” a few days ago.

1 Like

I can confirm. Probably because of the new car’s update 3.3.16…

Thank you very much! This worked for me too.

This Add-on is working well with my 2021 XC40 Recharge. I also have the Google Assistant integration working, so I can tell Google Assistant to ‘warm up the car’, and Home Assistant toggles the A/C Climate conditioning switch, equivalent to starting the climate from the Volvo Cars app.

FWIW, I would also like to see the battery charge from Google Assistant, but that’s proving to be cumbersome as HA only exports temp and humidity sensors to Google Assistant.

I also encountered this “bug” and couldn’t stand seeing the mismatched units, so I did the same. In case you didn’t catch it, you’ll also need to convert the Average Fuel Consumption (reported as L/100km) and the Average Energy Consumption (reported as kWh/100km). After making the below updates my custom dashboard matches what’s in the Volvo Cars app.

Here’s what I have in my template.yaml:

- sensor:
    - name: "Lars - 2025 XC90 T8 Fuel Level Gallons"
      unique_id: "volvo_<VIN>_fuel_level_gallons"
      unit_of_measurement: "gal"
      state: "{{ (states('sensor.volvo_<VIN>_fuel_level') | float * 0.264172) | round(2) }}"
      availability: "{{ is_number(states('sensor.volvo_<VIN>_fuel_level')) }}"
      device_class: "volume_storage"

    - name: "Lars - 2025 XC90 T8 Average Fuel Consumption Gallons"
      unique_id: "volvo_<VIN>_average_fuel_consumption_gallons"
      unit_of_measurement: "mi/gal"
      state: "{{ (235.2145 / states('sensor.volvo_<VIN>_average_fuel_consumption') | float) | round(2) }}"
      availability: "{{ is_number(states('sensor.volvo_<VIN>_average_fuel_consumption')) }}"
      device_class: "volume"

    - name: "Lars - 2025 XC90 T8 Average Energy Consumption Miles"
      unique_id: "volvo_<VIN>_average_energy_consumption_miles"
      unit_of_measurement: "kWh/100mi"
      state: "{{ (states('sensor.volvo_<VIN>_average_energy_consumption') | float * 1.609344) | round(2) }}"
      availability: "{{ is_number(states('sensor.volvo_<VIN>_average_energy_consumption')) }}"
      device_class: "energy"

Is this a Volvo issue or an MQTT issue or a combination of the two? I suspect the actual measurements for these sensors are all done natively with metric values and then converted to US units. I just find it strange that most of the values are properly converted, but these 3 are still unchanged.

Hope this helps you, as i had the same issue.
Found the answer is go to developer > Actions.

MQTT publish and input the command and OTP code similar to the screenshot attached.

Fill in the topic with
volvoAAOS2mqtt/otp_code

Fill in the otp code in the payload section.

Hope this helps everyone.

Any fix for this?

I’m trying to get it up and running using docker. I think I passed the MQTT connection. But it fails the OTP.:

volvo2mqtt  | Dec 29 11:17:57 volvo2mqtt [1] - INFO: Starting volvo2mqtt version v1.10.5
volvo2mqtt  | Dec 29 11:17:57 volvo2mqtt [1] - INFO: Starting login with OTP
volvo2mqtt  | Traceback (most recent call last):
volvo2mqtt  |   File "/usr/local/lib/python3.9/urllib/request.py", line 1346, in do_open
volvo2mqtt  |     h.request(req.get_method(), req.selector, req.data, headers,
volvo2mqtt  |   File "/usr/local/lib/python3.9/http/client.py", line 1285, in request
volvo2mqtt  |     
volvo2mqtt  | self._send_request(method, url, body, headers, encode_chunked)
volvo2mqtt  |   File "/usr/local/lib/python3.9/http/client.py", line 1331, in _send_request
volvo2mqtt  |     self.endheaders(body, encode_chunked=encode_chunked)
volvo2mqtt  |   File "/usr/local/lib/python3.9/http/client.py", line 1280, in endheaders
volvo2mqtt  |     self._send_output(message_body, encode_chunked=encode_chunked)
volvo2mqtt  |   File "/usr/local/lib/python3.9/http/client.py", line 1040, in _send_output
volvo2mqtt  |     self.send(msg)
volvo2mqtt  |   File "/usr/local/lib/python3.9/http/client.py", line 980, in send
volvo2mqtt  |     self.connect()
volvo2mqtt  |   File "/usr/local/lib/python3.9/http/client.py", line 1447, in connect
volvo2mqtt  |     super().connect()
volvo2mqtt  |   File "/usr/local/lib/python3.9/http/client.py", line 946, in connect
volvo2mqtt  |     self.sock = self._create_connection(
volvo2mqtt  |   File "/usr/local/lib/python3.9/socket.py", line 835, in create_connection
volvo2mqtt  |     for res in getaddrinfo(host, port, 0, SOCK_STREAM):
volvo2mqtt  |   File "/usr/local/lib/python3.9/socket.py", line 966, in getaddrinfo
volvo2mqtt  |     for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
volvo2mqtt  | socket.gaierror: [Errno -3] Temporary failure in name resolution
volvo2mqtt  | 
volvo2mqtt  | During handling of the above exception, another exception occurred:
volvo2mqtt  | 
volvo2mqtt  | Traceback (most recent call last):
volvo2mqtt  |   File "/volvoAAOS2mqtt/./main.py", line 15, in <module>
volvo2mqtt  | 
volvo2mqtt  |     authorize()
volvo2mqtt  |   File "/volvoAAOS2mqtt/volvo.py", line 55, in authorize
volvo2mqtt  |     "User-Agent": "vca-android/" + util.get_volvo_app_version(),
volvo2mqtt  |   File "/volvoAAOS2mqtt/util.py", line 34, in get_volvo_app_version
volvo2mqtt  |     result = app(
volvo2mqtt  |   File "/usr/local/lib/python3.9/site-packages/google_play_scraper/features/app.py", line 15, in app
volvo2mqtt  |     dom = get(url)
volvo2mqtt  |   File "/usr/local/lib/python3.9/site-packages/google_play_scraper/utils/request.py", line 48, in get
volvo2mqtt  |     return _urlopen(url)
volvo2mqtt  |   File "/usr/local/lib/python3.9/site-packages/google_play_scraper/utils/request.py", line 17, in _urlopen
volvo2mqtt  |     resp = urlopen(obj)
volvo2mqtt  |   File "/usr/local/lib/python3.9/urllib/request.py", line 214, in urlopen
volvo2mqtt  |     return opener.open(url, data, timeout)
volvo2mqtt  |   File "/usr/local/lib/python3.9/urllib/request.py", line 517, in open
volvo2mqtt  |     response = self._open(req, data)
volvo2mqtt  |   File "/usr/local/lib/python3.9/urllib/request.py", line 534, in _open
volvo2mqtt  |     result = self._call_chain(self.handle_open, protocol, protocol +
volvo2mqtt  |   File "/usr/local/lib/python3.9/urllib/request.py", line 494, in _call_chain
volvo2mqtt  |     result = func(*args)
volvo2mqtt  |   File "/usr/local/lib/python3.9/urllib/request.py", line 1389, in https_open
volvo2mqtt  |     return self.do_open(http.client.HTTPSConnection, req,
volvo2mqtt  |   File "/usr/local/lib/python3.9/urllib/request.py", line 1349, in do_open
volvo2mqtt  |     raise URLError(err)
volvo2mqtt  | urllib.error.URLError
volvo2mqtt  | : <urlopen error [Errno -3] Temporary failure in name resolution>
volvo2mqtt exited with code 1

I think it fails in the function util.get_volvo_app_version(). I tried to look in the python code. But I do not understand what this function is trying to do. Seems that it is trying to get the app version from an android device in docker??? I hope somebody can help. Thank you in advance.

Ow I’m sorry, i think I had a local problem with the internet connection inside the docker. I think I solved it!

Did anyone hit into this issue. Integrations stopped working after 20th Dec.

Traceback (most recent call last):
  File "/volvoAAOS2mqtt/main.py", line 16, in <module>
    update_loop()
  File "/volvoAAOS2mqtt/mqtt.py", line 276, in update_loop
    create_ha_devices()
  File "/volvoAAOS2mqtt/mqtt.py", line 406, in create_ha_devices
    device = volvo.get_vehicle_details(vin)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/volvoAAOS2mqtt/volvo.py", line 346, in get_vehicle_details
    mqtt.send_car_images(vin, data, device)
  File "/volvoAAOS2mqtt/mqtt.py", line 114, in send_car_images
    response = requests.get(data["images"][data_path], headers=headers)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/site-packages/requests/api.py", line 73, in get
    return request("get", url, params=params, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/site-packages/requests/api.py", line 59, in request
    return session.request(method=method, url=url, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/site-packages/requests/sessions.py", line 575, in request
    prep = self.prepare_request(req)
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/site-packages/requests/sessions.py", line 484, in prepare_request
    p.prepare(
  File "/usr/lib/python3.12/site-packages/requests/models.py", line 367, in prepare
    self.prepare_url(url, params)
  File "/usr/lib/python3.12/site-packages/requests/models.py", line 438, in prepare_url
    raise MissingSchema(
requests.exceptions.MissingSchema: Invalid URL '': No scheme supplied. Perhaps you meant https://?

As of January 2 this project appears to be discontinued and archived on the GitHub site. Did I miss an announcement or something? I don’t recall hearing anything!

There’s a link to a custom integration (GitHub - thomasddn/ha-volvo-cars: Volvo Cars integration for Home Assistant) but I haven’t tried it yet. In the meantime, volvo2mqtt continues to work here just fine.

2 Likes