Skip to content

Commit

Permalink
Add Battery target charge level sensor
Browse files Browse the repository at this point in the history
  • Loading branch information
stickpin committed Jan 21, 2024
1 parent e75a6d8 commit 09bec0a
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
6 changes: 6 additions & 0 deletions volkswagencarnet/vw_dashboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
17 changes: 16 additions & 1 deletion volkswagencarnet/vw_vehicle.py
Original file line number Diff line number Diff line change
Expand Up @@ -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":
Expand Down Expand Up @@ -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."""
Expand Down

0 comments on commit 09bec0a

Please sign in to comment.