Skip to content

Commit

Permalink
add preset mode icons
Browse files Browse the repository at this point in the history
  • Loading branch information
dandelionclock authored Jun 18, 2024
1 parent dba148f commit c27b810
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions custom_components/tesla_custom/climate.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@


KEEPER_MAP = {
"Keep On": 1,
"Dog Mode": 2,
"Camp Mode": 3,
"keep": 1,
"dog": 2,
"camp": 3,
}


Expand All @@ -46,8 +46,8 @@ class TeslaCarClimate(TeslaCarEntity, ClimateEntity):
| ClimateEntityFeature.FAN_MODE
)
_attr_hvac_modes = [HVACMode.HEAT_COOL, HVACMode.OFF]
_attr_preset_modes = ["Normal", "Defrost", "Keep On", "Dog Mode", "Camp Mode"]
_attr_fan_modes = ["Off", "Bioweapon Mode"]
_attr_preset_modes = ["normal", "defrost", "keep", "dog", "camp"]
_attr_fan_modes = ["off", "bioweapon"]

@property
def translation_key(self):
Expand Down Expand Up @@ -125,29 +125,29 @@ def preset_mode(self):
Requires SUPPORT_PRESET_MODE.
"""
if self._car.defrost_mode == 2:
return "Defrost"
return "defrost"
if self._car.climate_keeper_mode == "dog":
return "Dog Mode"
return "dog"
if self._car.climate_keeper_mode == "camp":
return "Camp Mode"
return "camp"
if self._car.climate_keeper_mode == "on":
return "Keep On"
return "keep"

return "Normal"
return "normal"

async def async_set_preset_mode(self, preset_mode: str) -> None:
"""Set new preset mode."""
_LOGGER.debug("%s: Setting preset_mode to: %s", self.name, preset_mode)

if preset_mode == "Normal":
if preset_mode == "normal":
# If setting Normal, we need to check Defrost And Keep modes.
if self._car.defrost_mode != 0:
await self._car.set_max_defrost(0)

if self._car.climate_keeper_mode != 0:
await self._car.set_climate_keeper_mode(0)

elif preset_mode == "Defrost":
elif preset_mode == "defrost":
await self._car.set_max_defrost(2)

else:
Expand All @@ -162,12 +162,12 @@ def fan_mode(self):
Requires SUPPORT_FAN_MODE.
"""
if self._car.bioweapon_mode:
return "Bioweapon Mode"
return "bioweapon"

return "Off"
return "off"

async def async_set_fan_mode(self, fan_mode: str) -> None:
"""Set new fan mode as bioweapon mode."""
_LOGGER.debug("%s: Setting fan_mode to: %s", self.name, fan_mode)

await self._car.set_bioweapon_mode(fan_mode == "Bioweapon Mode")
await self._car.set_bioweapon_mode(fan_mode == "bioweapon")

0 comments on commit c27b810

Please sign in to comment.