diff --git a/README.md b/README.md index ec9fdf9..1a71ee9 100644 --- a/README.md +++ b/README.md @@ -126,7 +126,7 @@ The following steps are required for authentication in exactly this order: 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` +`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` HA Add-On:
@@ -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` | `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/). 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](https://docs.diladele.com/docker/timezones.html)| diff --git a/src/CHANGELOG.md b/src/CHANGELOG.md index 24a12f9..5bd4a3e 100644 --- a/src/CHANGELOG.md +++ b/src/CHANGELOG.md @@ -1,3 +1,11 @@ +## v1.10.0 +### 🚀 Features: +- Remove unused multiplier options + +### 🐛 Bug Fixes: + +- Support new statistic keys #237 + ## v1.9.7 ### 🐛 Bug Fixes: diff --git a/src/config.yaml b/src/config.yaml index 79d3eba..8ea49ed 100644 --- a/src/config.yaml +++ b/src/config.yaml @@ -1,6 +1,6 @@ name: "Volvo2Mqtt" description: "Volvo AAOS MQTT bridge" -version: "1.9.7" +version: "1.10.0" slug: "volvo2mqtt" init: false url: "https://github.com/Dielee/volvo2mqtt" @@ -47,9 +47,6 @@ schema: vin: str? vccapikey: - match(^\b\w{32}\b$) - odometerMultiplier: int(1,) - averageSpeedDivider: int(1,) - averageFuelConsumptionMultiplier: int(1,) arch: - aarch64 - amd64 diff --git a/src/const.py b/src/const.py index 6b8a912..b73449c 100644 --- a/src/const.py +++ b/src/const.py @@ -1,6 +1,6 @@ from config import settings -VERSION = "v1.9.7" +VERSION = "v1.10.0" OAUTH_TOKEN_URL = "https://volvoid.eu.volvocars.com/as/token.oauth2" OAUTH_AUTH_URL = "https://volvoid.eu.volvocars.com/as/authorization.oauth2" diff --git a/src/volvo.py b/src/volvo.py index 8312a27..aaa562c 100644 --- a/src/volvo.py +++ b/src/volvo.py @@ -551,7 +551,6 @@ def cached_request(url, method, vin, force_update=False, key_change=False): def parse_api_data(data, sensor_id=None): if sensor_id != "api_backend_status": data = data["data"] - if sensor_id == "battery_charge_level": return data["batteryChargeLevel"]["value"] if util.keys_exists(data, "batteryChargeLevel") else None elif sensor_id == "battery_capacity": @@ -588,14 +587,7 @@ def parse_api_data(data, sensor_id=None): elif sensor_id == "lock_status": return data["centralLock"]["value"] if util.keys_exists(data, "centralLock") else None elif sensor_id == "odometer": - multiplier = 1 - 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) \ + return util.convert_metric_values(int(data["odometer"]["value"])) \ if util.keys_exists(data, "odometer") else None elif sensor_id == "window_front_left": 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 None elif sensor_id == "average_fuel_consumption": + average_fuel_con = 0 if util.keys_exists(data, "averageFuelConsumption"): average_fuel_con = float(data["averageFuelConsumption"]["value"]) - if average_fuel_con > 0: - multiplier = 1 - if util.keys_exists(settings["volvoData"], "averageFuelConsumptionMultiplier"): - multiplier = settings["volvoData"]["averageFuelConsumptionMultiplier"] - if isinstance(multiplier, str): - multiplier = 1 - elif multiplier < 1: - multiplier = 1 - return average_fuel_con * multiplier + elif util.keys_exists(data, "averageFuelConsumptionAutomatic"): + average_fuel_con = float(data["averageFuelConsumptionAutomatic"]["value"]) + + if average_fuel_con > 0: + return average_fuel_con return None elif sensor_id == "average_speed": + average_speed = 0 if util.keys_exists(data, "averageSpeed"): average_speed = float(data["averageSpeed"]["value"]) - if average_speed > 1: - 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 util.convert_metric_values(average_speed / divider) + elif util.keys_exists(data, "averageSpeedAutomatic"): + average_speed = float(data["averageSpeedAutomatic"]["value"]) + + if average_speed != 0: + return util.convert_metric_values(average_speed) + return None elif sensor_id == "location": coordinates = {} @@ -705,7 +692,15 @@ def parse_api_data(data, sensor_id=None): elif sensor_id == "service_warning_status": return data["serviceWarning"]["value"] if util.keys_exists(data, "serviceWarning") else None 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": return data["washerFluidLevelWarning"]["value"] if util.keys_exists(data, "washerFluidLevelWarning") else None elif sensor_id == "warnings":