Fix set_temperature in Tessie climate platform (#110445)
* HVAC_MODE support for set_temperature * Fix importpull/111133/head
parent
eff82ba82c
commit
9cb425ae8b
|
@ -11,6 +11,7 @@ from tessie_api import (
|
|||
)
|
||||
|
||||
from homeassistant.components.climate import (
|
||||
ATTR_HVAC_MODE,
|
||||
ClimateEntity,
|
||||
ClimateEntityFeature,
|
||||
HVACMode,
|
||||
|
@ -112,7 +113,10 @@ class TessieClimateEntity(TessieEntity, ClimateEntity):
|
|||
|
||||
async def async_set_temperature(self, **kwargs: Any) -> None:
|
||||
"""Set the climate temperature."""
|
||||
temp = kwargs[ATTR_TEMPERATURE]
|
||||
if mode := kwargs.get(ATTR_HVAC_MODE):
|
||||
await self.async_set_hvac_mode(mode)
|
||||
|
||||
if temp := kwargs.get(ATTR_TEMPERATURE):
|
||||
await self.run(set_temperature, temperature=temp)
|
||||
self.set(("climate_state_driver_temp_setting", temp))
|
||||
|
||||
|
|
|
@ -54,14 +54,22 @@ async def test_climate(
|
|||
with patch(
|
||||
"homeassistant.components.tessie.climate.set_temperature",
|
||||
return_value=TEST_RESPONSE,
|
||||
) as mock_set:
|
||||
) as mock_set, patch(
|
||||
"homeassistant.components.tessie.climate.start_climate_preconditioning",
|
||||
return_value=TEST_RESPONSE,
|
||||
) as mock_set2:
|
||||
await hass.services.async_call(
|
||||
CLIMATE_DOMAIN,
|
||||
SERVICE_SET_TEMPERATURE,
|
||||
{ATTR_ENTITY_ID: [entity_id], ATTR_TEMPERATURE: 20},
|
||||
{
|
||||
ATTR_ENTITY_ID: [entity_id],
|
||||
ATTR_HVAC_MODE: HVACMode.HEAT_COOL,
|
||||
ATTR_TEMPERATURE: 20,
|
||||
},
|
||||
blocking=True,
|
||||
)
|
||||
mock_set.assert_called_once()
|
||||
mock_set2.assert_called_once()
|
||||
state = hass.states.get(entity_id)
|
||||
assert state.attributes[ATTR_TEMPERATURE] == 20
|
||||
|
||||
|
|
Loading…
Reference in New Issue