From 09bec0ae5202e100265cf52d7412fb39bc3fc6d1 Mon Sep 17 00:00:00 2001 From: Jacob Berelman <630000+stickpin@users.noreply.github.com> Date: Sun, 21 Jan 2024 22:40:33 +0100 Subject: [PATCH] Add Battery target charge level sensor --- volkswagencarnet/vw_dashboard.py | 6 ++++++ volkswagencarnet/vw_vehicle.py | 17 ++++++++++++++++- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/volkswagencarnet/vw_dashboard.py b/volkswagencarnet/vw_dashboard.py index e8285a20..fef5ed37 100644 --- a/volkswagencarnet/vw_dashboard.py +++ b/volkswagencarnet/vw_dashboard.py @@ -825,6 +825,12 @@ def create_instruments(): device_class=VWDeviceClass.BATTERY, state_class=VWStateClass.MEASUREMENT, ), + Sensor( + attr="battery_target_charge_level", + name="Battery target charge level", + icon="mdi:battery-arrow-up", + unit="%", + ), Sensor( attr="adblue_level", name="Adblue level", diff --git a/volkswagencarnet/vw_vehicle.py b/volkswagencarnet/vw_vehicle.py index 76712d81..ad431958 100644 --- a/volkswagencarnet/vw_vehicle.py +++ b/volkswagencarnet/vw_vehicle.py @@ -792,7 +792,7 @@ def is_charging_rate_supported(self) -> bool: @property def charger_type(self) -> str: """Return charger type.""" - charger_type = find_path(self.attrs, f"{Services.CHARGING}.chargingStatus.value.chargeRate_kmph") + charger_type = find_path(self.attrs, f"{Services.CHARGING}.chargingStatus.value.chargeType") if charger_type == "ac": return "AC" elif charger_type == "dc": @@ -824,6 +824,21 @@ def is_battery_level_supported(self) -> bool: """Return true if battery level is supported.""" return is_valid_path(self.attrs, f"{Services.CHARGING}.batteryStatus.value.currentSOC_pct") + @property + def battery_target_charge_level(self) -> int: + """Return target charge level.""" + return find_path(self.attrs, f"{Services.CHARGING}.chargingSettings.value.targetSOC_pct") + + @property + def battery_target_charge_level_last_updated(self) -> datetime: + """Return attribute last updated timestamp.""" + return find_path(self.attrs, f"{Services.CHARGING}.chargingSettings.value.carCapturedTimestamp") + + @property + def is_battery_target_charge_level_supported(self) -> bool: + """Return true if target charge level is supported.""" + return is_valid_path(self.attrs, f"{Services.CHARGING}.chargingSettings.value.targetSOC_pct") + @property def charge_max_ampere(self) -> str | int: """Return charger max ampere setting."""