diff --git a/homeassistant/components/lg_thinq/icons.json b/homeassistant/components/lg_thinq/icons.json index 1eb96b71f4a..f7001a92b9d 100644 --- a/homeassistant/components/lg_thinq/icons.json +++ b/homeassistant/components/lg_thinq/icons.json @@ -45,6 +45,9 @@ }, "display_light": { "default": "mdi:lightbulb-on-outline" + }, + "air_clean_operation_mode": { + "default": "mdi:air-filter" } }, "binary_sensor": { diff --git a/homeassistant/components/lg_thinq/strings.json b/homeassistant/components/lg_thinq/strings.json index 1d48a065915..52b9ea4a346 100644 --- a/homeassistant/components/lg_thinq/strings.json +++ b/homeassistant/components/lg_thinq/strings.json @@ -70,6 +70,9 @@ }, "display_light": { "name": "Lighting" + }, + "air_clean_operation_mode": { + "name": "[%key:component::lg_thinq::entity::climate::climate_air_conditioner::state_attributes::preset_mode::state::air_clean%]" } }, "binary_sensor": { diff --git a/homeassistant/components/lg_thinq/switch.py b/homeassistant/components/lg_thinq/switch.py index 06363140193..8ba680ca93d 100644 --- a/homeassistant/components/lg_thinq/switch.py +++ b/homeassistant/components/lg_thinq/switch.py @@ -31,6 +31,15 @@ class ThinQSwitchEntityDescription(SwitchEntityDescription): off_key: str | None = None +DRYER_OPERATION_SWITCH_DESC = ThinQSwitchEntityDescription( + key=ThinQProperty.DRYER_OPERATION_MODE, translation_key="operation_power" +) + +WASHER_OPERATION_SWITCH_DESC = ThinQSwitchEntityDescription( + key=ThinQProperty.WASHER_OPERATION_MODE, translation_key="operation_power" +) + + DEVICE_TYPE_SWITCH_MAP: dict[DeviceType, tuple[ThinQSwitchEntityDescription, ...]] = { DeviceType.AIR_CONDITIONER: ( ThinQSwitchEntityDescription( @@ -52,6 +61,13 @@ DEVICE_TYPE_SWITCH_MAP: dict[DeviceType, tuple[ThinQSwitchEntityDescription, ... off_key="false", entity_category=EntityCategory.CONFIG, ), + ThinQSwitchEntityDescription( + key=ThinQProperty.AIR_CLEAN_OPERATION_MODE, + translation_key=ThinQProperty.AIR_CLEAN_OPERATION_MODE, + on_key="on", + off_key="off", + entity_category=EntityCategory.CONFIG, + ), ), DeviceType.AIR_PURIFIER_FAN: ( ThinQSwitchEntityDescription( @@ -84,6 +100,13 @@ DEVICE_TYPE_SWITCH_MAP: dict[DeviceType, tuple[ThinQSwitchEntityDescription, ... translation_key="operation_power", ), ), + DeviceType.DISH_WASHER: ( + ThinQSwitchEntityDescription( + key=ThinQProperty.DISH_WASHER_OPERATION_MODE, + translation_key="operation_power", + ), + ), + DeviceType.DRYER: (DRYER_OPERATION_SWITCH_DESC,), DeviceType.HUMIDIFIER: ( ThinQSwitchEntityDescription( key=ThinQProperty.HUMIDIFIER_OPERATION_MODE, @@ -155,6 +178,27 @@ DEVICE_TYPE_SWITCH_MAP: dict[DeviceType, tuple[ThinQSwitchEntityDescription, ... entity_category=EntityCategory.CONFIG, ), ), + DeviceType.STYLER: ( + ThinQSwitchEntityDescription( + key=ThinQProperty.STYLER_OPERATION_MODE, translation_key="operation_power" + ), + ), + DeviceType.VENTILATOR: ( + ThinQSwitchEntityDescription( + key=ThinQProperty.VENTILATOR_OPERATION_MODE, + translation_key="operation_power", + entity_category=EntityCategory.CONFIG, + ), + ), + DeviceType.WASHCOMBO_MAIN: (WASHER_OPERATION_SWITCH_DESC,), + DeviceType.WASHCOMBO_MINI: (WASHER_OPERATION_SWITCH_DESC,), + DeviceType.WASHER: (WASHER_OPERATION_SWITCH_DESC,), + DeviceType.WASHTOWER: ( + DRYER_OPERATION_SWITCH_DESC, + WASHER_OPERATION_SWITCH_DESC, + ), + DeviceType.WASHTOWER_DRYER: (DRYER_OPERATION_SWITCH_DESC,), + DeviceType.WASHTOWER_WASHER: (WASHER_OPERATION_SWITCH_DESC,), DeviceType.WINE_CELLAR: ( ThinQSwitchEntityDescription( key=ThinQProperty.OPTIMAL_HUMIDITY, @@ -186,7 +230,8 @@ async def async_setup_entry( entities.extend( ThinQSwitchEntity(coordinator, description, property_id) for property_id in coordinator.api.get_active_idx( - description.key, ActiveMode.READ_WRITE + description.key, + ActiveMode.WRITABLE, ) ) diff --git a/tests/components/lg_thinq/conftest.py b/tests/components/lg_thinq/conftest.py index 2eaddf1a83b..73abc8c5075 100644 --- a/tests/components/lg_thinq/conftest.py +++ b/tests/components/lg_thinq/conftest.py @@ -98,15 +98,6 @@ def mock_thinq_api(mock_thinq_mqtt_client: None) -> Generator[AsyncMock]: """Mock a thinq api.""" with patch("homeassistant.components.lg_thinq.ThinQApi", autospec=True) as mock_api: thinq_api = mock_api.return_value - thinq_api.async_get_device_list.return_value = [ - load_json_object_fixture("air_conditioner/device.json", DOMAIN) - ] - thinq_api.async_get_device_profile.return_value = load_json_object_fixture( - "air_conditioner/profile.json", DOMAIN - ) - thinq_api.async_get_device_status.return_value = load_json_object_fixture( - "air_conditioner/status.json", DOMAIN - ) yield thinq_api @@ -119,3 +110,31 @@ def mock_thinq_mqtt_client() -> Generator[None]: return_value=True, ): yield + + +@pytest.fixture( + params=[ + "air_conditioner", + "washer", + ] +) +def device_fixture( + mock_thinq_api: AsyncMock, request: pytest.FixtureRequest +) -> Generator[str]: + """Return every device.""" + return request.param + + +@pytest.fixture +def devices(mock_thinq_api: AsyncMock, device_fixture: str) -> Generator[AsyncMock]: + """Return a specific device.""" + mock_thinq_api.async_get_device_list.return_value = [ + load_json_object_fixture(f"{device_fixture}/device.json", DOMAIN) + ] + mock_thinq_api.async_get_device_profile.return_value = load_json_object_fixture( + f"{device_fixture}/profile.json", DOMAIN + ) + mock_thinq_api.async_get_device_status.return_value = load_json_object_fixture( + f"{device_fixture}/status.json", DOMAIN + ) + return mock_thinq_api diff --git a/tests/components/lg_thinq/fixtures/air_conditioner/status.json b/tests/components/lg_thinq/fixtures/air_conditioner/status.json index 8440e7da28c..bffb13a1ac1 100644 --- a/tests/components/lg_thinq/fixtures/air_conditioner/status.json +++ b/tests/components/lg_thinq/fixtures/air_conditioner/status.json @@ -44,7 +44,6 @@ "unit": "F" } ], - "timer": { "relativeStartTimer": "UNSET", "relativeStopTimer": "UNSET", diff --git a/tests/components/lg_thinq/fixtures/washer/device.json b/tests/components/lg_thinq/fixtures/washer/device.json new file mode 100644 index 00000000000..33ea13669bd --- /dev/null +++ b/tests/components/lg_thinq/fixtures/washer/device.json @@ -0,0 +1,9 @@ +{ + "deviceId": "MW2-0B530EFD-1ADF-4F54-A2C3-46C37F94C689", + "deviceInfo": { + "deviceType": "DEVICE_WASHER", + "modelName": "FAFXU22027", + "alias": "Test washer", + "reportable": true + } +} diff --git a/tests/components/lg_thinq/fixtures/washer/profile.json b/tests/components/lg_thinq/fixtures/washer/profile.json new file mode 100644 index 00000000000..6b78300b4f9 --- /dev/null +++ b/tests/components/lg_thinq/fixtures/washer/profile.json @@ -0,0 +1,151 @@ +{ + "notification": { + "push": ["WASHING_IS_COMPLETE", "ERROR_DURING_WASHING"] + }, + "property": [ + { + "cycle": { + "cycleCount": { + "mode": ["r"], + "type": "number" + } + }, + "detergent": { + "detergentSetting": "NORMAL" + }, + "location": { + "locationName": "MAIN" + }, + "operation": { + "washerOperationMode": { + "mode": ["w"], + "type": "enum", + "value": { + "w": ["START", "STOP", "POWER_OFF", "POWER_ON"] + } + } + }, + "remoteControlEnable": { + "remoteControlEnabled": { + "mode": ["r"], + "type": "boolean", + "value": { + "r": [false, true] + } + } + }, + "runState": { + "currentState": { + "mode": ["r"], + "type": "enum", + "value": { + "r": [ + "DISPENSING", + "END", + "RUNNING", + "FROZEN_PREVENT_RUNNING", + "PAUSE", + "PREWASH", + "DETECTING", + "INITIAL", + "SOAKING", + "DRYING", + "FROZEN_PREVENT_PAUSE", + "FROZEN_PREVENT_INITIAL", + "REFRESHING", + "RINSING", + "STEAM_SOFTENING", + "DETERGENT_AMOUNT", + "POWER_OFF", + "RESERVED", + "RINSE_HOLD", + "ERROR", + "SPINNING", + "ADD_DRAIN" + ] + } + } + }, + "timer": { + "relativeHourToStart": { + "mode": ["r", "w"], + "type": "range", + "value": { + "r": { + "except": [], + "max": 19, + "min": 1, + "step": 1 + }, + "w": { + "except": [], + "max": 19, + "min": 1, + "step": 1 + } + } + }, + "relativeMinuteToStart": { + "mode": ["r"], + "type": "range", + "value": { + "r": { + "except": [], + "max": 30, + "min": 0, + "step": 1 + } + } + }, + "remainHour": { + "mode": ["r"], + "type": "range", + "value": { + "r": { + "except": [], + "max": 30, + "min": 0, + "step": 1 + } + } + }, + "remainMinute": { + "mode": ["r"], + "type": "range", + "value": { + "r": { + "except": [], + "max": 59, + "min": 0, + "step": 1 + } + } + }, + "totalHour": { + "mode": ["r"], + "type": "range", + "value": { + "r": { + "except": [], + "max": 30, + "min": 0, + "step": 1 + } + } + }, + "totalMinute": { + "mode": ["r"], + "type": "range", + "value": { + "r": { + "except": [], + "max": 59, + "min": 0, + "step": 1 + } + } + } + } + } + ] +} diff --git a/tests/components/lg_thinq/fixtures/washer/status.json b/tests/components/lg_thinq/fixtures/washer/status.json new file mode 100644 index 00000000000..f325bc34691 --- /dev/null +++ b/tests/components/lg_thinq/fixtures/washer/status.json @@ -0,0 +1,22 @@ +{ + "cycle": { + "cycleCount": 10 + }, + "location": { + "locationName": "MAIN" + }, + "remoteControlEnable": { + "remoteControlEnabled": false + }, + "runState": { + "currentState": "POWER_OFF" + }, + "timer": { + "relativeHourToStart": 0, + "relativeMinuteToStart": 0, + "remainHour": 0, + "remainMinute": 45, + "totalHour": 0, + "totalMinute": 50 + } +} diff --git a/tests/components/lg_thinq/snapshots/test_climate.ambr b/tests/components/lg_thinq/snapshots/test_climate.ambr index 66d842050ab..5c05244b313 100644 --- a/tests/components/lg_thinq/snapshots/test_climate.ambr +++ b/tests/components/lg_thinq/snapshots/test_climate.ambr @@ -1,5 +1,5 @@ # serializer version: 1 -# name: test_all_entities[climate.test_air_conditioner-entry] +# name: test_climate_entities[air_conditioner][climate.test_air_conditioner-entry] EntityRegistryEntrySnapshot({ 'aliases': set({ }), @@ -60,7 +60,7 @@ 'unit_of_measurement': None, }) # --- -# name: test_all_entities[climate.test_air_conditioner-state] +# name: test_climate_entities[air_conditioner][climate.test_air_conditioner-state] StateSnapshot({ 'attributes': ReadOnlyDict({ 'current_humidity': 40, diff --git a/tests/components/lg_thinq/snapshots/test_event.ambr b/tests/components/lg_thinq/snapshots/test_event.ambr index 670ce8985fa..3f9e11849ab 100644 --- a/tests/components/lg_thinq/snapshots/test_event.ambr +++ b/tests/components/lg_thinq/snapshots/test_event.ambr @@ -1,5 +1,5 @@ # serializer version: 1 -# name: test_all_entities[event.test_air_conditioner_notification-entry] +# name: test_event_entities[air_conditioner][event.test_air_conditioner_notification-entry] EntityRegistryEntrySnapshot({ 'aliases': set({ }), @@ -38,7 +38,7 @@ 'unit_of_measurement': None, }) # --- -# name: test_all_entities[event.test_air_conditioner_notification-state] +# name: test_event_entities[air_conditioner][event.test_air_conditioner_notification-state] StateSnapshot({ 'attributes': ReadOnlyDict({ 'event_type': None, diff --git a/tests/components/lg_thinq/snapshots/test_number.ambr b/tests/components/lg_thinq/snapshots/test_number.ambr index 5fa03b60033..28403ab7337 100644 --- a/tests/components/lg_thinq/snapshots/test_number.ambr +++ b/tests/components/lg_thinq/snapshots/test_number.ambr @@ -1,5 +1,5 @@ # serializer version: 1 -# name: test_all_entities[number.test_air_conditioner_schedule_turn_off-entry] +# name: test_number_entities[air_conditioner][number.test_air_conditioner_schedule_turn_off-entry] EntityRegistryEntrySnapshot({ 'aliases': set({ }), @@ -39,7 +39,7 @@ 'unit_of_measurement': , }) # --- -# name: test_all_entities[number.test_air_conditioner_schedule_turn_off-state] +# name: test_number_entities[air_conditioner][number.test_air_conditioner_schedule_turn_off-state] StateSnapshot({ 'attributes': ReadOnlyDict({ 'friendly_name': 'Test air conditioner Schedule turn-off', @@ -57,7 +57,7 @@ 'state': 'unknown', }) # --- -# name: test_all_entities[number.test_air_conditioner_schedule_turn_on-entry] +# name: test_number_entities[air_conditioner][number.test_air_conditioner_schedule_turn_on-entry] EntityRegistryEntrySnapshot({ 'aliases': set({ }), @@ -97,7 +97,7 @@ 'unit_of_measurement': , }) # --- -# name: test_all_entities[number.test_air_conditioner_schedule_turn_on-state] +# name: test_number_entities[air_conditioner][number.test_air_conditioner_schedule_turn_on-state] StateSnapshot({ 'attributes': ReadOnlyDict({ 'friendly_name': 'Test air conditioner Schedule turn-on', @@ -115,3 +115,61 @@ 'state': 'unknown', }) # --- +# name: test_number_entities[washer][number.test_washer_delayed_start-entry] + EntityRegistryEntrySnapshot({ + 'aliases': set({ + }), + 'area_id': None, + 'capabilities': dict({ + 'max': 19, + 'min': 0, + 'mode': , + 'step': 1, + }), + 'config_entry_id': , + 'config_subentry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'number', + 'entity_category': None, + 'entity_id': 'number.test_washer_delayed_start', + 'has_entity_name': True, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'options': dict({ + }), + 'original_device_class': None, + 'original_icon': None, + 'original_name': 'Delayed start', + 'platform': 'lg_thinq', + 'previous_unique_id': None, + 'suggested_object_id': None, + 'supported_features': 0, + 'translation_key': , + 'unique_id': 'MW2-0B530EFD-1ADF-4F54-A2C3-46C37F94C689_main_relative_hour_to_start', + 'unit_of_measurement': , + }) +# --- +# name: test_number_entities[washer][number.test_washer_delayed_start-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + 'friendly_name': 'Test washer Delayed start', + 'max': 19, + 'min': 0, + 'mode': , + 'step': 1, + 'unit_of_measurement': , + }), + 'context': , + 'entity_id': 'number.test_washer_delayed_start', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': '0', + }) +# --- diff --git a/tests/components/lg_thinq/snapshots/test_sensor.ambr b/tests/components/lg_thinq/snapshots/test_sensor.ambr index 3f42d7e4f5c..1ab4ede5a5b 100644 --- a/tests/components/lg_thinq/snapshots/test_sensor.ambr +++ b/tests/components/lg_thinq/snapshots/test_sensor.ambr @@ -1,5 +1,5 @@ # serializer version: 1 -# name: test_all_entities[sensor.test_air_conditioner_filter_remaining-entry] +# name: test_sensor_entities[air_conditioner][sensor.test_air_conditioner_filter_remaining-entry] EntityRegistryEntrySnapshot({ 'aliases': set({ }), @@ -34,7 +34,7 @@ 'unit_of_measurement': , }) # --- -# name: test_all_entities[sensor.test_air_conditioner_filter_remaining-state] +# name: test_sensor_entities[air_conditioner][sensor.test_air_conditioner_filter_remaining-state] StateSnapshot({ 'attributes': ReadOnlyDict({ 'friendly_name': 'Test air conditioner Filter remaining', @@ -48,7 +48,7 @@ 'state': '540', }) # --- -# name: test_all_entities[sensor.test_air_conditioner_humidity-entry] +# name: test_sensor_entities[air_conditioner][sensor.test_air_conditioner_humidity-entry] EntityRegistryEntrySnapshot({ 'aliases': set({ }), @@ -85,7 +85,7 @@ 'unit_of_measurement': '%', }) # --- -# name: test_all_entities[sensor.test_air_conditioner_humidity-state] +# name: test_sensor_entities[air_conditioner][sensor.test_air_conditioner_humidity-state] StateSnapshot({ 'attributes': ReadOnlyDict({ 'device_class': 'humidity', @@ -101,7 +101,7 @@ 'state': '40', }) # --- -# name: test_all_entities[sensor.test_air_conditioner_pm1-entry] +# name: test_sensor_entities[air_conditioner][sensor.test_air_conditioner_pm1-entry] EntityRegistryEntrySnapshot({ 'aliases': set({ }), @@ -138,7 +138,7 @@ 'unit_of_measurement': 'μg/m³', }) # --- -# name: test_all_entities[sensor.test_air_conditioner_pm1-state] +# name: test_sensor_entities[air_conditioner][sensor.test_air_conditioner_pm1-state] StateSnapshot({ 'attributes': ReadOnlyDict({ 'device_class': 'pm1', @@ -154,7 +154,7 @@ 'state': '12', }) # --- -# name: test_all_entities[sensor.test_air_conditioner_pm10-entry] +# name: test_sensor_entities[air_conditioner][sensor.test_air_conditioner_pm10-entry] EntityRegistryEntrySnapshot({ 'aliases': set({ }), @@ -191,7 +191,7 @@ 'unit_of_measurement': 'μg/m³', }) # --- -# name: test_all_entities[sensor.test_air_conditioner_pm10-state] +# name: test_sensor_entities[air_conditioner][sensor.test_air_conditioner_pm10-state] StateSnapshot({ 'attributes': ReadOnlyDict({ 'device_class': 'pm10', @@ -207,7 +207,7 @@ 'state': '7', }) # --- -# name: test_all_entities[sensor.test_air_conditioner_pm2_5-entry] +# name: test_sensor_entities[air_conditioner][sensor.test_air_conditioner_pm2_5-entry] EntityRegistryEntrySnapshot({ 'aliases': set({ }), @@ -244,7 +244,7 @@ 'unit_of_measurement': 'μg/m³', }) # --- -# name: test_all_entities[sensor.test_air_conditioner_pm2_5-state] +# name: test_sensor_entities[air_conditioner][sensor.test_air_conditioner_pm2_5-state] StateSnapshot({ 'attributes': ReadOnlyDict({ 'device_class': 'pm25', @@ -260,7 +260,7 @@ 'state': '24', }) # --- -# name: test_all_entities[sensor.test_air_conditioner_schedule_turn_off-entry] +# name: test_sensor_entities[air_conditioner][sensor.test_air_conditioner_schedule_turn_off-entry] EntityRegistryEntrySnapshot({ 'aliases': set({ }), @@ -298,7 +298,7 @@ 'unit_of_measurement': , }) # --- -# name: test_all_entities[sensor.test_air_conditioner_schedule_turn_off-state] +# name: test_sensor_entities[air_conditioner][sensor.test_air_conditioner_schedule_turn_off-state] StateSnapshot({ 'attributes': ReadOnlyDict({ 'device_class': 'duration', @@ -313,7 +313,7 @@ 'state': 'unknown', }) # --- -# name: test_all_entities[sensor.test_air_conditioner_schedule_turn_on-entry] +# name: test_sensor_entities[air_conditioner][sensor.test_air_conditioner_schedule_turn_on-entry] EntityRegistryEntrySnapshot({ 'aliases': set({ }), @@ -351,7 +351,7 @@ 'unit_of_measurement': , }) # --- -# name: test_all_entities[sensor.test_air_conditioner_schedule_turn_on-state] +# name: test_sensor_entities[air_conditioner][sensor.test_air_conditioner_schedule_turn_on-state] StateSnapshot({ 'attributes': ReadOnlyDict({ 'device_class': 'duration', @@ -366,7 +366,7 @@ 'state': 'unknown', }) # --- -# name: test_all_entities[sensor.test_air_conditioner_schedule_turn_on_2-entry] +# name: test_sensor_entities[air_conditioner][sensor.test_air_conditioner_schedule_turn_on_2-entry] EntityRegistryEntrySnapshot({ 'aliases': set({ }), @@ -401,7 +401,7 @@ 'unit_of_measurement': None, }) # --- -# name: test_all_entities[sensor.test_air_conditioner_schedule_turn_on_2-state] +# name: test_sensor_entities[air_conditioner][sensor.test_air_conditioner_schedule_turn_on_2-state] StateSnapshot({ 'attributes': ReadOnlyDict({ 'device_class': 'timestamp', diff --git a/tests/components/lg_thinq/snapshots/test_switch.ambr b/tests/components/lg_thinq/snapshots/test_switch.ambr new file mode 100644 index 00000000000..e427916630b --- /dev/null +++ b/tests/components/lg_thinq/snapshots/test_switch.ambr @@ -0,0 +1,197 @@ +# serializer version: 1 +# name: test_switch_entities[washer][switch.test_washer_power-entry] + EntityRegistryEntrySnapshot({ + 'aliases': set({ + }), + 'area_id': None, + 'capabilities': None, + 'config_entry_id': , + 'config_subentry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'switch', + 'entity_category': None, + 'entity_id': 'switch.test_washer_power', + 'has_entity_name': True, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'options': dict({ + }), + 'original_device_class': , + 'original_icon': None, + 'original_name': 'Power', + 'platform': 'lg_thinq', + 'previous_unique_id': None, + 'suggested_object_id': None, + 'supported_features': 0, + 'translation_key': 'operation_power', + 'unique_id': 'MW2-0B530EFD-1ADF-4F54-A2C3-46C37F94C689_main_washer_operation_mode', + 'unit_of_measurement': None, + }) +# --- +# name: test_switch_entities[washer][switch.test_washer_power-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + 'device_class': 'switch', + 'friendly_name': 'Test washer Power', + }), + 'context': , + 'entity_id': 'switch.test_washer_power', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': 'off', + }) +# --- +# name: test_switch_entities[air_conditioner][switch.test_air_conditioner_power-entry] + EntityRegistryEntrySnapshot({ + 'aliases': set({ + }), + 'area_id': None, + 'capabilities': None, + 'config_entry_id': , + 'config_subentry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'switch', + 'entity_category': , + 'entity_id': 'switch.test_air_conditioner_power', + 'has_entity_name': True, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'options': dict({ + }), + 'original_device_class': , + 'original_icon': None, + 'original_name': 'Power', + 'platform': 'lg_thinq', + 'previous_unique_id': None, + 'suggested_object_id': None, + 'supported_features': 0, + 'translation_key': 'operation_power', + 'unique_id': 'MW2-2E247F93-B570-46A6-B827-920E9E10F966_air_con_operation_mode', + 'unit_of_measurement': None, + }) +# --- +# name: test_switch_entities[air_conditioner][switch.test_air_conditioner_power-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + 'device_class': 'switch', + 'friendly_name': 'Test air conditioner Power', + }), + 'context': , + 'entity_id': 'switch.test_air_conditioner_power', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': 'on', + }) +# --- +# name: test_switch_entities[air_conditioner][switch.test_air_conditioner_energy_saving-entry] + EntityRegistryEntrySnapshot({ + 'aliases': set({ + }), + 'area_id': None, + 'capabilities': None, + 'config_entry_id': , + 'config_subentry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'switch', + 'entity_category': , + 'entity_id': 'switch.test_air_conditioner_energy_saving', + 'has_entity_name': True, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'options': dict({ + }), + 'original_device_class': , + 'original_icon': None, + 'original_name': 'Energy saving', + 'platform': 'lg_thinq', + 'previous_unique_id': None, + 'suggested_object_id': None, + 'supported_features': 0, + 'translation_key': , + 'unique_id': 'MW2-2E247F93-B570-46A6-B827-920E9E10F966_power_save_enabled', + 'unit_of_measurement': None, + }) +# --- +# name: test_switch_entities[air_conditioner][switch.test_air_conditioner_energy_saving-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + 'device_class': 'switch', + 'friendly_name': 'Test air conditioner Energy saving', + }), + 'context': , + 'entity_id': 'switch.test_air_conditioner_energy_saving', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': 'off', + }) +# --- +# name: test_switch_entities[air_conditioner][switch.test_air_conditioner_air_purify-entry] + EntityRegistryEntrySnapshot({ + 'aliases': set({ + }), + 'area_id': None, + 'capabilities': None, + 'config_entry_id': , + 'config_subentry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'switch', + 'entity_category': , + 'entity_id': 'switch.test_air_conditioner_air_purify', + 'has_entity_name': True, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'options': dict({ + }), + 'original_device_class': , + 'original_icon': None, + 'original_name': 'Air purify', + 'platform': 'lg_thinq', + 'previous_unique_id': None, + 'suggested_object_id': None, + 'supported_features': 0, + 'translation_key': , + 'unique_id': 'MW2-2E247F93-B570-46A6-B827-920E9E10F966_air_clean_operation_mode', + 'unit_of_measurement': None, + }) +# --- +# name: test_switch_entities[air_conditioner][switch.test_air_conditioner_air_purify-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + 'device_class': 'switch', + 'friendly_name': 'Test air conditioner Air purify', + }), + 'context': , + 'entity_id': 'switch.test_air_conditioner_air_purify', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': 'off', + }) +# --- \ No newline at end of file diff --git a/tests/components/lg_thinq/test_climate.py b/tests/components/lg_thinq/test_climate.py index c79331dd638..6b80151805c 100644 --- a/tests/components/lg_thinq/test_climate.py +++ b/tests/components/lg_thinq/test_climate.py @@ -16,9 +16,11 @@ from tests.common import MockConfigEntry, snapshot_platform @pytest.mark.usefixtures("entity_registry_enabled_by_default") -async def test_all_entities( +@pytest.mark.parametrize("device_fixture", ["air_conditioner"]) +async def test_climate_entities( hass: HomeAssistant, snapshot: SnapshotAssertion, + devices: AsyncMock, mock_thinq_api: AsyncMock, mock_config_entry: MockConfigEntry, entity_registry: er.EntityRegistry, diff --git a/tests/components/lg_thinq/test_config_flow.py b/tests/components/lg_thinq/test_config_flow.py index a46162723f0..2612519824d 100644 --- a/tests/components/lg_thinq/test_config_flow.py +++ b/tests/components/lg_thinq/test_config_flow.py @@ -49,8 +49,7 @@ async def test_config_flow( async def test_config_flow_invalid_pat( - hass: HomeAssistant, - mock_invalid_thinq_api: AsyncMock, + hass: HomeAssistant, mock_invalid_thinq_api: AsyncMock ) -> None: """Test that an thinq flow should be aborted with an invalid PAT.""" result = await hass.config_entries.flow.async_init( diff --git a/tests/components/lg_thinq/test_event.py b/tests/components/lg_thinq/test_event.py index 398af1e8aad..c6aa176c429 100644 --- a/tests/components/lg_thinq/test_event.py +++ b/tests/components/lg_thinq/test_event.py @@ -15,9 +15,11 @@ from tests.common import MockConfigEntry, snapshot_platform @pytest.mark.usefixtures("entity_registry_enabled_by_default") -async def test_all_entities( +@pytest.mark.parametrize("device_fixture", ["air_conditioner"]) +async def test_event_entities( hass: HomeAssistant, snapshot: SnapshotAssertion, + devices: AsyncMock, mock_thinq_api: AsyncMock, mock_config_entry: MockConfigEntry, entity_registry: er.EntityRegistry, diff --git a/tests/components/lg_thinq/test_number.py b/tests/components/lg_thinq/test_number.py index 7c37ba3f5e0..b36685a8aa4 100644 --- a/tests/components/lg_thinq/test_number.py +++ b/tests/components/lg_thinq/test_number.py @@ -15,9 +15,10 @@ from tests.common import MockConfigEntry, snapshot_platform @pytest.mark.usefixtures("entity_registry_enabled_by_default") -async def test_all_entities( +async def test_number_entities( hass: HomeAssistant, snapshot: SnapshotAssertion, + devices: AsyncMock, mock_thinq_api: AsyncMock, mock_config_entry: MockConfigEntry, entity_registry: er.EntityRegistry, diff --git a/tests/components/lg_thinq/test_sensor.py b/tests/components/lg_thinq/test_sensor.py index e2c8e122eea..87f03de6c0d 100644 --- a/tests/components/lg_thinq/test_sensor.py +++ b/tests/components/lg_thinq/test_sensor.py @@ -15,11 +15,13 @@ from . import setup_integration from tests.common import MockConfigEntry, snapshot_platform +@pytest.mark.parametrize("device_fixture", ["air_conditioner"]) @pytest.mark.usefixtures("entity_registry_enabled_by_default") @pytest.mark.freeze_time(datetime(2024, 10, 10, tzinfo=UTC)) -async def test_all_entities( +async def test_sensor_entities( hass: HomeAssistant, snapshot: SnapshotAssertion, + devices: AsyncMock, mock_thinq_api: AsyncMock, mock_config_entry: MockConfigEntry, entity_registry: er.EntityRegistry, diff --git a/tests/components/lg_thinq/test_switch.py b/tests/components/lg_thinq/test_switch.py new file mode 100644 index 00000000000..0e2039f49d0 --- /dev/null +++ b/tests/components/lg_thinq/test_switch.py @@ -0,0 +1,28 @@ +"""Tests for the LG ThinQ switch platform.""" + +from unittest.mock import AsyncMock, patch + +from syrupy.assertion import SnapshotAssertion + +from homeassistant.const import Platform +from homeassistant.core import HomeAssistant +from homeassistant.helpers import entity_registry as er + +from . import setup_integration + +from tests.common import MockConfigEntry, snapshot_platform + + +async def test_switch_entities( + hass: HomeAssistant, + snapshot: SnapshotAssertion, + devices: AsyncMock, + mock_thinq_api: AsyncMock, + mock_config_entry: MockConfigEntry, + entity_registry: er.EntityRegistry, +) -> None: + """Test all entities.""" + with patch("homeassistant.components.lg_thinq.PLATFORMS", [Platform.SWITCH]): + await setup_integration(hass, mock_config_entry) + + await snapshot_platform(hass, entity_registry, snapshot, mock_config_entry.entry_id)