Fix SmartThings disabling working capabilities (#140039)

This commit is contained in:
Joost Lekkerkerker 2025-03-07 12:55:32 +01:00 committed by GitHub
parent 2985f08054
commit 73ef240921
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 2241 additions and 4 deletions

View File

@ -2,6 +2,7 @@
from __future__ import annotations
from collections.abc import Callable
from dataclasses import dataclass
import logging
from typing import TYPE_CHECKING, cast
@ -185,6 +186,16 @@ async def async_migrate_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
return True
DATA_VALIDATION: dict[
Capability | str, Callable[[dict[Attribute | str, Status]], bool]
] = {
Capability.WASHER_OPERATING_STATE: (
lambda status: status[Attribute.SUPPORTED_MACHINE_STATES].value is not None
),
Capability.DEMAND_RESPONSE_LOAD_CONTROL: lambda _: True,
}
def process_status(
status: dict[str, dict[Capability | str, dict[Attribute | str, Status]]],
) -> dict[str, dict[Capability | str, dict[Attribute | str, Status]]]:
@ -201,10 +212,9 @@ def process_status(
)
if disabled_capabilities is not None:
for capability in disabled_capabilities:
# We still need to make sure the climate entity can work without this capability
if (
capability in main_component
and capability != Capability.DEMAND_RESPONSE_LOAD_CONTROL
if capability in main_component and (
capability not in DATA_VALIDATION
or not DATA_VALIDATION[capability](main_component[capability])
):
del main_component[capability]
return status

View File

@ -105,6 +105,7 @@ def mock_smartthings() -> Generator[AsyncMock]:
"da_wm_dw_000001",
"da_wm_wd_000001",
"da_wm_wm_000001",
"da_wm_wm_000001_1",
"da_rvc_normal_000001",
"da_ks_microwave_0101x",
"hue_color_temperature_bulb",

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,261 @@
{
"items": [
{
"deviceId": "63803fae-cbed-f356-a063-2cf148ae3ca7",
"name": "[washer] Samsung",
"label": "Washing Machine",
"manufacturerName": "Samsung Electronics",
"presentationId": "DA-WM-WM-000001",
"deviceManufacturerCode": "Samsung Electronics",
"locationId": "ca23214d-d9ae-41e5-9d26-f1a604c864d8",
"ownerId": "9b53a4ba-4422-b04d-f436-33c0490e7c37",
"roomId": "e226f1ae-1112-4794-bd3a-0beddf811645",
"deviceTypeName": "Samsung OCF Washer",
"components": [
{
"id": "main",
"label": "Washing Machine",
"capabilities": [
{
"id": "execute",
"version": 1
},
{
"id": "ocf",
"version": 1
},
{
"id": "powerConsumptionReport",
"version": 1
},
{
"id": "refresh",
"version": 1
},
{
"id": "remoteControlStatus",
"version": 1
},
{
"id": "demandResponseLoadControl",
"version": 1
},
{
"id": "switch",
"version": 1
},
{
"id": "washerOperatingState",
"version": 1
},
{
"id": "custom.disabledCapabilities",
"version": 1
},
{
"id": "custom.dryerDryLevel",
"version": 1
},
{
"id": "custom.energyType",
"version": 1
},
{
"id": "custom.jobBeginningStatus",
"version": 1
},
{
"id": "custom.supportedOptions",
"version": 1
},
{
"id": "custom.washerAutoDetergent",
"version": 1
},
{
"id": "custom.washerAutoSoftener",
"version": 1
},
{
"id": "custom.washerRinseCycles",
"version": 1
},
{
"id": "custom.washerSoilLevel",
"version": 1
},
{
"id": "custom.washerSpinLevel",
"version": 1
},
{
"id": "custom.washerWaterTemperature",
"version": 1
},
{
"id": "samsungce.autoDispenseDetergent",
"version": 1
},
{
"id": "samsungce.autoDispenseSoftener",
"version": 1
},
{
"id": "samsungce.detergentOrder",
"version": 1
},
{
"id": "samsungce.detergentState",
"version": 1
},
{
"id": "samsungce.deviceIdentification",
"version": 1
},
{
"id": "samsungce.dongleSoftwareInstallation",
"version": 1
},
{
"id": "samsungce.detergentAutoReplenishment",
"version": 1
},
{
"id": "samsungce.softenerAutoReplenishment",
"version": 1
},
{
"id": "samsungce.driverVersion",
"version": 1
},
{
"id": "samsungce.softwareUpdate",
"version": 1
},
{
"id": "samsungce.kidsLock",
"version": 1
},
{
"id": "samsungce.softenerOrder",
"version": 1
},
{
"id": "samsungce.softenerState",
"version": 1
},
{
"id": "samsungce.washerBubbleSoak",
"version": 1
},
{
"id": "samsungce.washerCycle",
"version": 1
},
{
"id": "samsungce.washerCyclePreset",
"version": 1
},
{
"id": "samsungce.washerDelayEnd",
"version": 1
},
{
"id": "samsungce.washerFreezePrevent",
"version": 1
},
{
"id": "samsungce.washerOperatingState",
"version": 1
},
{
"id": "samsungce.washerWashingTime",
"version": 1
},
{
"id": "samsungce.washerWaterLevel",
"version": 1
},
{
"id": "samsungce.washerWaterValve",
"version": 1
},
{
"id": "samsungce.welcomeMessage",
"version": 1
},
{
"id": "samsungce.waterConsumptionReport",
"version": 1
},
{
"id": "samsungce.quickControl",
"version": 1
},
{
"id": "samsungce.energyPlanner",
"version": 1
},
{
"id": "sec.diagnosticsInformation",
"version": 1
},
{
"id": "sec.wifiConfiguration",
"version": 1
}
],
"categories": [
{
"name": "Washer",
"categoryType": "manufacturer"
}
]
},
{
"id": "hca.main",
"label": "hca.main",
"capabilities": [
{
"id": "hca.washerMode",
"version": 1
}
],
"categories": [
{
"name": "Other",
"categoryType": "manufacturer"
}
]
}
],
"createTime": "2020-03-04T03:03:19Z",
"profile": {
"id": "3f221c79-d81c-315f-8e8b-b5742802a1e3"
},
"ocf": {
"ocfDeviceType": "oic.d.washer",
"name": "[washer] Samsung",
"specVersion": "core.1.1.0",
"verticalDomainSpecVersion": "1.2.1",
"manufacturerName": "Samsung Electronics",
"modelNumber": "DA_WM_A51_20_COMMON|20224941|20010102011211030203000000000000",
"platformVersion": "DAWIT 2.0",
"platformOS": "TizenRT 1.0 + IPv6",
"hwVersion": "ARTIK051",
"firmwareVersion": "DA_WM_A51_20_COMMON_30230708",
"vendorId": "DA-WM-WM-000001",
"vendorResourceClientServerVersion": "ARTIK051 Release 2.210224.1",
"lastSignupTime": "2024-12-27T04:47:59.763899737Z",
"transferCandidate": false,
"additionalAuthCodeRequired": false
},
"type": "OCF",
"restrictionTier": 0,
"allowed": null,
"executionContext": "CLOUD",
"relationships": []
}
],
"_links": {}
}

View File

@ -494,6 +494,39 @@
'via_device_id': None,
})
# ---
# name: test_devices[da_wm_wm_000001_1]
DeviceRegistryEntrySnapshot({
'area_id': None,
'config_entries': <ANY>,
'config_entries_subentries': <ANY>,
'configuration_url': 'https://account.smartthings.com',
'connections': set({
}),
'disabled_by': None,
'entry_type': None,
'hw_version': 'ARTIK051',
'id': <ANY>,
'identifiers': set({
tuple(
'smartthings',
'63803fae-cbed-f356-a063-2cf148ae3ca7',
),
}),
'is_new': False,
'labels': set({
}),
'manufacturer': 'Samsung Electronics',
'model': 'DA_WM_A51_20_COMMON',
'model_id': None,
'name': 'Washing Machine',
'name_by_user': None,
'primary_config_entry': <ANY>,
'serial_number': None,
'suggested_area': None,
'sw_version': 'DA_WM_A51_20_COMMON_30230708',
'via_device_id': None,
})
# ---
# name: test_devices[ecobee_sensor]
DeviceRegistryEntrySnapshot({
'area_id': None,

View File

@ -3899,6 +3899,475 @@
'state': '0.0',
})
# ---
# name: test_all_entities[da_wm_wm_000001_1][sensor.washing_machine_completion_time-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': 'sensor',
'entity_category': None,
'entity_id': 'sensor.washing_machine_completion_time',
'has_entity_name': True,
'hidden_by': None,
'icon': None,
'id': <ANY>,
'labels': set({
}),
'name': None,
'options': dict({
}),
'original_device_class': <SensorDeviceClass.TIMESTAMP: 'timestamp'>,
'original_icon': None,
'original_name': 'Completion time',
'platform': 'smartthings',
'previous_unique_id': None,
'supported_features': 0,
'translation_key': 'completion_time',
'unique_id': '63803fae-cbed-f356-a063-2cf148ae3ca7.completionTime',
'unit_of_measurement': None,
})
# ---
# name: test_all_entities[da_wm_wm_000001_1][sensor.washing_machine_completion_time-state]
StateSnapshot({
'attributes': ReadOnlyDict({
'device_class': 'timestamp',
'friendly_name': 'Washing Machine Completion time',
}),
'context': <ANY>,
'entity_id': 'sensor.washing_machine_completion_time',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': '2025-03-07T07:01:12+00:00',
})
# ---
# name: test_all_entities[da_wm_wm_000001_1][sensor.washing_machine_energy-entry]
EntityRegistryEntrySnapshot({
'aliases': set({
}),
'area_id': None,
'capabilities': dict({
'state_class': <SensorStateClass.TOTAL_INCREASING: 'total_increasing'>,
}),
'config_entry_id': <ANY>,
'config_subentry_id': <ANY>,
'device_class': None,
'device_id': <ANY>,
'disabled_by': None,
'domain': 'sensor',
'entity_category': None,
'entity_id': 'sensor.washing_machine_energy',
'has_entity_name': True,
'hidden_by': None,
'icon': None,
'id': <ANY>,
'labels': set({
}),
'name': None,
'options': dict({
'sensor': dict({
'suggested_display_precision': 2,
}),
}),
'original_device_class': <SensorDeviceClass.ENERGY: 'energy'>,
'original_icon': None,
'original_name': 'Energy',
'platform': 'smartthings',
'previous_unique_id': None,
'supported_features': 0,
'translation_key': None,
'unique_id': '63803fae-cbed-f356-a063-2cf148ae3ca7.energy_meter',
'unit_of_measurement': <UnitOfEnergy.KILO_WATT_HOUR: 'kWh'>,
})
# ---
# name: test_all_entities[da_wm_wm_000001_1][sensor.washing_machine_energy-state]
StateSnapshot({
'attributes': ReadOnlyDict({
'device_class': 'energy',
'friendly_name': 'Washing Machine Energy',
'state_class': <SensorStateClass.TOTAL_INCREASING: 'total_increasing'>,
'unit_of_measurement': <UnitOfEnergy.KILO_WATT_HOUR: 'kWh'>,
}),
'context': <ANY>,
'entity_id': 'sensor.washing_machine_energy',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': '1323.6',
})
# ---
# name: test_all_entities[da_wm_wm_000001_1][sensor.washing_machine_energy_difference-entry]
EntityRegistryEntrySnapshot({
'aliases': set({
}),
'area_id': None,
'capabilities': dict({
'state_class': <SensorStateClass.TOTAL: 'total'>,
}),
'config_entry_id': <ANY>,
'config_subentry_id': <ANY>,
'device_class': None,
'device_id': <ANY>,
'disabled_by': None,
'domain': 'sensor',
'entity_category': None,
'entity_id': 'sensor.washing_machine_energy_difference',
'has_entity_name': True,
'hidden_by': None,
'icon': None,
'id': <ANY>,
'labels': set({
}),
'name': None,
'options': dict({
'sensor': dict({
'suggested_display_precision': 2,
}),
}),
'original_device_class': <SensorDeviceClass.ENERGY: 'energy'>,
'original_icon': None,
'original_name': 'Energy difference',
'platform': 'smartthings',
'previous_unique_id': None,
'supported_features': 0,
'translation_key': 'energy_difference',
'unique_id': '63803fae-cbed-f356-a063-2cf148ae3ca7.deltaEnergy_meter',
'unit_of_measurement': <UnitOfEnergy.KILO_WATT_HOUR: 'kWh'>,
})
# ---
# name: test_all_entities[da_wm_wm_000001_1][sensor.washing_machine_energy_difference-state]
StateSnapshot({
'attributes': ReadOnlyDict({
'device_class': 'energy',
'friendly_name': 'Washing Machine Energy difference',
'state_class': <SensorStateClass.TOTAL: 'total'>,
'unit_of_measurement': <UnitOfEnergy.KILO_WATT_HOUR: 'kWh'>,
}),
'context': <ANY>,
'entity_id': 'sensor.washing_machine_energy_difference',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': '0.1',
})
# ---
# name: test_all_entities[da_wm_wm_000001_1][sensor.washing_machine_energy_saved-entry]
EntityRegistryEntrySnapshot({
'aliases': set({
}),
'area_id': None,
'capabilities': dict({
'state_class': <SensorStateClass.TOTAL_INCREASING: 'total_increasing'>,
}),
'config_entry_id': <ANY>,
'config_subentry_id': <ANY>,
'device_class': None,
'device_id': <ANY>,
'disabled_by': None,
'domain': 'sensor',
'entity_category': None,
'entity_id': 'sensor.washing_machine_energy_saved',
'has_entity_name': True,
'hidden_by': None,
'icon': None,
'id': <ANY>,
'labels': set({
}),
'name': None,
'options': dict({
'sensor': dict({
'suggested_display_precision': 2,
}),
}),
'original_device_class': <SensorDeviceClass.ENERGY: 'energy'>,
'original_icon': None,
'original_name': 'Energy saved',
'platform': 'smartthings',
'previous_unique_id': None,
'supported_features': 0,
'translation_key': 'energy_saved',
'unique_id': '63803fae-cbed-f356-a063-2cf148ae3ca7.energySaved_meter',
'unit_of_measurement': <UnitOfEnergy.KILO_WATT_HOUR: 'kWh'>,
})
# ---
# name: test_all_entities[da_wm_wm_000001_1][sensor.washing_machine_energy_saved-state]
StateSnapshot({
'attributes': ReadOnlyDict({
'device_class': 'energy',
'friendly_name': 'Washing Machine Energy saved',
'state_class': <SensorStateClass.TOTAL_INCREASING: 'total_increasing'>,
'unit_of_measurement': <UnitOfEnergy.KILO_WATT_HOUR: 'kWh'>,
}),
'context': <ANY>,
'entity_id': 'sensor.washing_machine_energy_saved',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': '0.0',
})
# ---
# name: test_all_entities[da_wm_wm_000001_1][sensor.washing_machine_job_state-entry]
EntityRegistryEntrySnapshot({
'aliases': set({
}),
'area_id': None,
'capabilities': dict({
'options': list([
'air_wash',
'ai_rinse',
'ai_spin',
'ai_wash',
'cooling',
'delay_wash',
'drying',
'finish',
'none',
'pre_wash',
'rinse',
'spin',
'wash',
'weight_sensing',
'wrinkle_prevent',
'freeze_protection',
]),
}),
'config_entry_id': <ANY>,
'config_subentry_id': <ANY>,
'device_class': None,
'device_id': <ANY>,
'disabled_by': None,
'domain': 'sensor',
'entity_category': None,
'entity_id': 'sensor.washing_machine_job_state',
'has_entity_name': True,
'hidden_by': None,
'icon': None,
'id': <ANY>,
'labels': set({
}),
'name': None,
'options': dict({
}),
'original_device_class': <SensorDeviceClass.ENUM: 'enum'>,
'original_icon': None,
'original_name': 'Job state',
'platform': 'smartthings',
'previous_unique_id': None,
'supported_features': 0,
'translation_key': 'washer_job_state',
'unique_id': '63803fae-cbed-f356-a063-2cf148ae3ca7.washerJobState',
'unit_of_measurement': None,
})
# ---
# name: test_all_entities[da_wm_wm_000001_1][sensor.washing_machine_job_state-state]
StateSnapshot({
'attributes': ReadOnlyDict({
'device_class': 'enum',
'friendly_name': 'Washing Machine Job state',
'options': list([
'air_wash',
'ai_rinse',
'ai_spin',
'ai_wash',
'cooling',
'delay_wash',
'drying',
'finish',
'none',
'pre_wash',
'rinse',
'spin',
'wash',
'weight_sensing',
'wrinkle_prevent',
'freeze_protection',
]),
}),
'context': <ANY>,
'entity_id': 'sensor.washing_machine_job_state',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': 'wash',
})
# ---
# name: test_all_entities[da_wm_wm_000001_1][sensor.washing_machine_machine_state-entry]
EntityRegistryEntrySnapshot({
'aliases': set({
}),
'area_id': None,
'capabilities': dict({
'options': list([
'pause',
'run',
'stop',
]),
}),
'config_entry_id': <ANY>,
'config_subentry_id': <ANY>,
'device_class': None,
'device_id': <ANY>,
'disabled_by': None,
'domain': 'sensor',
'entity_category': None,
'entity_id': 'sensor.washing_machine_machine_state',
'has_entity_name': True,
'hidden_by': None,
'icon': None,
'id': <ANY>,
'labels': set({
}),
'name': None,
'options': dict({
}),
'original_device_class': <SensorDeviceClass.ENUM: 'enum'>,
'original_icon': None,
'original_name': 'Machine state',
'platform': 'smartthings',
'previous_unique_id': None,
'supported_features': 0,
'translation_key': 'washer_machine_state',
'unique_id': '63803fae-cbed-f356-a063-2cf148ae3ca7.machineState',
'unit_of_measurement': None,
})
# ---
# name: test_all_entities[da_wm_wm_000001_1][sensor.washing_machine_machine_state-state]
StateSnapshot({
'attributes': ReadOnlyDict({
'device_class': 'enum',
'friendly_name': 'Washing Machine Machine state',
'options': list([
'pause',
'run',
'stop',
]),
}),
'context': <ANY>,
'entity_id': 'sensor.washing_machine_machine_state',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': 'run',
})
# ---
# name: test_all_entities[da_wm_wm_000001_1][sensor.washing_machine_power-entry]
EntityRegistryEntrySnapshot({
'aliases': set({
}),
'area_id': None,
'capabilities': dict({
'state_class': <SensorStateClass.MEASUREMENT: 'measurement'>,
}),
'config_entry_id': <ANY>,
'config_subentry_id': <ANY>,
'device_class': None,
'device_id': <ANY>,
'disabled_by': None,
'domain': 'sensor',
'entity_category': None,
'entity_id': 'sensor.washing_machine_power',
'has_entity_name': True,
'hidden_by': None,
'icon': None,
'id': <ANY>,
'labels': set({
}),
'name': None,
'options': dict({
'sensor': dict({
'suggested_display_precision': 2,
}),
}),
'original_device_class': <SensorDeviceClass.POWER: 'power'>,
'original_icon': None,
'original_name': 'Power',
'platform': 'smartthings',
'previous_unique_id': None,
'supported_features': 0,
'translation_key': None,
'unique_id': '63803fae-cbed-f356-a063-2cf148ae3ca7.power_meter',
'unit_of_measurement': <UnitOfPower.WATT: 'W'>,
})
# ---
# name: test_all_entities[da_wm_wm_000001_1][sensor.washing_machine_power-state]
StateSnapshot({
'attributes': ReadOnlyDict({
'device_class': 'power',
'friendly_name': 'Washing Machine Power',
'power_consumption_end': '2025-03-07T06:23:21Z',
'power_consumption_start': '2025-03-07T06:21:09Z',
'state_class': <SensorStateClass.MEASUREMENT: 'measurement'>,
'unit_of_measurement': <UnitOfPower.WATT: 'W'>,
}),
'context': <ANY>,
'entity_id': 'sensor.washing_machine_power',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': '0',
})
# ---
# name: test_all_entities[da_wm_wm_000001_1][sensor.washing_machine_power_energy-entry]
EntityRegistryEntrySnapshot({
'aliases': set({
}),
'area_id': None,
'capabilities': dict({
'state_class': <SensorStateClass.TOTAL_INCREASING: 'total_increasing'>,
}),
'config_entry_id': <ANY>,
'config_subentry_id': <ANY>,
'device_class': None,
'device_id': <ANY>,
'disabled_by': None,
'domain': 'sensor',
'entity_category': None,
'entity_id': 'sensor.washing_machine_power_energy',
'has_entity_name': True,
'hidden_by': None,
'icon': None,
'id': <ANY>,
'labels': set({
}),
'name': None,
'options': dict({
'sensor': dict({
'suggested_display_precision': 2,
}),
}),
'original_device_class': <SensorDeviceClass.ENERGY: 'energy'>,
'original_icon': None,
'original_name': 'Power energy',
'platform': 'smartthings',
'previous_unique_id': None,
'supported_features': 0,
'translation_key': 'power_energy',
'unique_id': '63803fae-cbed-f356-a063-2cf148ae3ca7.powerEnergy_meter',
'unit_of_measurement': <UnitOfEnergy.KILO_WATT_HOUR: 'kWh'>,
})
# ---
# name: test_all_entities[da_wm_wm_000001_1][sensor.washing_machine_power_energy-state]
StateSnapshot({
'attributes': ReadOnlyDict({
'device_class': 'energy',
'friendly_name': 'Washing Machine Power energy',
'state_class': <SensorStateClass.TOTAL_INCREASING: 'total_increasing'>,
'unit_of_measurement': <UnitOfEnergy.KILO_WATT_HOUR: 'kWh'>,
}),
'context': <ANY>,
'entity_id': 'sensor.washing_machine_power_energy',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': '0.0',
})
# ---
# name: test_all_entities[ecobee_sensor][sensor.child_bedroom_temperature-entry]
EntityRegistryEntrySnapshot({
'aliases': set({

View File

@ -281,6 +281,53 @@
'state': 'off',
})
# ---
# name: test_all_entities[da_wm_wm_000001_1][switch.washing_machine-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.washing_machine',
'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': None,
'platform': 'smartthings',
'previous_unique_id': None,
'supported_features': 0,
'translation_key': None,
'unique_id': '63803fae-cbed-f356-a063-2cf148ae3ca7',
'unit_of_measurement': None,
})
# ---
# name: test_all_entities[da_wm_wm_000001_1][switch.washing_machine-state]
StateSnapshot({
'attributes': ReadOnlyDict({
'friendly_name': 'Washing Machine',
}),
'context': <ANY>,
'entity_id': 'switch.washing_machine',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': 'on',
})
# ---
# name: test_all_entities[sensibo_airconditioner_1][switch.office-entry]
EntityRegistryEntrySnapshot({
'aliases': set({