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 (
|
from homeassistant.components.climate import (
|
||||||
|
ATTR_HVAC_MODE,
|
||||||
ClimateEntity,
|
ClimateEntity,
|
||||||
ClimateEntityFeature,
|
ClimateEntityFeature,
|
||||||
HVACMode,
|
HVACMode,
|
||||||
|
@ -112,7 +113,10 @@ class TessieClimateEntity(TessieEntity, ClimateEntity):
|
||||||
|
|
||||||
async def async_set_temperature(self, **kwargs: Any) -> None:
|
async def async_set_temperature(self, **kwargs: Any) -> None:
|
||||||
"""Set the climate temperature."""
|
"""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)
|
await self.run(set_temperature, temperature=temp)
|
||||||
self.set(("climate_state_driver_temp_setting", temp))
|
self.set(("climate_state_driver_temp_setting", temp))
|
||||||
|
|
||||||
|
|
|
@ -54,14 +54,22 @@ async def test_climate(
|
||||||
with patch(
|
with patch(
|
||||||
"homeassistant.components.tessie.climate.set_temperature",
|
"homeassistant.components.tessie.climate.set_temperature",
|
||||||
return_value=TEST_RESPONSE,
|
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(
|
await hass.services.async_call(
|
||||||
CLIMATE_DOMAIN,
|
CLIMATE_DOMAIN,
|
||||||
SERVICE_SET_TEMPERATURE,
|
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,
|
blocking=True,
|
||||||
)
|
)
|
||||||
mock_set.assert_called_once()
|
mock_set.assert_called_once()
|
||||||
|
mock_set2.assert_called_once()
|
||||||
state = hass.states.get(entity_id)
|
state = hass.states.get(entity_id)
|
||||||
assert state.attributes[ATTR_TEMPERATURE] == 20
|
assert state.attributes[ATTR_TEMPERATURE] == 20
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue