Skip to content

Commit 761be93

Browse files
joostlekfrenck
authored andcommitted
Fix windowShadeLevel capability in SmartThings (#140552)
1 parent 54ad44a commit 761be93

File tree

7 files changed

+284
-0
lines changed

7 files changed

+284
-0
lines changed

homeassistant/components/smartthings/cover.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,10 @@ def _update_attr(self) -> None:
118118
self._attr_current_cover_position = self.get_attribute_value(
119119
Capability.SWITCH_LEVEL, Attribute.LEVEL
120120
)
121+
elif self.supports_capability(Capability.WINDOW_SHADE_LEVEL):
122+
self._attr_current_cover_position = self.get_attribute_value(
123+
Capability.WINDOW_SHADE_LEVEL, Attribute.SHADE_LEVEL
124+
)
121125

122126
self._attr_extra_state_attributes = {}
123127
if self.supports_capability(Capability.BATTERY):

tests/components/smartthings/conftest.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ def mock_smartthings() -> Generator[AsyncMock]:
129129
"im_speaker_ai_0001",
130130
"abl_light_b_001",
131131
"tplink_p110",
132+
"ikea_kadrilj",
132133
]
133134
)
134135
def device_fixture(
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
{
2+
"components": {
3+
"main": {
4+
"windowShadeLevel": {
5+
"shadeLevel": {
6+
"value": 32,
7+
"unit": "%",
8+
"timestamp": "2025-03-13T10:40:25.613Z"
9+
}
10+
},
11+
"refresh": {},
12+
"windowShadePreset": {},
13+
"battery": {
14+
"quantity": {
15+
"value": null
16+
},
17+
"battery": {
18+
"value": 37,
19+
"unit": "%",
20+
"timestamp": "2025-03-13T07:09:05.149Z"
21+
},
22+
"type": {
23+
"value": null
24+
}
25+
},
26+
"firmwareUpdate": {
27+
"lastUpdateStatusReason": {
28+
"value": null
29+
},
30+
"availableVersion": {
31+
"value": "22007631",
32+
"timestamp": "2025-03-12T20:35:04.576Z"
33+
},
34+
"lastUpdateStatus": {
35+
"value": null
36+
},
37+
"supportedCommands": {
38+
"value": null
39+
},
40+
"state": {
41+
"value": "updateRequested",
42+
"timestamp": "2025-03-12T20:35:03.879Z"
43+
},
44+
"updateAvailable": {
45+
"value": false,
46+
"timestamp": "2025-03-12T20:35:04.577Z"
47+
},
48+
"currentVersion": {
49+
"value": "22007631",
50+
"timestamp": "2025-03-12T20:35:04.508Z"
51+
},
52+
"lastUpdateTime": {
53+
"value": null
54+
}
55+
},
56+
"windowShade": {
57+
"supportedWindowShadeCommands": {
58+
"value": ["open", "close", "pause"],
59+
"timestamp": "2025-03-13T10:33:48.402Z"
60+
},
61+
"windowShade": {
62+
"value": "partially open",
63+
"timestamp": "2025-03-13T10:55:58.205Z"
64+
}
65+
}
66+
}
67+
}
68+
}
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
{
2+
"items": [
3+
{
4+
"deviceId": "71afed1c-006d-4e48-b16e-e7f88f9fd638",
5+
"name": "window-treatment-battery",
6+
"label": "Kitchen IKEA KADRILJ Window blind",
7+
"manufacturerName": "SmartThingsCommunity",
8+
"presentationId": "fa41d7d3-4c03-327f-b0ce-2edc829f0e34",
9+
"deviceManufacturerCode": "IKEA of Sweden",
10+
"locationId": "5b5f96b5-0286-4f4a-86ef-d5d5c1a78cb8",
11+
"ownerId": "f43fd9e5-2ecd-4aae-aeac-73a8e5cb04da",
12+
"roomId": "89f675a1-1f16-451c-8ab1-a7fdacc5852d",
13+
"components": [
14+
{
15+
"id": "main",
16+
"label": "main",
17+
"capabilities": [
18+
{
19+
"id": "windowShade",
20+
"version": 1
21+
},
22+
{
23+
"id": "windowShadePreset",
24+
"version": 1
25+
},
26+
{
27+
"id": "windowShadeLevel",
28+
"version": 1
29+
},
30+
{
31+
"id": "battery",
32+
"version": 1
33+
},
34+
{
35+
"id": "firmwareUpdate",
36+
"version": 1
37+
},
38+
{
39+
"id": "refresh",
40+
"version": 1
41+
}
42+
],
43+
"categories": [
44+
{
45+
"name": "Blind",
46+
"categoryType": "manufacturer"
47+
}
48+
]
49+
}
50+
],
51+
"createTime": "2023-04-26T18:19:06.792Z",
52+
"parentDeviceId": "3ffe04c4-a12c-41f5-b83d-c1b28eca2b5f",
53+
"profile": {
54+
"id": "6d9804bc-9e56-3823-95be-4b315669c481"
55+
},
56+
"zigbee": {
57+
"eui": "000D6FFFFE2AD0E7",
58+
"networkId": "3009",
59+
"driverId": "46b8bada-1a55-4f84-8915-47ce2cad3621",
60+
"executingLocally": true,
61+
"hubId": "3ffe04c4-a12c-41f5-b83d-c1b28eca2b5f",
62+
"provisioningState": "NONFUNCTIONAL"
63+
},
64+
"type": "ZIGBEE",
65+
"restrictionTier": 0,
66+
"allowed": null,
67+
"indoorMap": {
68+
"coordinates": [10.0, 36.0, 98.0],
69+
"rotation": [270.0, 0.0, 0.0],
70+
"visible": true,
71+
"data": null
72+
},
73+
"executionContext": "LOCAL",
74+
"relationships": []
75+
}
76+
],
77+
"_links": {}
78+
}

tests/components/smartthings/snapshots/test_cover.ambr

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,3 +49,54 @@
4949
'state': 'open',
5050
})
5151
# ---
52+
# name: test_all_entities[ikea_kadrilj][cover.kitchen_ikea_kadrilj_window_blind-entry]
53+
EntityRegistryEntrySnapshot({
54+
'aliases': set({
55+
}),
56+
'area_id': None,
57+
'capabilities': None,
58+
'config_entry_id': <ANY>,
59+
'config_subentry_id': <ANY>,
60+
'device_class': None,
61+
'device_id': <ANY>,
62+
'disabled_by': None,
63+
'domain': 'cover',
64+
'entity_category': None,
65+
'entity_id': 'cover.kitchen_ikea_kadrilj_window_blind',
66+
'has_entity_name': True,
67+
'hidden_by': None,
68+
'icon': None,
69+
'id': <ANY>,
70+
'labels': set({
71+
}),
72+
'name': None,
73+
'options': dict({
74+
}),
75+
'original_device_class': <CoverDeviceClass.SHADE: 'shade'>,
76+
'original_icon': None,
77+
'original_name': None,
78+
'platform': 'smartthings',
79+
'previous_unique_id': None,
80+
'supported_features': <CoverEntityFeature: 7>,
81+
'translation_key': None,
82+
'unique_id': '71afed1c-006d-4e48-b16e-e7f88f9fd638',
83+
'unit_of_measurement': None,
84+
})
85+
# ---
86+
# name: test_all_entities[ikea_kadrilj][cover.kitchen_ikea_kadrilj_window_blind-state]
87+
StateSnapshot({
88+
'attributes': ReadOnlyDict({
89+
'battery_level': 37,
90+
'current_position': 32,
91+
'device_class': 'shade',
92+
'friendly_name': 'Kitchen IKEA KADRILJ Window blind',
93+
'supported_features': <CoverEntityFeature: 7>,
94+
}),
95+
'context': <ANY>,
96+
'entity_id': 'cover.kitchen_ikea_kadrilj_window_blind',
97+
'last_changed': <ANY>,
98+
'last_reported': <ANY>,
99+
'last_updated': <ANY>,
100+
'state': 'open',
101+
})
102+
# ---

tests/components/smartthings/snapshots/test_init.ambr

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -959,6 +959,39 @@
959959
'via_device_id': None,
960960
})
961961
# ---
962+
# name: test_devices[ikea_kadrilj]
963+
DeviceRegistryEntrySnapshot({
964+
'area_id': None,
965+
'config_entries': <ANY>,
966+
'config_entries_subentries': <ANY>,
967+
'configuration_url': 'https://account.smartthings.com',
968+
'connections': set({
969+
}),
970+
'disabled_by': None,
971+
'entry_type': None,
972+
'hw_version': None,
973+
'id': <ANY>,
974+
'identifiers': set({
975+
tuple(
976+
'smartthings',
977+
'71afed1c-006d-4e48-b16e-e7f88f9fd638',
978+
),
979+
}),
980+
'is_new': False,
981+
'labels': set({
982+
}),
983+
'manufacturer': None,
984+
'model': None,
985+
'model_id': None,
986+
'name': 'Kitchen IKEA KADRILJ Window blind',
987+
'name_by_user': None,
988+
'primary_config_entry': <ANY>,
989+
'serial_number': None,
990+
'suggested_area': None,
991+
'sw_version': None,
992+
'via_device_id': None,
993+
})
994+
# ---
962995
# name: test_devices[im_speaker_ai_0001]
963996
DeviceRegistryEntrySnapshot({
964997
'area_id': None,

tests/components/smartthings/snapshots/test_sensor.ambr

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5506,6 +5506,55 @@
55065506
'state': '19.0',
55075507
})
55085508
# ---
5509+
# name: test_all_entities[ikea_kadrilj][sensor.kitchen_ikea_kadrilj_window_blind_battery-entry]
5510+
EntityRegistryEntrySnapshot({
5511+
'aliases': set({
5512+
}),
5513+
'area_id': None,
5514+
'capabilities': None,
5515+
'config_entry_id': <ANY>,
5516+
'config_subentry_id': <ANY>,
5517+
'device_class': None,
5518+
'device_id': <ANY>,
5519+
'disabled_by': None,
5520+
'domain': 'sensor',
5521+
'entity_category': <EntityCategory.DIAGNOSTIC: 'diagnostic'>,
5522+
'entity_id': 'sensor.kitchen_ikea_kadrilj_window_blind_battery',
5523+
'has_entity_name': True,
5524+
'hidden_by': None,
5525+
'icon': None,
5526+
'id': <ANY>,
5527+
'labels': set({
5528+
}),
5529+
'name': None,
5530+
'options': dict({
5531+
}),
5532+
'original_device_class': <SensorDeviceClass.BATTERY: 'battery'>,
5533+
'original_icon': None,
5534+
'original_name': 'Battery',
5535+
'platform': 'smartthings',
5536+
'previous_unique_id': None,
5537+
'supported_features': 0,
5538+
'translation_key': None,
5539+
'unique_id': '71afed1c-006d-4e48-b16e-e7f88f9fd638.battery',
5540+
'unit_of_measurement': '%',
5541+
})
5542+
# ---
5543+
# name: test_all_entities[ikea_kadrilj][sensor.kitchen_ikea_kadrilj_window_blind_battery-state]
5544+
StateSnapshot({
5545+
'attributes': ReadOnlyDict({
5546+
'device_class': 'battery',
5547+
'friendly_name': 'Kitchen IKEA KADRILJ Window blind Battery',
5548+
'unit_of_measurement': '%',
5549+
}),
5550+
'context': <ANY>,
5551+
'entity_id': 'sensor.kitchen_ikea_kadrilj_window_blind_battery',
5552+
'last_changed': <ANY>,
5553+
'last_reported': <ANY>,
5554+
'last_updated': <ANY>,
5555+
'state': '37',
5556+
})
5557+
# ---
55095558
# name: test_all_entities[im_speaker_ai_0001][sensor.galaxy_home_mini_media_input_source-entry]
55105559
EntityRegistryEntrySnapshot({
55115560
'aliases': set({

0 commit comments

Comments
 (0)