Skip to content

Commit

Permalink
Update Last Connected logic for EVs + Temporary disable broken controls
Browse files Browse the repository at this point in the history
  • Loading branch information
stickpin committed Jan 23, 2024
1 parent 09bec0a commit 06cfa3f
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 13 deletions.
6 changes: 5 additions & 1 deletion volkswagencarnet/vw_dashboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -525,7 +525,11 @@ def attributes(self) -> dict:

class AuxiliaryClimatisation(Switch):
def __init__(self):
super().__init__(attr="auxiliary_climatisation", name="Auxiliary Climatisation", icon="mdi:radiator")
super().__init__(
attr="auxiliary_climatisation",
name="Auxiliary Climatisation",
icon="mdi:radiator",
entity_type="config",)
self.spin = ""

def configurate(self, **config):
Expand Down
47 changes: 35 additions & 12 deletions volkswagencarnet/vw_vehicle.py
Original file line number Diff line number Diff line change
Expand Up @@ -610,9 +610,12 @@ def last_connected(self) -> str:
# this field is only a dirty hack, because there is no overarching information for the car anymore,
# only information per service, so we just use the one for odometer
last_connected_time = "Unknown"
last_connected_time_path = f"{Services.MEASUREMENTS}.odometerStatus.value.carCapturedTimestamp"
if is_valid_path(self.attrs, last_connected_time_path):
last_connected_time_utc = find_path(self.attrs, last_connected_time_path)
last_connected_time_utc = None
if self.is_battery_level_supported:
last_connected_time_utc = self.battery_level_last_updated
elif self.is_distance_supported:
last_connected_time_utc = self.distance_last_updated
if last_connected_time_utc is not None:
if type(last_connected_time_utc) is str:
last_connected_time_utc = datetime.strptime(last_connected_time_utc, "%Y-%m-%dT%H:%M:%S.%fZ").replace(
microsecond=0
Expand Down Expand Up @@ -757,7 +760,9 @@ def charging_last_updated(self) -> datetime:
@property
def is_charging_supported(self) -> bool:
"""Return true if charging is supported."""
return is_valid_path(self.attrs, f"{Services.CHARGING}.chargingStatus.value.chargingState")
#return is_valid_path(self.attrs, f"{Services.CHARGING}.chargingStatus.value.chargingState")
# CURRENTLY NOT SUPPORTED
return False

@property
def charging_power(self) -> int:
Expand Down Expand Up @@ -1174,7 +1179,9 @@ def climatisation_without_external_power_last_updated(self) -> datetime:
@property
def is_climatisation_without_external_power_supported(self) -> bool:
"""Return true if climatisation on battery power is supported."""
return is_valid_path(self.attrs, "climatisation.climatisationSettings.value.climatisationWithoutExternalPower")
#return is_valid_path(self.attrs, "climatisation.climatisationSettings.value.climatisationWithoutExternalPower")
# CURRENTLY NOT SUPPORTED
return False

@property
def outside_temperature(self) -> float | bool: # FIXME should probably be Optional[float] instead
Expand Down Expand Up @@ -1227,7 +1234,9 @@ def electric_climatisation_last_updated(self) -> datetime:
@property
def is_electric_climatisation_supported(self) -> bool:
"""Return true if vehicle has climater."""
return self.is_climatisation_supported
#return self.is_climatisation_supported
# CURRENTLY NOT SUPPORTED
return False

@property
def auxiliary_climatisation(self) -> bool:
Expand All @@ -1245,7 +1254,13 @@ def auxiliary_climatisation_last_updated(self) -> datetime:
@property
def is_auxiliary_climatisation_supported(self) -> bool:
"""Return true if vehicle has auxiliary climatisation."""
return is_valid_path(self.attrs, "climatisation.climatisationStatus.value.climatisationState")
#return (
# is_valid_path(self.attrs, "climatisation.climatisationSettings.value.heaterSource")
# or is_valid_path(self.attrs, "climatisation.climatisationSettings.value.climatizationAtUnlock")
#)
# CURRENTLY NOT SUPPORTED
return False


@property
def is_climatisation_supported(self) -> bool:
Expand Down Expand Up @@ -2054,26 +2069,34 @@ def is_timer_basic_settings_supported(self) -> bool:
@property
def is_departure_timer1_supported(self) -> bool:
"""Check if timer 1 is supported."""
return self.is_schedule_supported(1)
#return self.is_schedule_supported(1)
# CURRENTLY NOT SUPPORTED
return False

@property
def is_departure_timer2_supported(self) -> bool:
"""Check if timer 2is supported."""
return self.is_schedule_supported(2)
#return self.is_schedule_supported(2)
# CURRENTLY NOT SUPPORTED
return False

@property
def is_departure_timer3_supported(self) -> bool:
"""Check if timer 3 is supported."""
return self.is_schedule_supported(3)
#return self.is_schedule_supported(3)
# CURRENTLY NOT SUPPORTED
return False

def is_schedule_supported(self, id: str | int) -> bool:
"""
Return true if schedule is supported.
:return:
"""
timer: TimerData = self.attrs.get("timer", None)
return timer.has_schedule(id)
#timer: TimerData = self.attrs.get("timer", None)
#return timer.has_schedule(id)
# CURRENTLY NOT SUPPORTED
return False

# Trip data
@property
Expand Down

0 comments on commit 06cfa3f

Please sign in to comment.