mirror of
https://github.com/home-assistant/core.git
synced 2025-08-03 18:48:22 +00:00
Adjust climate
This commit is contained in:
parent
94739f45d0
commit
5dd916b5ba
@ -308,18 +308,16 @@ class TuyaClimateEntity(TuyaEntity, ClimateEntity):
|
|||||||
def set_fan_mode(self, fan_mode: str) -> None:
|
def set_fan_mode(self, fan_mode: str) -> None:
|
||||||
"""Set new target fan mode."""
|
"""Set new target fan mode."""
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
# We can rely on supported_features from __init__
|
# guarded by supported features
|
||||||
assert self._fan_mode_dp_code is not None
|
assert self._fan_mode_dp_code is not None
|
||||||
|
|
||||||
self._send_command([{"code": self._fan_mode_dp_code, "value": fan_mode}])
|
self._send_command([{"code": self._fan_mode_dp_code, "value": fan_mode}])
|
||||||
|
|
||||||
def set_humidity(self, humidity: int) -> None:
|
def set_humidity(self, humidity: int) -> None:
|
||||||
"""Set new target humidity."""
|
"""Set new target humidity."""
|
||||||
if self._set_humidity is None:
|
if TYPE_CHECKING:
|
||||||
raise ServiceValidationError(
|
# guarded by supported features
|
||||||
translation_domain=DOMAIN,
|
assert self._set_humidity is not None
|
||||||
translation_key="action_dpcode_not_found",
|
|
||||||
)
|
|
||||||
|
|
||||||
self._send_command(
|
self._send_command(
|
||||||
[
|
[
|
||||||
|
@ -11,6 +11,8 @@ from tuya_sharing import CustomerDevice
|
|||||||
from homeassistant.components.climate import (
|
from homeassistant.components.climate import (
|
||||||
DOMAIN as CLIMATE_DOMAIN,
|
DOMAIN as CLIMATE_DOMAIN,
|
||||||
SERVICE_SET_FAN_MODE,
|
SERVICE_SET_FAN_MODE,
|
||||||
|
SERVICE_SET_HUMIDITY,
|
||||||
|
SERVICE_SET_TEMPERATURE,
|
||||||
)
|
)
|
||||||
from homeassistant.components.tuya import ManagerCompat
|
from homeassistant.components.tuya import ManagerCompat
|
||||||
from homeassistant.const import Platform
|
from homeassistant.const import Platform
|
||||||
@ -62,6 +64,36 @@ async def test_platform_setup_no_discovery(
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.parametrize(
|
||||||
|
"mock_device_code",
|
||||||
|
["kt_serenelife_slpac905wuk_air_conditioner"],
|
||||||
|
)
|
||||||
|
async def test_set_temperature(
|
||||||
|
hass: HomeAssistant,
|
||||||
|
mock_manager: ManagerCompat,
|
||||||
|
mock_config_entry: MockConfigEntry,
|
||||||
|
mock_device: CustomerDevice,
|
||||||
|
) -> None:
|
||||||
|
"""Test set temperature service."""
|
||||||
|
entity_id = "climate.air_conditioner"
|
||||||
|
await initialize_entry(hass, mock_manager, mock_config_entry, mock_device)
|
||||||
|
|
||||||
|
state = hass.states.get(entity_id)
|
||||||
|
assert state is not None, f"{entity_id} does not exist"
|
||||||
|
await hass.services.async_call(
|
||||||
|
CLIMATE_DOMAIN,
|
||||||
|
SERVICE_SET_TEMPERATURE,
|
||||||
|
{
|
||||||
|
"entity_id": entity_id,
|
||||||
|
"temperature": 22.7,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
await hass.async_block_till_done()
|
||||||
|
mock_manager.send_commands.assert_called_once_with(
|
||||||
|
mock_device.id, [{"code": "temp_set", "value": 22}]
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize(
|
@pytest.mark.parametrize(
|
||||||
"mock_device_code",
|
"mock_device_code",
|
||||||
["kt_serenelife_slpac905wuk_air_conditioner"],
|
["kt_serenelife_slpac905wuk_air_conditioner"],
|
||||||
@ -125,3 +157,31 @@ async def test_fan_mode_no_valid_code(
|
|||||||
},
|
},
|
||||||
blocking=True,
|
blocking=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.parametrize(
|
||||||
|
"mock_device_code",
|
||||||
|
["kt_serenelife_slpac905wuk_air_conditioner"],
|
||||||
|
)
|
||||||
|
async def test_set_humidity_not_supported(
|
||||||
|
hass: HomeAssistant,
|
||||||
|
mock_manager: ManagerCompat,
|
||||||
|
mock_config_entry: MockConfigEntry,
|
||||||
|
mock_device: CustomerDevice,
|
||||||
|
) -> None:
|
||||||
|
"""Test set humidity service (not available on this device)."""
|
||||||
|
entity_id = "climate.air_conditioner"
|
||||||
|
await initialize_entry(hass, mock_manager, mock_config_entry, mock_device)
|
||||||
|
|
||||||
|
state = hass.states.get(entity_id)
|
||||||
|
assert state is not None, f"{entity_id} does not exist"
|
||||||
|
with pytest.raises(ServiceNotSupported):
|
||||||
|
await hass.services.async_call(
|
||||||
|
CLIMATE_DOMAIN,
|
||||||
|
SERVICE_SET_HUMIDITY,
|
||||||
|
{
|
||||||
|
"entity_id": entity_id,
|
||||||
|
"humidity": 50,
|
||||||
|
},
|
||||||
|
blocking=True,
|
||||||
|
)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user