Skip to content

Commit

Permalink
Fix fuel sensor for combustion car (#217)
Browse files Browse the repository at this point in the history
  • Loading branch information
stickpin authored Nov 29, 2023
1 parent 0a8290e commit 2a5fbbb
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions volkswagencarnet/vw_vehicle.py
Original file line number Diff line number Diff line change
Expand Up @@ -1192,12 +1192,24 @@ def fuel_level(self) -> int:
:return:
"""
return int(find_path(self.attrs, "measurements.fuelLevelStatus.value.currentFuelLevel_pct"))
fuel_level_pct = ""
if is_valid_path(self.attrs, "fuelStatus.rangeStatus.value.primaryEngine.currentFuelLevel_pct"):
fuel_level_pct = find_path(self.attrs, "fuelStatus.rangeStatus.value.primaryEngine.currentFuelLevel_pct")

if is_valid_path(self.attrs, "measurements.fuelLevelStatus.value.currentFuelLevel_pct"):
fuel_level_pct = find_path(self.attrs, "measurements.fuelLevelStatus.value.currentFuelLevel_pct")
return int(fuel_level_pct)

@property
def fuel_level_last_updated(self) -> datetime:
"""Return fuel level last updated."""
return find_path(self.attrs, "measurements.fuelLevelStatus.value.carCapturedTimestamp")
fuel_level_lastupdated = ""
if is_valid_path(self.attrs, "fuelStatus.rangeStatus.value.carCapturedTimestamp"):
fuel_level_lastupdated = find_path(self.attrs, "fuelStatus.rangeStatus.value.carCapturedTimestamp")

if is_valid_path(self.attrs, "measurements.fuelLevelStatus.value.carCapturedTimestamp"):
fuel_level_lastupdated = find_path(self.attrs, "measurements.fuelLevelStatus.value.carCapturedTimestamp")
return fuel_level_lastupdated

@property
def is_fuel_level_supported(self) -> bool:
Expand All @@ -1206,7 +1218,8 @@ def is_fuel_level_supported(self) -> bool:
:return:
"""
return is_valid_path(self.attrs, "measurements.fuelLevelStatus.value.currentFuelLevel_pct")
return (is_valid_path(self.attrs, "measurements.fuelLevelStatus.value.currentFuelLevel_pct")
or is_valid_path(self.attrs, "fuelStatus.rangeStatus.value.primaryEngine.currentFuelLevel_pct"))

# Climatisation settings
@property
Expand Down

0 comments on commit 2a5fbbb

Please sign in to comment.