Add switch for AC's air_clean, ventilator and washers to LG (#140842)

Co-authored-by: yunseon.park <yunseon.park@lge.com>
This commit is contained in:
LG-ThinQ-Integration
2025-08-25 13:42:14 +09:00
committed by GitHub
parent 91ef5fb429
commit e1e11db3d2
19 changed files with 581 additions and 41 deletions

View File

@@ -45,6 +45,9 @@
},
"display_light": {
"default": "mdi:lightbulb-on-outline"
},
"air_clean_operation_mode": {
"default": "mdi:air-filter"
}
},
"binary_sensor": {

View File

@@ -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": {

View File

@@ -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,
)
)

View File

@@ -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

View File

@@ -44,7 +44,6 @@
"unit": "F"
}
],
"timer": {
"relativeStartTimer": "UNSET",
"relativeStopTimer": "UNSET",

View File

@@ -0,0 +1,9 @@
{
"deviceId": "MW2-0B530EFD-1ADF-4F54-A2C3-46C37F94C689",
"deviceInfo": {
"deviceType": "DEVICE_WASHER",
"modelName": "FAFXU22027",
"alias": "Test washer",
"reportable": true
}
}

View File

@@ -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
}
}
}
}
}
]
}

View File

@@ -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
}
}

View File

@@ -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,

View File

@@ -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,

View File

@@ -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': <UnitOfTime.HOURS: 'h'>,
})
# ---
# 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': <UnitOfTime.HOURS: 'h'>,
})
# ---
# 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': <NumberMode.BOX: 'box'>,
'step': 1,
}),
'config_entry_id': <ANY>,
'config_subentry_id': <ANY>,
'device_class': None,
'device_id': <ANY>,
'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': <ANY>,
'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': <TimerProperty.RELATIVE_HOUR_TO_START_WM: 'relative_hour_to_start_wm'>,
'unique_id': 'MW2-0B530EFD-1ADF-4F54-A2C3-46C37F94C689_main_relative_hour_to_start',
'unit_of_measurement': <UnitOfTime.HOURS: 'h'>,
})
# ---
# 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': <NumberMode.BOX: 'box'>,
'step': 1,
'unit_of_measurement': <UnitOfTime.HOURS: 'h'>,
}),
'context': <ANY>,
'entity_id': 'number.test_washer_delayed_start',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': '0',
})
# ---

View File

@@ -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': <UnitOfTime.HOURS: 'h'>,
})
# ---
# 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': <UnitOfTime.MINUTES: 'min'>,
})
# ---
# 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': <UnitOfTime.MINUTES: 'min'>,
})
# ---
# 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',

View File

@@ -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': <ANY>,
'config_subentry_id': <ANY>,
'device_class': None,
'device_id': <ANY>,
'disabled_by': None,
'domain': 'switch',
'entity_category': None,
'entity_id': 'switch.test_washer_power',
'has_entity_name': True,
'hidden_by': None,
'icon': None,
'id': <ANY>,
'labels': set({
}),
'name': None,
'options': dict({
}),
'original_device_class': <SwitchDeviceClass.SWITCH: 'switch'>,
'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': <ANY>,
'entity_id': 'switch.test_washer_power',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'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': <ANY>,
'config_subentry_id': <ANY>,
'device_class': None,
'device_id': <ANY>,
'disabled_by': None,
'domain': 'switch',
'entity_category': <EntityCategory.CONFIG: 'config'>,
'entity_id': 'switch.test_air_conditioner_power',
'has_entity_name': True,
'hidden_by': None,
'icon': None,
'id': <ANY>,
'labels': set({
}),
'name': None,
'options': dict({
}),
'original_device_class': <SwitchDeviceClass.SWITCH: 'switch'>,
'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': <ANY>,
'entity_id': 'switch.test_air_conditioner_power',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'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': <ANY>,
'config_subentry_id': <ANY>,
'device_class': None,
'device_id': <ANY>,
'disabled_by': None,
'domain': 'switch',
'entity_category': <EntityCategory.CONFIG: 'config'>,
'entity_id': 'switch.test_air_conditioner_energy_saving',
'has_entity_name': True,
'hidden_by': None,
'icon': None,
'id': <ANY>,
'labels': set({
}),
'name': None,
'options': dict({
}),
'original_device_class': <SwitchDeviceClass.SWITCH: 'switch'>,
'original_icon': None,
'original_name': 'Energy saving',
'platform': 'lg_thinq',
'previous_unique_id': None,
'suggested_object_id': None,
'supported_features': 0,
'translation_key': <Property.POWER_SAVE_ENABLED: 'power_save_enabled'>,
'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': <ANY>,
'entity_id': 'switch.test_air_conditioner_energy_saving',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'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': <ANY>,
'config_subentry_id': <ANY>,
'device_class': None,
'device_id': <ANY>,
'disabled_by': None,
'domain': 'switch',
'entity_category': <EntityCategory.CONFIG: 'config'>,
'entity_id': 'switch.test_air_conditioner_air_purify',
'has_entity_name': True,
'hidden_by': None,
'icon': None,
'id': <ANY>,
'labels': set({
}),
'name': None,
'options': dict({
}),
'original_device_class': <SwitchDeviceClass.SWITCH: 'switch'>,
'original_icon': None,
'original_name': 'Air purify',
'platform': 'lg_thinq',
'previous_unique_id': None,
'suggested_object_id': None,
'supported_features': 0,
'translation_key': <Property.AIR_CLEAN_OPERATION_MODE: 'air_clean_operation_mode'>,
'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': <ANY>,
'entity_id': 'switch.test_air_conditioner_air_purify',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': 'off',
})
# ---

View File

@@ -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,

View File

@@ -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(

View File

@@ -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,

View File

@@ -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,

View File

@@ -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,

View File

@@ -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)