This commit is contained in:
epenet
2025-08-14 11:53:09 +00:00
parent 03222c4742
commit a9e1e9e411

View File

@@ -372,25 +372,31 @@ class TuyaClimateEntity(TuyaEntity, ClimateEntity):
def set_temperature(self, **kwargs: Any) -> None:
"""Set new target temperature."""
commands = []
if ATTR_TEMPERATURE in kwargs:
if TYPE_CHECKING:
# guarded by ClimateEntityFeature.TARGET_TEMPERATURE
assert self._set_temperature is not None
commands.append(
self._send_command(
[
{
"code": self._set_temperature.dpcode,
"value": round(
self._set_temperature.scale_value_back(kwargs[ATTR_TEMPERATURE])
self._set_temperature.scale_value_back(
kwargs[ATTR_TEMPERATURE]
)
),
}
]
)
return
if ATTR_TARGET_TEMP_LOW in kwargs:
if ATTR_TARGET_TEMP_LOW in kwargs and ATTR_TARGET_TEMP_HIGH in kwargs:
if TYPE_CHECKING:
# guarded by ClimateEntityFeature.TARGET_TEMPERATURE_RANGE
assert self._set_temperature_lower is not None
commands.append(
assert self._set_temperature_upper is not None
self._send_command(
[
{
"code": self._set_temperature_lower.dpcode,
"value": round(
@@ -398,14 +404,7 @@ class TuyaClimateEntity(TuyaEntity, ClimateEntity):
kwargs[ATTR_TARGET_TEMP_LOW]
)
),
}
)
if ATTR_TARGET_TEMP_HIGH in kwargs:
if TYPE_CHECKING:
# guarded by ClimateEntityFeature.TARGET_TEMPERATURE_RANGE
assert self._set_temperature_upper is not None
commands.append(
},
{
"code": self._set_temperature_upper.dpcode,
"value": round(
@@ -413,12 +412,10 @@ class TuyaClimateEntity(TuyaEntity, ClimateEntity):
kwargs[ATTR_TARGET_TEMP_HIGH]
)
),
}
},
]
)
if commands:
self._send_command(commands)
@property
def current_temperature(self) -> float | None:
"""Return the current temperature."""