forked from peter/volvo2mqtt
Support new statistic endpoints // Remove unused multiplier options
This commit is contained in:
@@ -126,7 +126,7 @@ The following steps are required for authentication in exactly this order:
|
|||||||
Just install this addon with the following command.
|
Just install this addon with the following command.
|
||||||
Please note to fill in your settings inside the environment variables.
|
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`
|
`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"]}' -e TZ='Europe/Berlin' --name volvo2mqtt ghcr.io/dielee/volvo2mqtt:latest`
|
||||||
|
|
||||||
<b>HA Add-On:</b><br>
|
<b>HA Add-On:</b><br>
|
||||||
|
|
||||||
@@ -146,9 +146,6 @@ Here is what every option means:
|
|||||||
| `CONF_volvoData` | `json` | `password` | **required** | Your password 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` | `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](https://developer.volvocars.com/account/). <b>Starting version 1.8.0, it is possible to define multiple keys, like this: `["vccapikey1", "vccapikey2", "vccapikey3", "etc..."]`</b>
|
| `CONF_volvoData` | `json` | `vccapikey` | **required** | VCCAPIKEY linked with your volvo developer account. Get your Vccapi key from [here](https://developer.volvocars.com/account/). <b>Starting version 1.8.0, it is possible to define multiple keys, like this: `["vccapikey1", "vccapikey2", "vccapikey3", "etc..."]`</b>
|
||||||
| `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. |
|
| `CONF_debug` | `string` | | optional | Debug option (true/false). Normally you don't need this. |
|
||||||
| `TZ` | `string` | | **required** | Container timezone eg "Europe/Berlin" from [here](https://docs.diladele.com/docker/timezones.html)|
|
| `TZ` | `string` | | **required** | Container timezone eg "Europe/Berlin" from [here](https://docs.diladele.com/docker/timezones.html)|
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,11 @@
|
|||||||
|
## v1.10.0
|
||||||
|
### 🚀 Features:
|
||||||
|
- Remove unused multiplier options
|
||||||
|
|
||||||
|
### 🐛 Bug Fixes:
|
||||||
|
|
||||||
|
- Support new statistic keys #237
|
||||||
|
|
||||||
## v1.9.7
|
## v1.9.7
|
||||||
### 🐛 Bug Fixes:
|
### 🐛 Bug Fixes:
|
||||||
|
|
||||||
|
|||||||
+1
-4
@@ -1,6 +1,6 @@
|
|||||||
name: "Volvo2Mqtt"
|
name: "Volvo2Mqtt"
|
||||||
description: "Volvo AAOS MQTT bridge"
|
description: "Volvo AAOS MQTT bridge"
|
||||||
version: "1.9.7"
|
version: "1.10.0"
|
||||||
slug: "volvo2mqtt"
|
slug: "volvo2mqtt"
|
||||||
init: false
|
init: false
|
||||||
url: "https://github.com/Dielee/volvo2mqtt"
|
url: "https://github.com/Dielee/volvo2mqtt"
|
||||||
@@ -47,9 +47,6 @@ schema:
|
|||||||
vin: str?
|
vin: str?
|
||||||
vccapikey:
|
vccapikey:
|
||||||
- match(^\b\w{32}\b$)
|
- match(^\b\w{32}\b$)
|
||||||
odometerMultiplier: int(1,)
|
|
||||||
averageSpeedDivider: int(1,)
|
|
||||||
averageFuelConsumptionMultiplier: int(1,)
|
|
||||||
arch:
|
arch:
|
||||||
- aarch64
|
- aarch64
|
||||||
- amd64
|
- amd64
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
from config import settings
|
from config import settings
|
||||||
|
|
||||||
VERSION = "v1.9.7"
|
VERSION = "v1.10.0"
|
||||||
|
|
||||||
OAUTH_TOKEN_URL = "https://volvoid.eu.volvocars.com/as/token.oauth2"
|
OAUTH_TOKEN_URL = "https://volvoid.eu.volvocars.com/as/token.oauth2"
|
||||||
OAUTH_AUTH_URL = "https://volvoid.eu.volvocars.com/as/authorization.oauth2"
|
OAUTH_AUTH_URL = "https://volvoid.eu.volvocars.com/as/authorization.oauth2"
|
||||||
|
|||||||
+23
-28
@@ -551,7 +551,6 @@ def cached_request(url, method, vin, force_update=False, key_change=False):
|
|||||||
def parse_api_data(data, sensor_id=None):
|
def parse_api_data(data, sensor_id=None):
|
||||||
if sensor_id != "api_backend_status":
|
if sensor_id != "api_backend_status":
|
||||||
data = data["data"]
|
data = data["data"]
|
||||||
|
|
||||||
if sensor_id == "battery_charge_level":
|
if sensor_id == "battery_charge_level":
|
||||||
return data["batteryChargeLevel"]["value"] if util.keys_exists(data, "batteryChargeLevel") else None
|
return data["batteryChargeLevel"]["value"] if util.keys_exists(data, "batteryChargeLevel") else None
|
||||||
elif sensor_id == "battery_capacity":
|
elif sensor_id == "battery_capacity":
|
||||||
@@ -588,14 +587,7 @@ def parse_api_data(data, sensor_id=None):
|
|||||||
elif sensor_id == "lock_status":
|
elif sensor_id == "lock_status":
|
||||||
return data["centralLock"]["value"] if util.keys_exists(data, "centralLock") else None
|
return data["centralLock"]["value"] if util.keys_exists(data, "centralLock") else None
|
||||||
elif sensor_id == "odometer":
|
elif sensor_id == "odometer":
|
||||||
multiplier = 1
|
return util.convert_metric_values(int(data["odometer"]["value"])) \
|
||||||
if util.keys_exists(settings["volvoData"], "odometerMultiplier"):
|
|
||||||
multiplier = settings["volvoData"]["odometerMultiplier"]
|
|
||||||
if isinstance(multiplier, str):
|
|
||||||
multiplier = 1
|
|
||||||
elif multiplier < 1:
|
|
||||||
multiplier = 1
|
|
||||||
return util.convert_metric_values(int(data["odometer"]["value"]) * multiplier) \
|
|
||||||
if util.keys_exists(data, "odometer") else None
|
if util.keys_exists(data, "odometer") else None
|
||||||
elif sensor_id == "window_front_left":
|
elif sensor_id == "window_front_left":
|
||||||
return window_states[data["frontLeftWindow"]["value"]] if util.keys_exists(data, "frontLeftWindow") \
|
return window_states[data["frontLeftWindow"]["value"]] if util.keys_exists(data, "frontLeftWindow") \
|
||||||
@@ -643,30 +635,25 @@ def parse_api_data(data, sensor_id=None):
|
|||||||
return fuel_amount
|
return fuel_amount
|
||||||
return None
|
return None
|
||||||
elif sensor_id == "average_fuel_consumption":
|
elif sensor_id == "average_fuel_consumption":
|
||||||
|
average_fuel_con = 0
|
||||||
if util.keys_exists(data, "averageFuelConsumption"):
|
if util.keys_exists(data, "averageFuelConsumption"):
|
||||||
average_fuel_con = float(data["averageFuelConsumption"]["value"])
|
average_fuel_con = float(data["averageFuelConsumption"]["value"])
|
||||||
if average_fuel_con > 0:
|
elif util.keys_exists(data, "averageFuelConsumptionAutomatic"):
|
||||||
multiplier = 1
|
average_fuel_con = float(data["averageFuelConsumptionAutomatic"]["value"])
|
||||||
if util.keys_exists(settings["volvoData"], "averageFuelConsumptionMultiplier"):
|
|
||||||
multiplier = settings["volvoData"]["averageFuelConsumptionMultiplier"]
|
if average_fuel_con > 0:
|
||||||
if isinstance(multiplier, str):
|
return average_fuel_con
|
||||||
multiplier = 1
|
|
||||||
elif multiplier < 1:
|
|
||||||
multiplier = 1
|
|
||||||
return average_fuel_con * multiplier
|
|
||||||
return None
|
return None
|
||||||
elif sensor_id == "average_speed":
|
elif sensor_id == "average_speed":
|
||||||
|
average_speed = 0
|
||||||
if util.keys_exists(data, "averageSpeed"):
|
if util.keys_exists(data, "averageSpeed"):
|
||||||
average_speed = float(data["averageSpeed"]["value"])
|
average_speed = float(data["averageSpeed"]["value"])
|
||||||
if average_speed > 1:
|
elif util.keys_exists(data, "averageSpeedAutomatic"):
|
||||||
divider = 1
|
average_speed = float(data["averageSpeedAutomatic"]["value"])
|
||||||
if util.keys_exists(settings["volvoData"], "averageSpeedDivider"):
|
|
||||||
divider = settings["volvoData"]["averageSpeedDivider"]
|
if average_speed != 0:
|
||||||
if isinstance(divider, str):
|
return util.convert_metric_values(average_speed)
|
||||||
divider = 1
|
|
||||||
elif divider < 1:
|
|
||||||
divider = 1
|
|
||||||
return util.convert_metric_values(average_speed / divider)
|
|
||||||
return None
|
return None
|
||||||
elif sensor_id == "location":
|
elif sensor_id == "location":
|
||||||
coordinates = {}
|
coordinates = {}
|
||||||
@@ -705,7 +692,15 @@ def parse_api_data(data, sensor_id=None):
|
|||||||
elif sensor_id == "service_warning_status":
|
elif sensor_id == "service_warning_status":
|
||||||
return data["serviceWarning"]["value"] if util.keys_exists(data, "serviceWarning") else None
|
return data["serviceWarning"]["value"] if util.keys_exists(data, "serviceWarning") else None
|
||||||
elif sensor_id == "average_energy_consumption":
|
elif sensor_id == "average_energy_consumption":
|
||||||
return data["averageEnergyConsumption"]["value"] if util.keys_exists(data, "averageEnergyConsumption") else None
|
average_energy_con = 0
|
||||||
|
if util.keys_exists(data, "averageEnergyConsumption"):
|
||||||
|
average_energy_con = data["averageEnergyConsumption"]["value"]
|
||||||
|
elif util.keys_exists(data, "averageEnergyConsumptionAutomatic"):
|
||||||
|
average_energy_con = data["averageEnergyConsumptionAutomatic"]["value"]
|
||||||
|
|
||||||
|
if average_energy_con != 0:
|
||||||
|
return average_energy_con
|
||||||
|
return None
|
||||||
elif sensor_id == "washer_fluid_warning":
|
elif sensor_id == "washer_fluid_warning":
|
||||||
return data["washerFluidLevelWarning"]["value"] if util.keys_exists(data, "washerFluidLevelWarning") else None
|
return data["washerFluidLevelWarning"]["value"] if util.keys_exists(data, "washerFluidLevelWarning") else None
|
||||||
elif sensor_id == "warnings":
|
elif sensor_id == "warnings":
|
||||||
|
|||||||
Reference in New Issue
Block a user