Make odometer multiplier configurable

This commit is contained in:
Linus Dietz
2023-06-23 12:31:38 +02:00
parent c34e090bfd
commit 7103b30da2
4 changed files with 11 additions and 4 deletions
+3 -1
View File
@@ -1,6 +1,6 @@
name: "Volvo2Mqtt"
description: "Volvo AAOS MQTT bridge"
version: "1.3.1"
version: "1.3.2"
slug: "volvo2mqtt"
init: false
url: "https://github.com/Dielee/volvo2mqtt"
@@ -18,6 +18,7 @@ options:
password: null
vin: ""
vccapikey: null
odometerMultiplier: 1
schema:
updateInterval: int(10,)
babelLocale: str
@@ -31,6 +32,7 @@ schema:
password: str
vin: str?
vccapikey: str
odometerMultiplier: int(1,)
arch:
- aarch64
- amd64
+1 -1
View File
@@ -1,6 +1,6 @@
from config import settings
VERSION = "v1.3.1"
VERSION = "v1.3.2"
OAUTH_URL = "https://volvoid.eu.volvocars.com/as/token.oauth2"
VEHICLES_URL = "https://api.volvocars.com/connected-vehicle/v1/vehicles"
+1 -1
View File
@@ -13,4 +13,4 @@ configuration:
description: Broker is your mqtt broker IP eg "192.168.0.1". Mqtt username and password are optional.
volvoData:
name: Volvo APP credentials
description: You have to enter your Volvo app credentials. The username is normally your email, and the password is the password you use for your Volvo app. The vin can stay empty. The Add-On will use any vin inside your Volvo account. VCCAPI key is required and comes from your Volvo developer account. Take a look at the GitHub repo for more information!
description: You have to enter your Volvo app credentials. The username is normally your email, and the password is the password you use for your Volvo app. The vin can stay empty. The Add-On will use any vin inside your Volvo account. VCCAPI key is required and comes from your Volvo developer account. Odometer multiplier is sometimes 10, sometimes 1. Leave it empty if you don't know what's right. Take a look at the GitHub repo for more information!
+6 -1
View File
@@ -331,7 +331,12 @@ def parse_api_data(data, sensor_id=None):
elif sensor_id == "lock_status":
return data["carLocked"]["value"] if keys_exists(data, "carLocked") else None
elif sensor_id == "odometer":
return int(data["odometer"]["value"]) * 10 if keys_exists(data, "odometer") else None
multiplier = 1
if keys_exists(settings["volvoData"], "odometerMultiplier"):
multiplier = settings["volvoData"]["odometerMultiplier"]
if multiplier < 1:
multiplier = 1
return int(data["odometer"]["value"]) * multiplier if keys_exists(data, "odometer") else None
elif sensor_id == "window_front_left":
return data["frontLeftWindowOpen"]["value"] if keys_exists(data, "frontLeftWindowOpen") else None
elif sensor_id == "window_front_right":