Skip to content

Commit

Permalink
Don't return 15 for requests remaining if we don't know it
Browse files Browse the repository at this point in the history
  • Loading branch information
milkboy committed Mar 15, 2022
1 parent 0d27eba commit 64a4500
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions volkswagencarnet/vw_vehicle.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ async def get_position(self):
old_time = self.attrs.get("findCarResponse", {}).get("parkingTimeUTC", None)
if old_time is None or new_time > old_time:
_LOGGER.debug(f"Detected new parking time: {new_time}")
self.requests_remaining = 15
self.requests_remaining = -1 if old_time is None else 15
self.requests_remaining_last_updated = datetime.utcnow()
except Exception as e:
_LOGGER.warning(f"Failed to parse parking time: {e}")
Expand Down Expand Up @@ -890,7 +890,7 @@ def is_adblue_level_supported(self) -> bool:

# Charger related states for EV and PHEV
@property
def charging(self) -> int:
def charging(self) -> bool:
"""Return charging state."""
cstate = (
self.attrs.get("charger", {})
Expand All @@ -899,7 +899,7 @@ def charging(self) -> int:
.get("chargingState", {})
.get("content", "")
)
return 1 if cstate == "charging" else 0
return cstate == "charging"

@property
def charging_last_updated(self) -> datetime:
Expand Down Expand Up @@ -1202,7 +1202,6 @@ def electric_range(self) -> int:
@property
def electric_range_last_updated(self) -> datetime:
"""Return electric range last updated."""
value = None
if (
PRIMARY_RANGE in self.attrs.get("StoredVehicleDataResponseParsed")
and self.attrs.get("StoredVehicleDataResponseParsed")[PRIMARY_DRIVE].get("value", UNSUPPORTED)
Expand Down Expand Up @@ -2536,6 +2535,7 @@ def is_request_results_supported(self):

@property
def requests_results_last_updated(self):
"""Return last updated timestamp for attribute."""
return None

@property
Expand Down

0 comments on commit 64a4500

Please sign in to comment.