mirror of
https://github.com/home-assistant/core.git
synced 2025-07-25 06:07:17 +00:00
Refactor async_set_temperature for mqtt climate (#94166)
This commit is contained in:
parent
7d8e412314
commit
8e9eb400bf
@ -604,15 +604,8 @@ class MqttTemperatureControlEntity(MqttEntity, ABC):
|
|||||||
return changed
|
return changed
|
||||||
|
|
||||||
@abstractmethod
|
@abstractmethod
|
||||||
async def async_set_hvac_mode(self, hvac_mode: HVACMode) -> None:
|
|
||||||
"""Set hvac mode."""
|
|
||||||
|
|
||||||
async def async_set_temperature(self, **kwargs: Any) -> None:
|
async def async_set_temperature(self, **kwargs: Any) -> None:
|
||||||
"""Set new target temperatures."""
|
"""Set new target temperatures."""
|
||||||
operation_mode: HVACMode | None
|
|
||||||
if (operation_mode := kwargs.get(ATTR_HVAC_MODE)) is not None:
|
|
||||||
await self.async_set_hvac_mode(operation_mode)
|
|
||||||
|
|
||||||
changed = await self._set_climate_attribute(
|
changed = await self._set_climate_attribute(
|
||||||
kwargs.get(ATTR_TEMPERATURE),
|
kwargs.get(ATTR_TEMPERATURE),
|
||||||
CONF_TEMP_COMMAND_TOPIC,
|
CONF_TEMP_COMMAND_TOPIC,
|
||||||
@ -967,6 +960,13 @@ class MqttClimate(MqttTemperatureControlEntity, ClimateEntity):
|
|||||||
|
|
||||||
self.prepare_subscribe_topics(topics)
|
self.prepare_subscribe_topics(topics)
|
||||||
|
|
||||||
|
async def async_set_temperature(self, **kwargs: Any) -> None:
|
||||||
|
"""Set new target temperatures."""
|
||||||
|
operation_mode: HVACMode | None
|
||||||
|
if (operation_mode := kwargs.get(ATTR_HVAC_MODE)) is not None:
|
||||||
|
await self.async_set_hvac_mode(operation_mode)
|
||||||
|
await super().async_set_temperature(**kwargs)
|
||||||
|
|
||||||
async def async_set_humidity(self, humidity: int) -> None:
|
async def async_set_humidity(self, humidity: int) -> None:
|
||||||
"""Set new target humidity."""
|
"""Set new target humidity."""
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user