GithubHelp home page GithubHelp logo

dielee / volvo2mqtt Goto Github PK

View Code? Open in Web Editor NEW
127.0 18.0 25.0 420 KB

Home Assistant addon for connecting AAOS Volvos

License: MIT License

Dockerfile 1.41% Python 98.19% Shell 0.39%
home-assistant mqtt smarthome volvo volvocars

volvo2mqtt's Introduction

Volvo2Mqtt

Supports aarch64 Architecture Supports amd64 Architecture Supports armhf Architecture Supports armv7 Architecture Supports i386 Architecture
Project Maintenance GitHub Release GitHub Activity

This component establishes a connection between the newer AAOS Volvo cars and Home Assistant via MQTT.
Maybe this component works also with other Volvo cars. Please try out the native Volvo integration before using this component! If the native component doesn't work for your car, try this mqtt bridge.

Home Assistant thread can be found here.

Important note: The Volvo api currently ONLY works in these countries

If you like my work:
ko-fi

Confirmed working with

  • XC40 BEV (2024)
  • XC40 BEV (2023)
  • XC40 BEV (2022)
  • XC40 PHEV (2021)
  • V60 T8 PHEV (2023)
  • C40 BEV (2023)
  • C40 BEV (2022)
  • C40 BEV (2024)
  • XC90 T8 PHEV (2023)
  • XC60 PHEV (2024)
  • XC60 PHEV (2023)
  • XC60 PHEV (2022)
  • XC60 B5 Mildhybrid (2023)
  • XC90 PHEV T8 (2023)
  • XC90 PHEV T8 (2024)
  • XC90 B5 Mildhybrid (2024)
  • V90 PHEV T8 (2019)*
  • V90 PHEV T6 (2024)
  • V90 B5 Mildhybrid (2023)

*only partly working

Please let me know if your car works with this addon so I can expand the list!

Supported features

  • Lock/unlock car
  • Start/stop climate
  • Sensor "Battery Charge Level"
  • Sensor "Battery Capacity"
  • Sensor "Electric Range"
  • Sensor "Charging System Status"
  • Sensor "Charging Connection Status" (partly broken since 2.10 car update)
  • Sensor "Estimated Charging Finish Time"
  • Sensor "Door Lock Status (All doors, tank lid, and engine hood)"
  • Sensor "Window Lock Status (All windows and sunroof - Thanks to @navet)"
  • Sensor "Engine Status"
  • Sensor "Odometer"
  • Sensor "Tire Status"
  • Sensor "Fuel Status"
  • Sensor "Average Fuel Consumption"
  • Sensor "Average Speed"
  • Sensor "Distance to Empty"
  • Sensor "Hours to Service"
  • Sensor "Distance to Service"
  • Sensor "Months to Service"
  • Sensor "Service warning status"
  • Sensor "Service warning trigger"
  • Car Device Tracker
  • Multiple cars

NOTE: Energy status currently available only for cars in the Europe / Middle East / Africa regions. source

OTP Authentication

As of version v1.9.0, this addon uses the same OTP authentication as the Volvo app. The following steps are required for authentication in exactly this order:

  1. Setup volvo2Mqtt, either via Docker, or via HA addon (take a look at the "Setup" section below)

  2. Fill in your settings and start volvo2Mqtt

  3. Your log will show the following lines
    Waiting for otp code... Please check your mailbox and post your otp code to the following mqtt topic "volvoAAOS2mqtt/otp_code". Retry 0/15
    Waiting for otp code... Please check your mailbox and post your otp code to the following mqtt topic "volvoAAOS2mqtt/otp_code". Retry 1/15
    etc ...

  4. Now, open your mailbox and copy your OTP Code

  5. Open HomeAssistant and search for the entity ID text.volvo_otp

  6. Paste your OTP into the text entity and press Enter
    6a. (optional) If your OTP cannot be safed, try to paste your OTP code via MQTT to the following topic: volvoAAOS2mqtt/otp_code

    OTP Post Script

    1. Safe the following script in your script section
    2. Go to https://yourHAUrl/developer-tools/service
    3. Search for "Post Volvo OTP"
    4. Tick "OTP" and fill in your OTP
    5. Run this service

         alias: Post Volvo OTP
         sequence:
           - service: mqtt.publish
             metadata: {}
             data:
               topic: volvoAAOS2mqtt/otp_code
               payload: "{{ otp }}"
         mode: single
         fields:
           otp:
             selector:
               text: null
             name: OTP
             description: Volvo OTP
    
  7. If everything has worked, your addon is now authenticated. In the future, OTP authentication only needs to be done when updating, not when restarting the container.

Setup

Docker:

Just install this addon with the following command. Please note to fill in your settings inside the environment variables.

docker run -d --pull=always -e CONF_updateInterval=300 -e CONF_babelLocale='de' -e CONF_mqtt='@json {"broker": "", "username": "", "password": "", "port": 1883}' -e CONF_volvoData='@json {"username": "", "password": "", "vin": "", "vccapikey": ["key1", "key2"], "odometerMultiplier": 1, "averageSpeedDivider": 1, "averageFuelConsumptionMultiplier": 1}' -e TZ='Europe/Berlin' --name volvo2mqtt ghcr.io/dielee/volvo2mqtt:latest

HA Add-On:

Open your Home Assistant instance and show the add add-on repository dialog with a specific repository URL pre-filled.

Here is what every option means:

Environment Variable Name Type Json Option Default Description
CONF_updateInterval int required Update intervall in seconds.
CONF_babelLocale string required Select your country from this list. "Locale name" is the column you need!
CONF_mqtt json broker required Your MQTT Broker IP. Eg. 192.168.0.5.
CONF_mqtt json port 1883 Your MQTT Broker Port. If no value is given, port 1883 will be used.
CONF_mqtt json username optional MQTT Username for your broker.
CONF_mqtt json password optional MQTT Password for your broker.
CONF_volvoData json username required Normally your email address to login into the Volvo App.
CONF_volvoData json password required Your password to login into the Volvo App.
CONF_volvoData json vin optional A single VIN like "VIN1" or a list of VINs like "["VIN1", "VIN2"]". Leave this empty if you don't know your VIN. The addon will use every car that is tied to your account.
CONF_volvoData json vccapikey required VCCAPIKEY linked with your volvo developer account. Get your Vccapi key from here. Starting version 1.8.0, it is possible to define multiple keys, like this: ["vccapikey1", "vccapikey2", "vccapikey3", "etc..."]
CONF_volvoData json odometerMultiplier optional The multiplier value for the odometer value, as the volvo api delivers inconsistent data. For some cars this setting is 10, for some 1. Try what's right for your car. If you leave it empty, the multiplier will be 1.
CONF_volvoData json averageSpeedDivider optional The divider value for the average speed value, as the volvo api delivers inconsistent data. For some cars this setting is 10, for some 1. Try what's right for your car. If you leave it empty, the divider will be 1.
CONF_volvoData json averageFuelConsumptionMultiplier optional The multiplier value for the average fuel consumption value, as the volvo api delivers inconsistent data. For some cars this setting is 10, for some 1. Try what's right for your car. If you leave it empty, the multiplier will be 1.
CONF_debug string optional Debug option (true/false). Normally you don't need this.
TZ string required Container timezone eg "Europe/Berlin" from here

volvo2mqtt's People

Contributors

bogdanbujdea avatar dielee avatar elyara avatar gurtjun avatar hapu2000 avatar jverdeyen avatar marengaz avatar mkrzych avatar rustymage avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

volvo2mqtt's Issues

Volvo2mqtt terminates unexpectedly after ValueError: invalid literal for int() with base 10: '55.4'

Describe the bug
Volvo2mqtt terminates with the following error registered in the log.

Traceback (most recent call last):
File "/volvoAAOS2mqtt/main.py", line 13, in
authorize()
File "/volvoAAOS2mqtt/volvo.py", line 52, in authorize
check_supported_endpoints()
File "/volvoAAOS2mqtt/volvo.py", line 159, in check_supported_endpoints
state = api_call(entity["url"], "GET", vin, entity["id"])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/volvoAAOS2mqtt/volvo.py", line 250, in api_call
return parse_api_data(data, sensor_id)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/volvoAAOS2mqtt/volvo.py", line 372, in parse_api_data
fuel_amount = int(data["fuelAmount"]["value"])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ValueError: invalid literal for int() with base 10: '55.4'
s6-rc: info: service legacy-services: stopping
s6-rc: info: service legacy-services successfully stopped
s6-rc: info: service legacy-cont-init: stopping
s6-rc: info: service legacy-cont-init successfully stopped
s6-rc: info: service fix-attrs: stopping
s6-rc: info: service fix-attrs successfully stopped
s6-rc: info: service s6rc-oneshot-runner: stopping
s6-rc: info: service s6rc-oneshot-runner successfully stopped

To Reproduce:

Attempt to restart generates the same error.

Expected behavior:

The service should bee able to handle unexpected API responses and if not, restart according to the user watchdog preferences.

Screenshots:
N/A

Version info:

1.7.2 in HA Addon in hassio 2023.6.3

Logs:

},
"rearRightTyrePressure" : {
"name" : "rearRightTyrePressure",
"value" : "NORMAL",
"timestamp" : "2023-07-05T15:03:30Z"
},
"frontRightTyrePressure" : {
"name" : "frontRightTyrePressure",
"value" : "NORMAL",
"timestamp" : "2023-07-05T15:03:30Z"
},
"frontLeftTyrePressure" : {
"name" : "frontLeftTyrePressure",
"value" : "NORMAL",
"timestamp" : "2023-07-05T15:03:30Z"
}
}
}
Jul 05 18:19:42 volvo2mqtt [107] - INFO: Success! Tire Rear Left is supported by your vehicle.
Jul 05 18:19:42 volvo2mqtt [107] - DEBUG: Response status code: 200
Jul 05 18:19:42 volvo2mqtt [107] - DEBUG: {
"status" : 200,
"operationId" : "6078c11b-130e-43e9-9fb3-e48f0f111df6",
"data" : {
"rearLeftTyrePressure" : {
"name" : "rearLeftTyrePressure",
"value" : "NORMAL",
"timestamp" : "2023-07-05T15:03:30Z"
},
"rearRightTyrePressure" : {
"name" : "rearRightTyrePressure",
"value" : "NORMAL",
"timestamp" : "2023-07-05T15:03:30Z"
},
"frontRightTyrePressure" : {
"name" : "frontRightTyrePressure",
"value" : "NORMAL",
"timestamp" : "2023-07-05T15:03:30Z"
},
"frontLeftTyrePressure" : {
"name" : "frontLeftTyrePressure",
"value" : "NORMAL",
"timestamp" : "2023-07-05T15:03:30Z"
}
}
}
Jul 05 18:19:42 volvo2mqtt [107] - INFO: Success! Tire Rear Right is supported by your vehicle.
Jul 05 18:19:42 volvo2mqtt [107] - DEBUG: Starting GET call against https://api.volvocars.com/connected-vehicle/v2/vehicles/{0}/engine-status
Jul 05 18:19:42 volvo2mqtt [107] - DEBUG: https://api.volvocars.com:443 "GET /connected-vehicle/v2/vehicles//engine-status HTTP/1.1" 200 226
Jul 05 18:19:42 volvo2mqtt [107] - DEBUG: Response status code: 200
Jul 05 18:19:42 volvo2mqtt [107] - DEBUG: {
"status" : 200,
"operationId" : "25b3c403-5eb8-4d09-bf15-d756f5f01596",
"data" : {
"engineRunning" : {
"name" : "engineRunning",
"value" : "false",
"timestamp" : "1970-01-01T00:00:00Z"
}
}
}
Jul 05 18:19:42 volvo2mqtt [107] - INFO: Success! Engine State is supported by your vehicle.
Jul 05 18:19:42 volvo2mqtt [107] - DEBUG: Starting GET call against https://api.volvocars.com/connected-vehicle/v2/vehicles/{0}/fuel
Jul 05 18:19:43 volvo2mqtt [107] - DEBUG: https://api.volvocars.com:443 "GET /connected-vehicle/v2/vehicles/
/fuel HTTP/1.1" 200 244
Jul 05 18:19:43 volvo2mqtt [107] - DEBUG: Response status code: 200
Traceback (most recent call last):
File "/volvoAAOS2mqtt/main.py", line 13, in
Jul 05 18:19:43 volvo2mqtt [107] - DEBUG: {
"status" : 200,
"operationId" : "809b848e-468c-4610-a045-89d05a0605ee",
"data" : {
"fuelAmount" : {
"name" : "fuelAmount",
"value" : "55.4",
"unit" : "liters",
"timestamp" : "2023-07-05T15:03:30Z"
}
}
}
authorize()
File "/volvoAAOS2mqtt/volvo.py", line 52, in authorize
check_supported_endpoints()
File "/volvoAAOS2mqtt/volvo.py", line 159, in check_supported_endpoints
state = api_call(entity["url"], "GET", vin, entity["id"])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/volvoAAOS2mqtt/volvo.py", line 250, in api_call
return parse_api_data(data, sensor_id)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/volvoAAOS2mqtt/volvo.py", line 372, in parse_api_data
fuel_amount = int(data["fuelAmount"]["value"])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ValueError: invalid literal for int() with base 10: '55.4'
s6-rc: info: service legacy-services: stopping
s6-rc: info: service legacy-services successfully stopped
s6-rc: info: service legacy-cont-init: stopping
s6-rc: info: service legacy-cont-init successfully stopped
s6-rc: info: service fix-attrs: stopping
s6-rc: info: service fix-attrs successfully stopped
s6-rc: info: service s6rc-oneshot-runner: stopping
s6-rc: info: service s6rc-oneshot-runner successfully stopped

Add more sensors

Great work! If it is possible I would like even more sensors added:

Current GPS position
kWh consumption
Last trip (from where to where, GPS coordinates)
Odometer
Lock status as a sensor
Door and window sensors (open or closed)

urllib3.exceptions.ReadTimeoutError: HTTPSConnectionPool(host='api.volvocars.com', port=443): Read timed out. (read timeout=15)

Describe the bug

Mqtt update done. Next run in 120 seconds.
Sending mqtt update...
Starting GET call against https://api.volvocars.com/energy/v1/vehicles/{0}/recharge-status
Starting GET call against https://api.volvocars.com/connected-vehicle/v2/vehicles/{0}/odometer
Starting GET call against https://api.volvocars.com/connected-vehicle/v2/vehicles/{0}/windows
Starting GET call against https://api.volvocars.com/connected-vehicle/v2/vehicles/{0}/doors
Traceback (most recent call last):
File "/usr/lib/python3.11/site-packages/urllib3/connectionpool.py", line 466, in _make_request
six.raise_from(e, None)
File "", line 3, in raise_from
File "/usr/lib/python3.11/site-packages/urllib3/connectionpool.py", line 461, in _make_request
httplib_response = conn.getresponse()
^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/http/client.py", line 1378, in getresponse
response.begin()
File "/usr/lib/python3.11/http/client.py", line 318, in begin
version, status, reason = self._read_status()
^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/http/client.py", line 279, in _read_status
line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1")
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/socket.py", line 706, in readinto
return self._sock.recv_into(b)
^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/ssl.py", line 1278, in recv_into
return self.read(nbytes, buffer)
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/ssl.py", line 1134, in read
return self._sslobj.read(len, buffer)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TimeoutError: The read operation timed out
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/lib/python3.11/site-packages/requests/adapters.py", line 487, in send
resp = conn.urlopen(
^^^^^^^^^^^^^
File "/usr/lib/python3.11/site-packages/urllib3/connectionpool.py", line 798, in urlopen
retries = retries.increment(
^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/site-packages/urllib3/util/retry.py", line 550, in increment
raise six.reraise(type(error), error, _stacktrace)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/site-packages/urllib3/packages/six.py", line 770, in reraise
raise value
File "/usr/lib/python3.11/site-packages/urllib3/connectionpool.py", line 714, in urlopen
httplib_response = self._make_request(
^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/site-packages/urllib3/connectionpool.py", line 468, in _make_request
self._raise_timeout(err=e, url=url, timeout_value=read_timeout)
File "/usr/lib/python3.11/site-packages/urllib3/connectionpool.py", line 357, in _raise_timeout
raise ReadTimeoutError(
urllib3.exceptions.ReadTimeoutError: HTTPSConnectionPool(host='api.volvocars.com', port=443): Read timed out. (read timeout=15)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/volvoAAOS2mqtt/./main.py", line 9, in
update_loop()
File "/volvoAAOS2mqtt/mqtt.py", line 86, in update_loop
update_car_data()
File "/volvoAAOS2mqtt/mqtt.py", line 104, in update_car_data
state = volvo.api_call(entity["url"], "GET", vin, entity["id"], force_update)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/volvoAAOS2mqtt/volvo.py", line 186, in api_call
response = pull_door_api(url, method, vin, force_update)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/volvoAAOS2mqtt/volvo.py", line 249, in pull_door_api
response = session.get(url.format(vin), timeout=15)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/site-packages/requests/sessions.py", line 600, in get
return self.request("GET", url, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/site-packages/requests/sessions.py", line 587, in request
resp = self.send(prep, **send_kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/site-packages/requests/sessions.py", line 701, in send
r = adapter.send(request, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/site-packages/requests/adapters.py", line 533, in send
raise ReadTimeout(e, request=request)
requests.exceptions.ReadTimeout: HTTPSConnectionPool(host='api.volvocars.com', port=443): Read timed out. (read timeout=15)
s6-rc: info: service legacy-services: stopping
s6-rc: info: service legacy-services successfully stopped
s6-rc: info: service legacy-cont-init: stopping
s6-rc: info: service legacy-cont-init successfully stopped
s6-rc: info: service fix-attrs: stopping
s6-rc: info: service fix-attrs successfully stopped
s6-rc: info: service s6rc-oneshot-runner: stopping
s6-rc: info: service s6rc-oneshot-runner successfully stopped

To Reproduce
It suddenly happened during one of the HTTP calls to the Volvo API.

Expected behavior
Sometimes a request can fail, but maybe it is better to just keep the previous data in HA and try to do a new request on the defined interval (via configuration). Now the application crashed completely.

Cannot start add-on, nor save config since 1.7

Describe the bug
Cannot start add-on, nor save config. Getting the error "not a valid value"

To Reproduce
Using config that worked with v1.6.4
Updated to 1.7.0/1.7.1
Cannot start add-on

When I try to save the config:
Failed to save add-on configuration, not a valid value. Got {'updateInterval': 300, 'babelLocale': 'en_GB', 'TZ': 'Europe/London', 'debug': False, 'mqtt': {'broker': '192.168.xxx.xxx', 'port': 1883, 'username': 'xxxxx', 'password': 'xxxxx'}, 'volvoData': {'username': 'xxxxx', 'password': 'xxxxx', 'vin': '', 'vccapikey': xxxxx', 'odometerMultiplier': 10, 'averageSpeedDivider': 1, 'averageFuelConsumptionMultiplier': 1}}

KeyError: 'batteryChargeLevel'

Hi @Dielee! Thank you for this add-on, months of waiting has finally ended!

There is an issue though:
When I run it with my 2022 C40, I get this error:

Traceback (most recent call last):
  File "C:\Users\user\volvo2mqtt\main.py", line 7, in <module>
    update_loop()
  File "C:\Users\user\volvo2mqtt\mqtt.py", line 76, in update_loop
    update_car_data()
  File "C:\Users\user\volvo2mqtt\mqtt.py", line 105, in update_car_data
    state = volvo.api_call(sensor["url"], "GET", sensor["id"])
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\user\volvo2mqtt\volvo.py", line 150, in api_call
    return data["data"]["batteryChargeLevel"]["value"]
           ~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^
KeyError: 'batteryChargeLevel'

and I look into the data and:

{'status': 200, 'operationId': '-------------------------', 'data': {}} (I redacted the operation ID)

Let me know if you need any more info from me!

Edit: Upon further investigation, it seems all energy API endpoints for my car don't work :/

vccapikey error

when i want to install the docker i get this error:

File "/usr/local/lib/python3.9/site-packages/dynaconf/vendor/box/box.py", line 162, in getitem
raise BoxKeyError(str(E)) from _A
dynaconf.vendor.box.exceptions.BoxKeyError: "'vccapikey'"

2023 XC90 B6 - Missing sensors - USA

I am missing:
Sensor "Engine Status"
Sensor "Odometer"
Sensor "Fuel Status"
Sensor "Average Fuel Consumption"
Sensor "Average Speed"
and
Car Device Tracker shows unknown.

Is this expected with an 2023 XC90 B6, a misconfiguration, or a bug?

Add HAOS Addon - testers needed!

As I don't have any HA OS instances, I can't test the add-on.
Maybe someone could help me test the add-on ?
Please comment if you are able to help.

Extended vehicle API resources

Can you please add the Extended vehicle API resources for the non electric mild hybrids with AAOS, with the distance to empty and other resources. Thnx.

Charging system status description

The Charging system status is showing the correct state when my C40 is charging (Charging) or charging reached the charge limit of 90% (Idle). After disconnecting the charging cable the state changes to Unspecified. Can this state description be changed in to for example Disconnected?

Error max retry;s

I am getting below in the logs and the docker wil not start.
is it possible that there is a limit on how much conections you have to the volvo api ?

requests.exceptions.ConnectionError: HTTPSConnectionPool(host='volvoid.eu.volvocars.com', port=443): Max retries exceeded with url: /as/token.oauth2 (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x7f18abe16bb0>: Failed to establish a new connection: [Errno -3] Temporary failure in name resolution'))

Entities become unavailable after HA restart

Describe the bug
When I restart HA, all the entities become unavailable and the add on doesn't update anymore even though it is started.

If I restart the add on manually after the HA restart, things work as they should again.

To Reproduce
Restart HA.

Expected behavior
The add on should work as normal.

Screenshots
If applicable, add screenshots to help explain your problem.

Version info
1.4.4

Additional context
Add any other context about the problem here.

Update to core_2023.6.2

Hi,

Just for your information, I updated to the core_2023.6.2 and the addon seems completly desconnected from the API

Captura de pantalla 2023-06-24 085152

2023-06-24 07:51:41: Saving in-memory database to /data//mosquitto.db.
2023-06-24 07:52:49: New connection from 172.30.32.2:34174 on port 1883.
2023-06-24 07:52:49: Client closed its connection.
2023-06-24 07:54:49: New connection from 172.30.32.2:55064 on port 1883.
2023-06-24 07:54:49: Client closed its connection.
2023-06-24 07:56:49: New connection from 172.30.32.2:43838 on port 1883.
2023-06-24 07:56:49: Client closed its connection.
2023-06-24 07:58:49: New connection from 172.30.32.2:32808 on port 1883.
2023-06-24 07:58:49: Client closed its connection.
2023-06-24 08:00:49: New connection from 172.30.32.2:34262 on port 1883.
2023-06-24 08:00:49: Client closed its connection.
2023-06-24 08:02:49: New connection from 172.30.32.2:34982 on port 1883.
2023-06-24 08:02:49: Client closed its connection.
2023-06-24 08:04:49: New connection from 172.30.32.2:59732 on port 1883.
2023-06-24 08:04:49: Client closed its connection.
2023-06-24 08:08:49: New connection from 172.30.32.2:50556 on port 1883.
2023-06-24 08:08:49: Client closed its connection.
2023-06-24 08:10:49: New connection from 172.30.32.2:51658 on port 1883.
2023-06-24 08:10:49: Client closed its connection.
2023-06-24 08:11:27: Client XXXXXXXXXXXXXXXXXXXXXX closed its connection.
2023-06-24 08:12:09: New connection from 172.30.32.1:52131 on port 1883.
2023-06-24 08:12:09: New client connected from 172.30.32.1:52131 as XXXXXXXXXXXXXXXXXXXXXX (p2, c1, k60, u'homeassistant').
2023-06-24 08:12:49: New connection from 172.30.32.2:46692 on port 1883.
2023-06-24 08:12:49: Client closed its connection.
2023-06-24 08:14:49: New connection from 172.30.32.2:46074 on port 1883.

Kind regards!

MQTT Values outside homeassistant and levels in MQTT

It would be nice, to use outside homeassistant, if you could split the mqtt data to homeassistant auto discovery and the data with an separate naming in mqtt and the values in a separate level.

NOW:

homeassistant/
     sensor/
           volvoAAOS2mqtt/ --> Autodiscovery
           VIN1_charging_system_status
           VIN1_battery_charge_level
           VIN1_estimated_charging_time
           VIN2_charging_system_status
           VIN2_battery_charge_level
           VIN2_estimated_charging_time
      switch/
           volvoAAOS2mqtt/ --> Autodiscovery
           VIN1_climate_status/
                 state
           VIN2_climate_status/
                 state

suggestion:

homeassistant/sensor/volvoAAOS2mqtt/ --> Autodiscovery
volvoAAOS2mqtt/
        VIN1/
           sensor/
                charging_system_status
                battery_charge_level
                estimated_charging_time
           switch/
                climate_status
                       state
        VIN2/
           sensor/
                charging_system_status
                battery_charge_level
                estimated_charging_time
           switch/
                climate_status
                       state

RasPi build?

Hey, thanks for the extension. I would like to ask if you could build an arm/v7 version of the image to be run on a Raspberry Pi 4. That's where my Home Assistant is running.

Thank you very much!

Volvo2mqtt terminates unexpectedly

Describe the bug
Volvo2mqtt terminates with the following error registered in the log.
image

To Reproduce:

new start of the server gets actual every time the same error
Login and API Key is still working
You wrote i should open a bug
it seems to be the same issue like
home-assistant/core#61785

Expected behavior:

Version info:

HA 2023.6.3 in a docker container
volvo2mqtt 1.7.2 in a docker container
MQTT (Mosquito 2.0.15) in a docker container
CAR = VOLVO XC 60 PHEV 2022 early

Logs:

No data returned when charging system has error

Describe the bug
Fails to start when charging returns error. Noticed since yesterday when cable not connected correctly. After replacing cable restarted container and now ok.

To Reproduce:

  1. Part connect cable
  2. Restart docker container

Expected behavior:

start up and show
Screenshots:

If applicable, add screenshots to help explain your problem.

Version info:

The version you are using and the method you are using (Docker container/HA Addon/Cloned repo)

Logs:

Jul 06 08:58:16 volvo2mqtt [1] - INFO: Starting volvo2mqtt version v1.7.3
Jul 06 08:58:17 volvo2mqtt [1] - INFO: Vin: ['XXXXXXXXXXXXXXXXXX'] found!
Jul 06 08:58:17 volvo2mqtt [1] - INFO: Success! Battery Charge Level is supported by your vehicle.
Jul 06 08:58:17 volvo2mqtt [1] - INFO: Success! Electric Range is supported by your vehicle.
Jul 06 08:58:17 volvo2mqtt [1] - INFO: Success! Estimated Charging Time is supported by your vehicle.
Jul 06 08:58:17 volvo2mqtt [1] - INFO: Success! Charging System Status is supported by your vehicle.
Traceback (most recent call last):
File "/volvoAAOS2mqtt/./main.py", line 13, in
authorize()
File "/volvoAAOS2mqtt/volvo.py", line 52, in authorize
check_supported_endpoints()
File "/volvoAAOS2mqtt/volvo.py", line 159, in check_supported_endpoints
state = api_call(entity["url"], "GET", vin, entity["id"])
File "/volvoAAOS2mqtt/volvo.py", line 250, in api_call
return parse_api_data(data, sensor_id)
File "/volvoAAOS2mqtt/volvo.py", line 297, in parse_api_data
return charging_connection_states[data["chargingConnectionStatus"]["value"]]
KeyError: 'CONNECTION_STATUS_FAULT'

Add new entities

What would be interesting is to have additional entities:

all windows are closed
all doors including the tailgate are closed.
average fuel consumption.

sunroof opened or closed

After that, having the option of remotely closing the windows and sunroof ... but that's not possible :)

Need a property for average speed - off by a power of 10

Describe the bug
My average speed is 283 km/h. That's really fast ... :) In reality it's 28.3 km/h.

To Reproduce
The API is delivering 283.

Expected behavior
Should be 28.3.

Screenshots
If applicable, add screenshots to help explain your problem.

Version info
1.5.4.

Additional context
We need a property where you can specify divider.

Distance to Empty : Unable to adjust value

The "Distance to Empty" entity does not display the correct value and cannot be adjusted using the "odometerMultiplier" parameter.

For example, the real value should be 40km, but "Distance to Empty" shows me 40000km.
I therefore need to set "odometerMultiplier" to 0.001 to obtain 40km (40000 x 0.001 = 40).

Problem : It seems impossible to set a comma value in VolvoToMqtt configuration.
odometerMultiplier: 0**.001 or odometerMultiplier: 0,**001

Thank you

Add-on crashes because of fuelAmount conversion to int

I have a Volvo XC60 2023 T8 and the integration was working before I updated from 1.6.5 to latest. It seems the fuel amount should not be an int, but a double/float (I'm not familiar with Python types, sorry)

Jul 06 00:01:30 volvo2mqtt [106] - INFO: Success! Engine State is supported by your vehicle.
Traceback (most recent call last):
File "/volvoAAOS2mqtt/main.py", line 13, in
authorize()
File "/volvoAAOS2mqtt/volvo.py", line 52, in authorize
check_supported_endpoints()
File "/volvoAAOS2mqtt/volvo.py", line 159, in check_supported_endpoints
state = api_call(entity["url"], "GET", vin, entity["id"])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/volvoAAOS2mqtt/volvo.py", line 250, in api_call
return parse_api_data(data, sensor_id)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/volvoAAOS2mqtt/volvo.py", line 372, in parse_api_data
fuel_amount = int(data["fuelAmount"]["value"])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ValueError: invalid literal for int() with base 10: '17.8'

Failed to start after update to 1.7.2

Describe the bug
Add on fails to start after update to 1.7.2. no other changes.
Error is "Go to configuration
not a valid value."
To Reproduce:

Steps to reproduce the behavior:
Start the add-on
Error "Go to configuration not a valid value."

Expected behavior:

Add-on should start

Log
Failed to save add-on configuration, not a valid value. Got {'updateInterval': 300, 'babelLocale': 'en_GB', 'TZ': 'Europe/London', 'debug': True, 'mqtt': {'broker': '192.168.0.Xx', 'port': 1883, 'username': 'xxxxx', 'password': 'xxxxxx'}, 'volvoData': {'username': '[email protected]', 'password': 'xxxxxxx', 'vin': '', 'vccapikey': 'xxxxxxxxxx', 'odometerMultiplier': 10, 'averageSpeedDivider': 1, 'averageFuelConsumptionMultiplier': 1}}

Mqtt port other than 1883

I canโ€™t connect to broker on port 1888.

Describe the solution you'd like
Either a colon separated host:port solution or add a โ€portโ€ element to the JSON config.

Getting Odometer Crashing

Some cars dont return odometer information, crashing the application:

Starting GET call against https://api.volvocars.com/connected-vehicle/v2/vehicles/{0}/odometer
Traceback (most recent call last):
  File "/volvoAAOS2mqtt/./main.py", line 9, in <module>
    update_loop()
  File "/volvoAAOS2mqtt/mqtt.py", line 84, in update_loop
    update_car_data()
  File "/volvoAAOS2mqtt/mqtt.py", line 122, in update_car_data
    state = volvo.api_call(sensor["url"], "GET", vin, sensor["id"], force_update)
  File "/volvoAAOS2mqtt/volvo.py", line 183, in api_call
    return parse_api_data(data, sensor_id)
  File "/volvoAAOS2mqtt/volvo.py", line 288, in parse_api_data
    return data["data"]["odometer"]["value"]
KeyError: 'odometer'

In my case XC60 23 - (Brazil), the data field return an empty array. It would be nice to check the response.

HA - Babel Locale bug?

When trying to set Babel locale = no_NO (as stated on https://www.ibm.com/docs/en/radfws/9.7?topic=overview-locales-code-pages-supported for Norway), the addon fails to start with error:

Traceback (most recent call last):
  File "/volvoAAOS2mqtt/./main.py", line 9, in <module>
    update_loop()
  File "/volvoAAOS2mqtt/mqtt.py", line 84, in update_loop
    update_car_data()
  File "/volvoAAOS2mqtt/mqtt.py", line 91, in update_car_data
    last_data_update = format_datetime(datetime.now(), format="medium", locale=settings["babelLocale"])
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/babel/dates.py", line 719, in format_datetime
    locale = Locale.parse(locale)
             ^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/babel/core.py", line 391, in parse
    raise UnknownLocaleError(input_id)
babel.core.UnknownLocaleError: unknown locale 'no_NO'

Setting it to en_GB works

Multiple Cars: Air Conditioning Switch turn both cars on

I'Ve got 2 cars, if I put the AC in one car on, the switch gets activated in the other one, too.

Starting GET call against https://api.volvocars.com/connected-vehicle/v2/vehicles/{0}/doors
Starting POST call against https://api.volvocars.com/connected-vehicle/v2/vehicles/{0}/commands/climatization-start
Starting GET call against https://api.volvocars.com/connected-vehicle/v2/vehicles/{0}/doors
Starting GET call against https://api.volvocars.com/connected-vehicle/v2/vehicles/{0}/doors

image

Charge scheduling

The recent 2.10 update has added charge scheduling, which despite what the release notes say, also seem to work on a 2023 V60 T8 Recharge.

Is there a way we can integrate this? Automating when it can charge is obviously where we want to be.

If you can give me some pointers on where to look, I'll happily help figure this out / help build it (though the Home Assistant internals are unknown territory for me).

PS: Thanks for this brilliant project!

Lock icon is static - can it open/close with state?

Unlike other MQTT locks I have (via zigbee2mqtt), the Home Assistant icon for the Volvo lock state is static - it doesn't open or close according to the state.

Is this something that can be updated in this project, or is it an issue with some other part of the ecosystem?

Ideally, the icon would be mdi:lock when locked, and mdi:lock-open when unlocked.

Weird dates

First of all, I can confirm this is working on a Volvo V60 T8 Polestar Engineered (2023)! So kudos for that!

The only thing that is a bit weird are the dates that I see on mqtt/HA:

image

Do you perhaps have an idea what could be causing this? I'm located in Belgium.

I use the following docker command to run:

docker run -d --restart unless-stopped --pull=always -e CONF_updateInterval=60 -e CONF_babelLocale='be' -e CONF_mqtt='@json {"broker": "xxx", "username": "xxx", "password": "xxx"}' -e CONF_volvoData='@json {"username": "xxx", "password": "xxx", "vin": "xxx", "vccapikey": "xxx"}' -e TZ='Europe/Brussels' --name volvo2mqtt ghcr.io/dielee/volvo2mqtt:latest

Bug ?

It looks like some of the sensors are not updated for a Volvo V90 T8
image

If I look at the Volvo On Call integration in Home Assistant, these sensors are updated...
image
image

UTC time is shown as local time

Describe the bug
The estimated charging finish time shown is UTC and not local time.

To Reproduce
Steps to reproduce the behavior:

  1. Start charging the car.
  2. Examine the sensor.estimated_charging_finish_time entity
  3. It will show the time in UTC rather than the local time.

Expected behavior
The time should be shown as local time.

Screenshots
N/A

Version info
hassio 2023.6.3

Additional context
Additional info can be supplied on request as well as testing if nessecary.

HA Add-on crashes

Describe the bug
After some hours the add-on crashes

error log in add-one

Error getting data: HTTPSConnectionPool(host='api.volvocars.com', port=443): Max retries exceeded with url: /location/v1/vehicles/******************/location (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x7fb9d78c50>: Failed to establish a new connection: [Errno -3] Try again'))
Starting GET call against https://api.volvocars.com/connected-vehicle/v2/vehicles/{0}/tyres
Error getting data: HTTPSConnectionPool(host='api.volvocars.com', port=443): Max retries exceeded with url: /connected-vehicle/v2/vehicles/******************/tyres (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x7fb9d802d0>: Failed to establish a new connection: [Errno -3] Try again'))
Starting GET call against https://api.volvocars.com/connected-vehicle/v2/vehicles/{0}/tyres
Error getting data: HTTPSConnectionPool(host='api.volvocars.com', port=443): Max retries exceeded with url: /connected-vehicle/v2/vehicles/******************/tyres (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x7fb9d7ba90>: Failed to establish a new connection: [Errno -3] Try again'))
Starting GET call against https://api.volvocars.com/connected-vehicle/v2/vehicles/{0}/tyres
Error getting data: HTTPSConnectionPool(host='api.volvocars.com', port=443): Max retries exceeded with url: /connected-vehicle/v2/vehicles/******************/tyres (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x7fb9d74ad0>: Failed to establish a new connection: [Errno -3] Try again'))
Starting GET call against https://api.volvocars.com/connected-vehicle/v2/vehicles/{0}/tyres
Error getting data: HTTPSConnectionPool(host='api.volvocars.com', port=443): Max retries exceeded with url: /connected-vehicle/v2/vehicles/******************/tyres (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x7fb9d78850>: Failed to establish a new connection: [Errno -3] Try again'))
Starting GET call against https://api.volvocars.com/connected-vehicle/v2/vehicles/{0}/engine-status
Error getting data: HTTPSConnectionPool(host='api.volvocars.com', port=443): Max retries exceeded with url: /connected-vehicle/v2/vehicles/******************/engine-status (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x7fb9d7abd0>: Failed to establish a new connection: [Errno -3] Try again'))
Starting GET call against https://api.volvocars.com/connected-vehicle/v2/vehicles/{0}/fuel
Error getting data: HTTPSConnectionPool(host='api.volvocars.com', port=443): Max retries exceeded with url: /connected-vehicle/v2/vehicles/******************/fuel (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x7fb9d77350>: Failed to establish a new connection: [Errno -3] Try again'))
Starting GET call against https://api.volvocars.com/connected-vehicle/v2/vehicles/{0}/statistics
Error getting data: HTTPSConnectionPool(host='api.volvocars.com', port=443): Max retries exceeded with url: /connected-vehicle/v2/vehicles/******************/statistics (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x7fb9d74ad0>: Failed to establish a new connection: [Errno -3] Try again'))
Starting GET call against https://api.volvocars.com/connected-vehicle/v2/vehicles/{0}/statistics
Error getting data: HTTPSConnectionPool(host='api.volvocars.com', port=443): Max retries exceeded with url: /connected-vehicle/v2/vehicles/******************/statistics (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x7fb9d791d0>: Failed to establish a new connection: [Errno -3] Try again'))
Mqtt update done. Next run in 300 seconds.
Sending mqtt update...
Refreshing credentials
Traceback (most recent call last):
  File "/usr/lib/python3.11/site-packages/urllib3/connection.py", line 174, in _new_conn
    conn = connection.create_connection(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/urllib3/util/connection.py", line 72, in create_connection
    for res in socket.getaddrinfo(host, port, family, socket.SOCK_STREAM):
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/socket.py", line 962, in getaddrinfo
    for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
socket.gaierror: [Errno -3] Try again
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "/usr/lib/python3.11/site-packages/urllib3/connectionpool.py", line 714, in urlopen
    httplib_response = self._make_request(
                       ^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/urllib3/connectionpool.py", line 403, in _make_request
    self._validate_conn(conn)
  File "/usr/lib/python3.11/site-packages/urllib3/connectionpool.py", line 1053, in _validate_conn
    conn.connect()
  File "/usr/lib/python3.11/site-packages/urllib3/connection.py", line 363, in connect
    self.sock = conn = self._new_conn()
                       ^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/urllib3/connection.py", line 186, in _new_conn
    raise NewConnectionError(
urllib3.exceptions.NewConnectionError: <urllib3.connection.HTTPSConnection object at 0x7fba526250>: Failed to establish a new connection: [Errno -3] Try again
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "/usr/lib/python3.11/site-packages/requests/adapters.py", line 487, in send
    resp = conn.urlopen(
           ^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/urllib3/connectionpool.py", line 798, in urlopen
    retries = retries.increment(
              ^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/urllib3/util/retry.py", line 592, in increment
    raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='volvoid.eu.volvocars.com', port=443): Max retries exceeded with url: /as/token.oauth2 (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x7fba526250>: Failed to establish a new connection: [Errno -3] Try again'))
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "/volvoAAOS2mqtt/./main.py", line 11, in <module>
    update_loop()
  File "/volvoAAOS2mqtt/mqtt.py", line 96, in update_loop
    update_car_data()
  File "/volvoAAOS2mqtt/mqtt.py", line 125, in update_car_data
    state = volvo.api_call(entity["url"], "GET", vin, entity["id"], force_update)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/volvoAAOS2mqtt/volvo.py", line 172, in api_call
    refresh_auth()
  File "/volvoAAOS2mqtt/volvo.py", line 68, in refresh_auth
    auth = requests.post(OAUTH_URL, data=body, headers=headers)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/requests/api.py", line 115, in post
    return request("post", url, data=data, json=json, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/requests/api.py", line 59, in request
    return session.request(method=method, url=url, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/requests/sessions.py", line 587, in request
    resp = self.send(prep, **send_kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/requests/sessions.py", line 701, in send
    r = adapter.send(request, **kwargs)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/requests/adapters.py", line 520, in send
    raise ConnectionError(e, request=request)
requests.exceptions.ConnectionError: HTTPSConnectionPool(host='volvoid.eu.volvocars.com', port=443): Max retries exceeded with url: /as/token.oauth2 (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x7fba526250>: Failed to establish a new connection: [Errno -3] Try again'))
s6-rc: info: service legacy-services: stopping
s6-rc: info: service legacy-services successfully stopped
s6-rc: info: service legacy-cont-init: stopping
s6-rc: info: service legacy-cont-init successfully stopped
s6-rc: info: service fix-attrs: stopping
s6-rc: info: service fix-attrs successfully stopped
s6-rc: info: service s6rc-oneshot-runner: stopping
s6-rc: info: service s6rc-oneshot-runner successfully stopped

Version info
1.6.0

ODO shows just first 4 digits

Hi @Dielee , thanks for this add-on!
Everything works fine on my '22 XC60 except for the ODO value - it shows only the first 4 digits (e.g. the distance is 12345 and 1234 is presented). I tried to find any config issues, no luck.

Cheers

Speed, range and odometer in miles

Is your feature request related to a problem? Please describe.
I live in a silly country that uses miles instead of kilometres

Describe the solution you'd like
An option to specify the units as imperial would be fantastic (for speed, range and odometer)

Describe alternatives you've considered
I could create my own sensors to piggyback off yours.

Additional context
I'm using the add-on

Can not create container

I can not deploy. When I try to run docker run getting the following error:
latest: Pulling from dielee/volvo2mqtt
Digest: sha256:d471b459c12cbc9daf5235610ghtrr2d23a2dbe2ae2d9e7234ce9e5b9499301
Status: Image is up to date for ghcr.io/dielee/volvo2mqtt:latest
Starting volvo2mqtt version v1.2.2
Vin: ['YV1UZBFVDxxxxxxxxx'] found!
Traceback (most recent call last):
File "/volvoAAOS2mqtt/./main.py", line 8, in
connect()
File "/volvoAAOS2mqtt/mqtt.py", line 26, in connect
client.connect(settings["mqtt"]["broker"])
File "/usr/local/lib/python3.9/site-packages/paho/mqtt/client.py", line 914, in connect
return self.reconnect()
File "/usr/local/lib/python3.9/site-packages/paho/mqtt/client.py", line 1044, in reconnect
sock = self._create_socket_connection()
File "/usr/local/lib/python3.9/site-packages/paho/mqtt/client.py", line 3685, in _create_socket_connection
return socket.create_connection(addr, timeout=self._connect_timeout, source_address=source)
File "/usr/local/lib/python3.9/socket.py", line 823, in create_connection
for res in getaddrinfo(host, port, 0, SOCK_STREAM):
File "/usr/local/lib/python3.9/socket.py", line 954, in getaddrinfo
for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
socket.gaierror: [Errno -2] Name or service not known

Add-on stops itself after 30 seconds.

Hi,
Thank you for all your development so far on this!

I can't seem to get mine set up, I assume I have done something wrong on my end. The service initial finds my VIN number and says it can read a couple of things, but then stops after a short amount of time.

Any help you be greatly appreciated!

Unknown states since v1.5.2

Describe the bug
I'm seeing a lot of unknown fields since (I guess) v1.5.2 update in HASS.
Should I reset or remove some fields in my MQTT broker? Or is this volvo2mqtt related?

To Reproduce
Steps to reproduce the behavior:

  1. Install a version lower than v1.5.2
  2. Update fields - all fields are filled in
  3. Install version v1.5.2 or later
  4. Update fields - some fields are unknown

Expected behavior
Field should still be as before v1.5.2

Screenshots
image

Version info
Docker container which published on a mqtt broker (mosquitte) available for MQTT HA plugin

Additional context
It 'used' to work as expected. Sensors renaming seems to be the issue.

Thanks!

Error with mutiple cars

          Something is still wrong :-(

PS: I could not reopen the ticket

If I run the command with empty vin it's just running once and getting an error. If I put both vins in the command ( "vin": ["VIN1", "VIN2"]) it's the same

root@vm-docker:/data/docker/volvo2mqtt# docker run --rm=true  --pull=always -e CONF_updateInterval=30 -e CONF_babelLocale='de' -e CONF_mqtt='@json {"broker": "", "username": "", "password": ""}' -e CONF_volvoData='@json {"username": "XXXX", "password": "XXXX", "vin": "", "vccapikey": "XXXX"}' -e TZ='Europe/Berlin' --name volvo2mqtt ghcr.io/dielee/volvo2mqtt:latest
latest: Pulling from dielee/volvo2mqtt
Digest: sha256:15806260614d8f899fab82afd0ed3e2759e77daea771d5192bbca6f94d43ea62
Status: Image is up to date for ghcr.io/dielee/volvo2mqtt:latest
Starting volvo2mqtt version v1.0.5
Vin: ['VIN1', 'VIN2'] found!
Starting GET call against https://api.volvocars.com/connected-vehicle/v1/vehicles/{0}
Starting GET call against https://api.volvocars.com/connected-vehicle/v1/vehicles/{0}
Sending mqtt update...
Starting GET call against https://api.volvocars.com/connected-vehicle/v2/vehicles/{0}/doors
Starting GET call against https://api.volvocars.com/energy/v1/vehicles/{0}/recharge-status
Starting GET call against https://api.volvocars.com/connected-vehicle/v2/vehicles/{0}/doors
Traceback (most recent call last):
  File "/volvoAAOS2mqtt/./main.py", line 9, in <module>
    update_loop()
  File "/volvoAAOS2mqtt/mqtt.py", line 76, in update_loop
    update_car_data()
  File "/volvoAAOS2mqtt/mqtt.py", line 107, in update_car_data
    state = volvo.api_call(sensor["url"], "GET", vin, sensor["id"])
  File "/volvoAAOS2mqtt/volvo.py", line 129, in api_call
    response = recharge_response[vin]
KeyError: 'VIN2'

If I run this separately its working fine for both vin's

root@vm-docker:/data/docker/volvo2mqtt# docker run --rm=true  --pull=always -e CONF_updateInterval=30 -e CONF_babelLocale='de' -e CONF_mqtt='@json {"broker": "XXX", "username": "", "password": ""}' -e CONF_volvoData='@json {"username": "XXX", "password": "XXX", "vin": "VIN1", "vccapikey": "XXX"}' -e TZ='Europe/Berlin' --name volvo2mqtt ghcr.io/dielee/volvo2mqtt:latest
latest: Pulling from dielee/volvo2mqtt
Digest: sha256:15806260614d8f899fab82afd0ed3e2759e77daea771d5192bbca6f94d43ea62
Status: Image is up to date for ghcr.io/dielee/volvo2mqtt:latest
Starting volvo2mqtt version v1.0.5
Vin: ['VIN1'] found!
Starting GET call against https://api.volvocars.com/connected-vehicle/v1/vehicles/{0}
Sending mqtt update...
Starting GET call against https://api.volvocars.com/connected-vehicle/v2/vehicles/{0}/doors
Starting GET call against https://api.volvocars.com/energy/v1/vehicles/{0}/recharge-status
Mqtt update done. Next run in 30 seconds.
Sending mqtt update...
Starting GET call against https://api.volvocars.com/connected-vehicle/v2/vehicles/{0}/doors
Starting GET call against https://api.volvocars.com/energy/v1/vehicles/{0}/recharge-status
Mqtt update done. Next run in 30 seconds.

root@vm-docker:/data/docker/volvo2mqtt# docker run --rm=true  --pull=always -e CONF_updateInterval=30 -e CONF_babelLocale='de' -e CONF_mqtt='@json {"broker": "XXX", "username": "", "password": ""}' -e CONF_volvoData='@json {"username": "XXX", "password": "XXX", "vin": "VIN2", "vccapikey": "XXX"}' -e TZ='Europe/Berlin' --name volvo2mqtt ghcr.io/dielee/volvo2mqtt:latest
latest: Pulling from dielee/volvo2mqtt
Digest: sha256:15806260614d8f899fab82afd0ed3e2759e77daea771d5192bbca6f94d43ea62
Status: Image is up to date for ghcr.io/dielee/volvo2mqtt:latest
Starting volvo2mqtt version v1.0.5
Vin: ['VIN2'] found!
Starting GET call against https://api.volvocars.com/connected-vehicle/v1/vehicles/{0}
Sending mqtt update...
Starting GET call against https://api.volvocars.com/connected-vehicle/v2/vehicles/{0}/doors
Starting GET call against https://api.volvocars.com/energy/v1/vehicles/{0}/recharge-status
Mqtt update done. Next run in 30 seconds.

Originally posted by @christoph-ng in #3 (comment)

Error on Getting engineRunning

Describe the bug
Jul 03 10:07:54 volvo2mqtt [1] - INFO: Success! Tire Rear Left is supported by your vehicle.
Jul 03 10:07:54 volvo2mqtt [1] - INFO: Success! Tire Rear Right is supported by your vehicle.
Traceback (most recent call last):
File "/volvoAAOS2mqtt/./main.py", line 13, in
authorize()
File "/volvoAAOS2mqtt/volvo.py", line 52, in authorize
check_supported_endpoints()
File "/volvoAAOS2mqtt/volvo.py", line 159, in check_supported_endpoints
state = api_call(entity["url"], "GET", vin, entity["id"])
File "/volvoAAOS2mqtt/volvo.py", line 250, in api_call
return parse_api_data(data, sensor_id)
File "/volvoAAOS2mqtt/volvo.py", line 369, in parse_api_data
return engine_states[data["engineRunning"]["value"]] if util.keys_exists(data, "engineRunning") else None
KeyError: 'false'

Version info
Docker Container 1.7.1

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.