Skip to content

Commit

Permalink
Fix edge case when the targetTemperature is not present
Browse files Browse the repository at this point in the history
  • Loading branch information
stickpin committed Feb 19, 2024
1 parent 4eb6f36 commit 533069f
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions volkswagencarnet/vw_vehicle.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
ENGINE_TYPE_DIESEL = "diesel"
ENGINE_TYPE_GASOLINE = "gasoline"
ENGINE_TYPE_COMBUSTION = [ENGINE_TYPE_DIESEL, ENGINE_TYPE_GASOLINE]
DEFAULT_TARGET_TEMP = 24


class Vehicle:
Expand Down Expand Up @@ -343,8 +344,13 @@ async def set_battery_climatisation(self, mode=False):
"""Turn on/off electric climatisation from battery."""
if self.is_climatisation_without_external_power_supported:
if mode in [True, False]:
temperature = (
self.climatisation_target_temperature
if self.climatisation_target_temperature is not None
else DEFAULT_TARGET_TEMP
)
data = {
"targetTemperature": self.climatisation_target_temperature,
"targetTemperature": temperature,
"targetTemperatureUnit": "celsius",
"climatisationWithoutExternalPower": mode,
}
Expand All @@ -358,7 +364,6 @@ async def set_battery_climatisation(self, mode=False):
else:
_LOGGER.error(f'Set climatisation without external power to "{mode}" is not supported.')
raise Exception(f'Set climatisation without external power to "{mode}" is not supported.')
return await self.set_climater(data)
else:
_LOGGER.error("No climatisation support.")
raise Exception("No climatisation support.")
Expand Down

0 comments on commit 533069f

Please sign in to comment.