From a097c75eb6fe2ca24ac6ed249d9c136d68836042 Mon Sep 17 00:00:00 2001 From: Jacob Berelman <630000+stickpin@users.noreply.github.com> Date: Sun, 21 Jan 2024 21:33:55 +0100 Subject: [PATCH] Add charging rate and charging power sensor for supported vehicles --- volkswagencarnet/vw_dashboard.py | 12 ++++++++++++ volkswagencarnet/vw_vehicle.py | 32 +++++++++++++++++++++++++++++++- 2 files changed, 43 insertions(+), 1 deletion(-) diff --git a/volkswagencarnet/vw_dashboard.py b/volkswagencarnet/vw_dashboard.py index f56ae9f5..4c781840 100644 --- a/volkswagencarnet/vw_dashboard.py +++ b/volkswagencarnet/vw_dashboard.py @@ -905,6 +905,18 @@ def create_instruments(): icon="mdi:flash", unit="", ), + Sensor( + attr="charging_power", + name="Charging Power", + icon="mdi:transmission-tower", + unit="kW", + ), + Sensor( + attr="charging_rate", + name="Charging Rate", + icon="mdi:ev-station", + unit="km/h", + ), Sensor( attr="climatisation_target_temperature", name="Climatisation target temperature", diff --git a/volkswagencarnet/vw_vehicle.py b/volkswagencarnet/vw_vehicle.py index 6266825b..218f6328 100644 --- a/volkswagencarnet/vw_vehicle.py +++ b/volkswagencarnet/vw_vehicle.py @@ -759,6 +759,36 @@ def is_charging_supported(self) -> bool: """Return true if charging is supported.""" return is_valid_path(self.attrs, f"{Services.CHARGING}.chargingStatus.value.chargingState") + @property + def charging_power(self) -> bool: + """Return charging state.""" + return find_path(self.attrs, f"{Services.CHARGING}.chargingStatus.value.chargePower_kW") + + @property + def charging_power_last_updated(self) -> datetime: + """Return attribute last updated timestamp.""" + return find_path(self.attrs, f"{Services.CHARGING}.chargingStatus.value.carCapturedTimestamp") + + @property + def is_charging_power_supported(self) -> bool: + """Return true if charging is supported.""" + return is_valid_path(self.attrs, f"{Services.CHARGING}.chargingStatus.value.chargePower_kW") + + @property + def charging_rate(self) -> bool: + """Return charging state.""" + return find_path(self.attrs, f"{Services.CHARGING}.chargingStatus.value.chargeRate_kmph") + + @property + def charging_rate_last_updated(self) -> datetime: + """Return attribute last updated timestamp.""" + return find_path(self.attrs, f"{Services.CHARGING}.chargingStatus.value.carCapturedTimestamp") + + @property + def is_charging_rate_supported(self) -> bool: + """Return true if charging is supported.""" + return is_valid_path(self.attrs, f"{Services.CHARGING}.chargingStatus.value.chargeRate_kmph") + @property def battery_level(self) -> int: """Return battery level.""" @@ -1506,7 +1536,7 @@ def is_sunroof_closed_supported(self) -> bool: if window["name"] == "sunRoof" and "unsupported" not in window["status"]: return True return False - + @property def sunroof_rear_closed(self) -> bool: """