diff --git a/tests/components/tuya/__init__.py b/tests/components/tuya/__init__.py index 1ce7e6c47dd..d9016d18def 100644 --- a/tests/components/tuya/__init__.py +++ b/tests/components/tuya/__init__.py @@ -15,8 +15,8 @@ from tests.common import MockConfigEntry DEVICE_MOCKS = { "cl_am43_corded_motor_zigbee_cover": [ # https://github.com/home-assistant/core/issues/71242 - Platform.SELECT, Platform.COVER, + Platform.SELECT, ], "clkg_curtain_switch": [ # https://github.com/home-assistant/core/issues/136055 diff --git a/tests/components/tuya/test_climate.py b/tests/components/tuya/test_climate.py index d564c027cd1..9c0e3c31a26 100644 --- a/tests/components/tuya/test_climate.py +++ b/tests/components/tuya/test_climate.py @@ -8,6 +8,10 @@ import pytest from syrupy.assertion import SnapshotAssertion from tuya_sharing import CustomerDevice +from homeassistant.components.climate import ( + DOMAIN as CLIMATE_DOMAIN, + SERVICE_SET_FAN_MODE, +) from homeassistant.components.tuya import ManagerCompat from homeassistant.const import Platform from homeassistant.core import HomeAssistant @@ -69,16 +73,17 @@ async def test_fan_mode_windspeed( mock_device: CustomerDevice, ) -> None: """Test fan mode with windspeed.""" + entity_id = "climate.air_conditioner" await initialize_entry(hass, mock_manager, mock_config_entry, mock_device) - state = hass.states.get("climate.air_conditioner") - assert state is not None, "climate.air_conditioner does not exist" + state = hass.states.get(entity_id) + assert state is not None, f"{entity_id} does not exist" assert state.attributes["fan_mode"] == 1 await hass.services.async_call( - Platform.CLIMATE, - "set_fan_mode", + CLIMATE_DOMAIN, + SERVICE_SET_FAN_MODE, { - "entity_id": "climate.air_conditioner", + "entity_id": entity_id, "fan_mode": 2, }, ) @@ -104,17 +109,18 @@ async def test_fan_mode_no_valid_code( mock_device.status_range.pop("windspeed", None) mock_device.status.pop("windspeed", None) + entity_id = "climate.air_conditioner" await initialize_entry(hass, mock_manager, mock_config_entry, mock_device) - state = hass.states.get("climate.air_conditioner") - assert state is not None, "climate.air_conditioner does not exist" + state = hass.states.get(entity_id) + assert state is not None, f"{entity_id} does not exist" assert state.attributes.get("fan_mode") is None with pytest.raises(ServiceNotSupported): await hass.services.async_call( - Platform.CLIMATE, - "set_fan_mode", + CLIMATE_DOMAIN, + SERVICE_SET_FAN_MODE, { - "entity_id": "climate.air_conditioner", + "entity_id": entity_id, "fan_mode": 2, }, blocking=True, diff --git a/tests/components/tuya/test_cover.py b/tests/components/tuya/test_cover.py index 3b190e46827..29a6d65978f 100644 --- a/tests/components/tuya/test_cover.py +++ b/tests/components/tuya/test_cover.py @@ -83,8 +83,9 @@ async def test_percent_state_on_cover( # 100 is closed and 0 is open for Tuya covers mock_device.status["percent_state"] = 100 - percent_state + entity_id = "cover.kitchen_blinds_curtain" await initialize_entry(hass, mock_manager, mock_config_entry, mock_device) - cover_state = hass.states.get("cover.kitchen_blinds_curtain") - assert cover_state is not None, "cover.kitchen_blinds_curtain does not exist" - assert cover_state.attributes["current_position"] == percent_state + state = hass.states.get(entity_id) + assert state is not None, f"{entity_id} does not exist" + assert state.attributes["current_position"] == percent_state