mirror of
https://github.com/home-assistant/core.git
synced 2025-07-30 00:27:19 +00:00
Revert climate/cover
This commit is contained in:
parent
855de74646
commit
d0c70eca7d
@ -307,16 +307,17 @@ 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:
|
||||||
# guarded by ClimateEntityFeature.FAN_MODE
|
# We can rely on supported_features from __init__
|
||||||
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 TYPE_CHECKING:
|
if self._set_humidity is None:
|
||||||
# guarded by ClimateEntityFeature.TARGET_HUMIDITY
|
raise RuntimeError(
|
||||||
assert self._set_humidity is not None
|
"Cannot set humidity, device doesn't provide methods to set it"
|
||||||
|
)
|
||||||
|
|
||||||
self._send_command(
|
self._send_command(
|
||||||
[
|
[
|
||||||
@ -354,9 +355,11 @@ class TuyaClimateEntity(TuyaEntity, ClimateEntity):
|
|||||||
|
|
||||||
def set_temperature(self, **kwargs: Any) -> None:
|
def set_temperature(self, **kwargs: Any) -> None:
|
||||||
"""Set new target temperature."""
|
"""Set new target temperature."""
|
||||||
if TYPE_CHECKING:
|
if self._set_temperature is None:
|
||||||
# guarded by ClimateEntityFeature.TARGET_TEMPERATURE
|
raise RuntimeError(
|
||||||
assert self._set_temperature is not None
|
"Cannot set target temperature, device doesn't provide methods to"
|
||||||
|
" set it"
|
||||||
|
)
|
||||||
|
|
||||||
self._send_command(
|
self._send_command(
|
||||||
[
|
[
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
from dataclasses import dataclass
|
from dataclasses import dataclass
|
||||||
from typing import TYPE_CHECKING, Any
|
from typing import Any
|
||||||
|
|
||||||
from tuya_sharing import CustomerDevice, Manager
|
from tuya_sharing import CustomerDevice, Manager
|
||||||
|
|
||||||
@ -333,9 +333,10 @@ class TuyaCoverEntity(TuyaEntity, CoverEntity):
|
|||||||
|
|
||||||
def set_cover_position(self, **kwargs: Any) -> None:
|
def set_cover_position(self, **kwargs: Any) -> None:
|
||||||
"""Move the cover to a specific position."""
|
"""Move the cover to a specific position."""
|
||||||
if TYPE_CHECKING:
|
if self._set_position is None:
|
||||||
# guarded by CoverEntityFeature.SET_POSITION
|
raise RuntimeError(
|
||||||
assert self._set_position is not None
|
"Cannot set position, device doesn't provide methods to set it"
|
||||||
|
)
|
||||||
|
|
||||||
self._send_command(
|
self._send_command(
|
||||||
[
|
[
|
||||||
@ -363,9 +364,10 @@ class TuyaCoverEntity(TuyaEntity, CoverEntity):
|
|||||||
|
|
||||||
def set_cover_tilt_position(self, **kwargs: Any) -> None:
|
def set_cover_tilt_position(self, **kwargs: Any) -> None:
|
||||||
"""Move the cover tilt to a specific position."""
|
"""Move the cover tilt to a specific position."""
|
||||||
if TYPE_CHECKING:
|
if self._tilt is None:
|
||||||
# guarded by CoverEntityFeature.SET_TILT_POSITION
|
raise RuntimeError(
|
||||||
assert self._tilt is not None
|
"Cannot set tilt, device doesn't provide methods to set it"
|
||||||
|
)
|
||||||
|
|
||||||
self._send_command(
|
self._send_command(
|
||||||
[
|
[
|
||||||
|
@ -11,8 +11,6 @@ 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
|
||||||
@ -64,36 +62,6 @@ 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"],
|
||||||
@ -157,31 +125,3 @@ 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,
|
|
||||||
)
|
|
||||||
|
@ -8,17 +8,9 @@ import pytest
|
|||||||
from syrupy.assertion import SnapshotAssertion
|
from syrupy.assertion import SnapshotAssertion
|
||||||
from tuya_sharing import CustomerDevice
|
from tuya_sharing import CustomerDevice
|
||||||
|
|
||||||
from homeassistant.components.cover import (
|
|
||||||
DOMAIN as COVER_DOMAIN,
|
|
||||||
SERVICE_CLOSE_COVER,
|
|
||||||
SERVICE_OPEN_COVER,
|
|
||||||
SERVICE_SET_COVER_POSITION,
|
|
||||||
SERVICE_SET_COVER_TILT_POSITION,
|
|
||||||
)
|
|
||||||
from homeassistant.components.tuya import ManagerCompat
|
from homeassistant.components.tuya import ManagerCompat
|
||||||
from homeassistant.const import Platform
|
from homeassistant.const import Platform
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.exceptions import ServiceNotSupported
|
|
||||||
from homeassistant.helpers import entity_registry as er
|
from homeassistant.helpers import entity_registry as er
|
||||||
|
|
||||||
from . import DEVICE_MOCKS, initialize_entry
|
from . import DEVICE_MOCKS, initialize_entry
|
||||||
@ -65,107 +57,6 @@ async def test_platform_setup_no_discovery(
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize(
|
|
||||||
"mock_device_code",
|
|
||||||
["cl_am43_corded_motor_zigbee_cover"],
|
|
||||||
)
|
|
||||||
@patch("homeassistant.components.tuya.PLATFORMS", [Platform.COVER])
|
|
||||||
async def test_open_service(
|
|
||||||
hass: HomeAssistant,
|
|
||||||
mock_manager: ManagerCompat,
|
|
||||||
mock_config_entry: MockConfigEntry,
|
|
||||||
mock_device: CustomerDevice,
|
|
||||||
) -> None:
|
|
||||||
"""Test open service."""
|
|
||||||
entity_id = "cover.kitchen_blinds_curtain"
|
|
||||||
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(
|
|
||||||
COVER_DOMAIN,
|
|
||||||
SERVICE_OPEN_COVER,
|
|
||||||
{
|
|
||||||
"entity_id": entity_id,
|
|
||||||
},
|
|
||||||
)
|
|
||||||
await hass.async_block_till_done()
|
|
||||||
mock_manager.send_commands.assert_called_once_with(
|
|
||||||
mock_device.id,
|
|
||||||
[
|
|
||||||
{"code": "control", "value": "open"},
|
|
||||||
{"code": "percent_control", "value": 0},
|
|
||||||
],
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize(
|
|
||||||
"mock_device_code",
|
|
||||||
["cl_am43_corded_motor_zigbee_cover"],
|
|
||||||
)
|
|
||||||
@patch("homeassistant.components.tuya.PLATFORMS", [Platform.COVER])
|
|
||||||
async def test_close_service(
|
|
||||||
hass: HomeAssistant,
|
|
||||||
mock_manager: ManagerCompat,
|
|
||||||
mock_config_entry: MockConfigEntry,
|
|
||||||
mock_device: CustomerDevice,
|
|
||||||
) -> None:
|
|
||||||
"""Test close service."""
|
|
||||||
entity_id = "cover.kitchen_blinds_curtain"
|
|
||||||
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(
|
|
||||||
COVER_DOMAIN,
|
|
||||||
SERVICE_CLOSE_COVER,
|
|
||||||
{
|
|
||||||
"entity_id": entity_id,
|
|
||||||
},
|
|
||||||
)
|
|
||||||
await hass.async_block_till_done()
|
|
||||||
mock_manager.send_commands.assert_called_once_with(
|
|
||||||
mock_device.id,
|
|
||||||
[
|
|
||||||
{"code": "control", "value": "close"},
|
|
||||||
{"code": "percent_control", "value": 100},
|
|
||||||
],
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize(
|
|
||||||
"mock_device_code",
|
|
||||||
["cl_am43_corded_motor_zigbee_cover"],
|
|
||||||
)
|
|
||||||
async def test_set_position(
|
|
||||||
hass: HomeAssistant,
|
|
||||||
mock_manager: ManagerCompat,
|
|
||||||
mock_config_entry: MockConfigEntry,
|
|
||||||
mock_device: CustomerDevice,
|
|
||||||
) -> None:
|
|
||||||
"""Test set position service (not available on this device)."""
|
|
||||||
entity_id = "cover.kitchen_blinds_curtain"
|
|
||||||
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(
|
|
||||||
COVER_DOMAIN,
|
|
||||||
SERVICE_SET_COVER_POSITION,
|
|
||||||
{
|
|
||||||
"entity_id": entity_id,
|
|
||||||
"position": 25,
|
|
||||||
},
|
|
||||||
)
|
|
||||||
await hass.async_block_till_done()
|
|
||||||
mock_manager.send_commands.assert_called_once_with(
|
|
||||||
mock_device.id,
|
|
||||||
[
|
|
||||||
{"code": "percent_control", "value": 75},
|
|
||||||
],
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize(
|
@pytest.mark.parametrize(
|
||||||
"mock_device_code",
|
"mock_device_code",
|
||||||
["cl_am43_corded_motor_zigbee_cover"],
|
["cl_am43_corded_motor_zigbee_cover"],
|
||||||
@ -198,31 +89,3 @@ async def test_percent_state_on_cover(
|
|||||||
state = hass.states.get(entity_id)
|
state = hass.states.get(entity_id)
|
||||||
assert state is not None, f"{entity_id} does not exist"
|
assert state is not None, f"{entity_id} does not exist"
|
||||||
assert state.attributes["current_position"] == percent_state
|
assert state.attributes["current_position"] == percent_state
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize(
|
|
||||||
"mock_device_code",
|
|
||||||
["cl_am43_corded_motor_zigbee_cover"],
|
|
||||||
)
|
|
||||||
async def test_set_tilt_position_not_supported(
|
|
||||||
hass: HomeAssistant,
|
|
||||||
mock_manager: ManagerCompat,
|
|
||||||
mock_config_entry: MockConfigEntry,
|
|
||||||
mock_device: CustomerDevice,
|
|
||||||
) -> None:
|
|
||||||
"""Test set tilt position service (not available on this device)."""
|
|
||||||
entity_id = "cover.kitchen_blinds_curtain"
|
|
||||||
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(
|
|
||||||
COVER_DOMAIN,
|
|
||||||
SERVICE_SET_COVER_TILT_POSITION,
|
|
||||||
{
|
|
||||||
"entity_id": entity_id,
|
|
||||||
"tilt_position": 50,
|
|
||||||
},
|
|
||||||
blocking=True,
|
|
||||||
)
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user