Skip to content

Commit

Permalink
Fix status reporting for sunroof vehicles
Browse files Browse the repository at this point in the history
  • Loading branch information
G-Two committed Jul 23, 2023
1 parent 57ea4f3 commit 9b70989
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 11 deletions.
2 changes: 1 addition & 1 deletion subarulink/__version__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
For more details about this api, please refer to the documentation at
https://github.com/G-Two/subarulink
"""
__version__ = "0.7.6-1"
__version__ = "0.7.7"
19 changes: 9 additions & 10 deletions subarulink/controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ def has_power_windows(self, vin: str) -> bool:
"""
vehicle = self._vehicles.get(vin.upper())
if vehicle:
status = api.API_FEATURE_POWER_WINDOWS in vehicle[sc.VEHICLE_FEATURES] and self.get_remote_status(vin)
status = api.API_FEATURE_POWER_WINDOWS in vehicle[sc.VEHICLE_FEATURES]
_LOGGER.debug("Getting power window status %s:%s", vin, status)
return status
raise SubaruException("Invalid VIN")
Expand All @@ -295,12 +295,11 @@ def has_sunroof(self, vin: str) -> bool:
vehicle = self._vehicles.get(vin.upper())
if vehicle:
status = False
if self.has_power_windows(vin):
if (
api.API_FEATURE_MOONROOF_PANORAMIC in vehicle[sc.VEHICLE_FEATURES]
or api.API_FEATURE_MOONROOF_POWER in vehicle[sc.VEHICLE_FEATURES]
):
status = True
if (
api.API_FEATURE_MOONROOF_PANORAMIC in vehicle[sc.VEHICLE_FEATURES]
or api.API_FEATURE_MOONROOF_POWER in vehicle[sc.VEHICLE_FEATURES]
):
status = True
_LOGGER.debug("Getting moonroof status %s:%s", vin, status)
return status
raise SubaruException("Invalid VIN")
Expand Down Expand Up @@ -1295,7 +1294,7 @@ def _parse_condition(self, js_resp: dict[str, Any], vin: str) -> dict[str, str |
keep_data[sc.REMAINING_FUEL_PERCENT] = data[api.API_REMAINING_FUEL_PERCENT]

# Parse window/sunroof status for supported vehicles
if self.has_power_windows(vin):
if self.has_power_windows(vin) or self.has_sunroof(vin):
keep_data.update(
{
sc.WINDOW_FRONT_LEFT_STATUS: data[api.API_WINDOW_FRONT_LEFT_STATUS],
Expand All @@ -1305,8 +1304,8 @@ def _parse_condition(self, js_resp: dict[str, Any], vin: str) -> dict[str, str |
}
)

if self.has_sunroof(vin):
keep_data[sc.WINDOW_SUNROOF_STATUS] = data[api.API_WINDOW_SUNROOF_STATUS]
if self.has_sunroof(vin):
keep_data[sc.WINDOW_SUNROOF_STATUS] = data[api.API_WINDOW_SUNROOF_STATUS]

# Parse EV specific values
if self.get_ev_status(vin):
Expand Down

0 comments on commit 9b70989

Please # to comment.