Small code quality fix in Teslemetry (#124603)
* Fix cop_mode logic bug * Update climate.py * Fix attributespull/124969/head^2
parent
30aa3a26ad
commit
3e60d7aa11
|
@ -183,20 +183,28 @@ COP_MODES = {
|
||||||
"FanOnly": HVACMode.FAN_ONLY,
|
"FanOnly": HVACMode.FAN_ONLY,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# String to celsius
|
||||||
COP_LEVELS = {
|
COP_LEVELS = {
|
||||||
"Low": 30,
|
"Low": 30,
|
||||||
"Medium": 35,
|
"Medium": 35,
|
||||||
"High": 40,
|
"High": 40,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Celsius to IntEnum
|
||||||
|
TEMP_LEVELS = {
|
||||||
|
30: CabinOverheatProtectionTemp.LOW,
|
||||||
|
35: CabinOverheatProtectionTemp.MEDIUM,
|
||||||
|
40: CabinOverheatProtectionTemp.HIGH,
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
class TeslemetryCabinOverheatProtectionEntity(TeslemetryVehicleEntity, ClimateEntity):
|
class TeslemetryCabinOverheatProtectionEntity(TeslemetryVehicleEntity, ClimateEntity):
|
||||||
"""Telemetry vehicle cabin overheat protection entity."""
|
"""Telemetry vehicle cabin overheat protection entity."""
|
||||||
|
|
||||||
_attr_precision = PRECISION_WHOLE
|
_attr_precision = PRECISION_WHOLE
|
||||||
_attr_target_temperature_step = 5
|
_attr_target_temperature_step = 5
|
||||||
_attr_min_temp = 30
|
_attr_min_temp = COP_LEVELS["Low"]
|
||||||
_attr_max_temp = 40
|
_attr_max_temp = COP_LEVELS["High"]
|
||||||
_attr_temperature_unit = UnitOfTemperature.CELSIUS
|
_attr_temperature_unit = UnitOfTemperature.CELSIUS
|
||||||
_attr_hvac_modes = list(COP_MODES.values())
|
_attr_hvac_modes = list(COP_MODES.values())
|
||||||
_enable_turn_on_off_backwards_compatibility = False
|
_enable_turn_on_off_backwards_compatibility = False
|
||||||
|
@ -256,13 +264,7 @@ class TeslemetryCabinOverheatProtectionEntity(TeslemetryVehicleEntity, ClimateEn
|
||||||
if not (temp := kwargs.get(ATTR_TEMPERATURE)):
|
if not (temp := kwargs.get(ATTR_TEMPERATURE)):
|
||||||
return
|
return
|
||||||
|
|
||||||
if temp == 30:
|
if (cop_mode := TEMP_LEVELS.get(temp)) is None:
|
||||||
cop_mode = CabinOverheatProtectionTemp.LOW
|
|
||||||
elif temp == 35:
|
|
||||||
cop_mode = CabinOverheatProtectionTemp.MEDIUM
|
|
||||||
elif temp == 40:
|
|
||||||
cop_mode = CabinOverheatProtectionTemp.HIGH
|
|
||||||
else:
|
|
||||||
raise ServiceValidationError(
|
raise ServiceValidationError(
|
||||||
translation_domain=DOMAIN,
|
translation_domain=DOMAIN,
|
||||||
translation_key="invalid_cop_temp",
|
translation_key="invalid_cop_temp",
|
||||||
|
|
Loading…
Reference in New Issue