Skip to content

Commit

Permalink
Add charging rate and charging power sensor for supported vehicles
Browse files Browse the repository at this point in the history
  • Loading branch information
stickpin committed Jan 21, 2024
1 parent 81d6bfb commit a097c75
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 1 deletion.
12 changes: 12 additions & 0 deletions volkswagencarnet/vw_dashboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
32 changes: 31 additions & 1 deletion volkswagencarnet/vw_vehicle.py
Original file line number Diff line number Diff line change
Expand Up @@ -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."""
Expand Down Expand Up @@ -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:
"""
Expand Down

0 comments on commit a097c75

Please sign in to comment.