Add divider option for average speed

This commit is contained in:
Linus Dietz
2023-06-26 14:23:53 +02:00
parent 988fb3bd21
commit 4bd6a7a991
5 changed files with 16 additions and 7 deletions
+3 -1
View File
@@ -1,6 +1,6 @@
name: "Volvo2Mqtt"
description: "Volvo AAOS MQTT bridge"
version: "1.5.4"
version: "1.5.5"
slug: "volvo2mqtt"
init: false
url: "https://github.com/Dielee/volvo2mqtt"
@@ -21,6 +21,7 @@ options:
vin: ""
vccapikey: null
odometerMultiplier: 1
averageSpeedDivider: 1
schema:
updateInterval: int(10,)
babelLocale: str
@@ -37,6 +38,7 @@ schema:
vin: str?
vccapikey: str
odometerMultiplier: int(1,)
averageSpeedDivider: int(1,)
arch:
- aarch64
- amd64
+1 -1
View File
@@ -1,6 +1,6 @@
from config import settings
VERSION = "v1.5.4"
VERSION = "v1.5.5"
OAUTH_URL = "https://volvoid.eu.volvocars.com/as/token.oauth2"
VEHICLES_URL = "https://api.volvocars.com/connected-vehicle/v1/vehicles"
+2 -2
View File
@@ -15,5 +15,5 @@ configuration:
name: MQTT Broker settings
description: Broker is your mqtt broker IP eg "192.168.0.1". Mqtt username and password are optional. Broker port can be changed. If no value is given, port 1883 will be used.
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. 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!
name: Volvo configuration options
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. The same is applicable for average speed divider. Leave it as it is if you don't know what's right. Take a look at the GitHub repo for more information!
+8 -1
View File
@@ -344,7 +344,14 @@ def parse_api_data(data, sensor_id=None):
if util.keys_exists(data, "averageSpeed"):
average_speed = int(data["averageSpeed"]["value"])
if average_speed > 0:
return average_speed
divider = 1
if util.keys_exists(settings["volvoData"], "averageSpeedDivider"):
divider = settings["volvoData"]["averageSpeedDivider"]
if isinstance(divider, str):
divider = 1
elif divider < 1:
divider = 1
return average_speed / divider
else:
return None
else: