Skip to content

Commit aab349e

Browse files
joostlekfrenck
authored andcommitted
Fix SmartThings ACs without supported AC modes (#140744)
1 parent 21ced23 commit aab349e

File tree

7 files changed

+309
-6
lines changed

7 files changed

+309
-6
lines changed

homeassistant/components/smartthings/climate.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -565,12 +565,15 @@ async def async_set_preset_mode(self, preset_mode: str) -> None:
565565
def _determine_hvac_modes(self) -> list[HVACMode]:
566566
"""Determine the supported HVAC modes."""
567567
modes = [HVACMode.OFF]
568-
modes.extend(
569-
state
570-
for mode in self.get_attribute_value(
568+
if (
569+
ac_modes := self.get_attribute_value(
571570
Capability.AIR_CONDITIONER_MODE, Attribute.SUPPORTED_AC_MODES
572571
)
573-
if (state := AC_MODE_TO_STATE.get(mode)) is not None
574-
if state not in modes
575-
)
572+
) is not None:
573+
modes.extend(
574+
state
575+
for mode in ac_modes
576+
if (state := AC_MODE_TO_STATE.get(mode)) is not None
577+
if state not in modes
578+
)
576579
return modes

tests/components/smartthings/conftest.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ def mock_smartthings() -> Generator[AsyncMock]:
132132
"abl_light_b_001",
133133
"tplink_p110",
134134
"ikea_kadrilj",
135+
"aux_ac",
135136
]
136137
)
137138
def device_fixture(
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
{
2+
"components": {
3+
"main": {
4+
"partyvoice23922.vtempset": {
5+
"vtemp": {
6+
"value": 20,
7+
"unit": "C",
8+
"timestamp": "2024-12-05T20:03:33.161Z"
9+
}
10+
},
11+
"airConditionerFanMode": {
12+
"fanMode": {
13+
"value": "auto",
14+
"timestamp": "2024-12-05T20:03:32.930Z"
15+
},
16+
"supportedAcFanModes": {
17+
"value": null
18+
},
19+
"availableAcFanModes": {
20+
"value": null
21+
}
22+
},
23+
"temperatureMeasurement": {
24+
"temperatureRange": {
25+
"value": null
26+
},
27+
"temperature": {
28+
"value": 20.0,
29+
"unit": "C",
30+
"timestamp": "2024-12-05T20:03:33.066Z"
31+
}
32+
},
33+
"airConditionerMode": {
34+
"availableAcModes": {
35+
"value": null
36+
},
37+
"supportedAcModes": {
38+
"value": null
39+
},
40+
"airConditionerMode": {
41+
"value": "cool",
42+
"timestamp": "2024-12-05T20:03:32.845Z"
43+
}
44+
},
45+
"fanSpeed": {
46+
"fanSpeed": {
47+
"value": 0,
48+
"timestamp": "2024-12-05T20:03:33.334Z"
49+
}
50+
},
51+
"thermostatCoolingSetpoint": {
52+
"coolingSetpointRange": {
53+
"value": null
54+
},
55+
"coolingSetpoint": {
56+
"value": 20.0,
57+
"unit": "C",
58+
"timestamp": "2024-12-05T20:03:33.243Z"
59+
}
60+
},
61+
"switch": {
62+
"switch": {
63+
"value": "off",
64+
"timestamp": "2024-12-05T20:03:32.662Z"
65+
}
66+
}
67+
}
68+
}
69+
}
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
{
2+
"items": [
3+
{
4+
"deviceId": "bf53a150-f8a4-45d1-aac4-86252475d551",
5+
"name": "vedgeaircon.v1",
6+
"label": "AUX A/C on-off",
7+
"manufacturerName": "SmartThingsCommunity",
8+
"presentationId": "ab252042-5669-3c2c-8b1b-d606bbcc9e04",
9+
"deviceManufacturerCode": "SmartThings Community",
10+
"locationId": "5db1e3d8-ea26-44b4-8ed0-1ba9c841fd57",
11+
"ownerId": "5404aa57-6a68-4fe2-83ff-168ef769d1c7",
12+
"roomId": "564cdd9a-fa9f-4187-902f-95656ef22989",
13+
"components": [
14+
{
15+
"id": "main",
16+
"label": "main",
17+
"capabilities": [
18+
{
19+
"id": "switch",
20+
"version": 1
21+
},
22+
{
23+
"id": "airConditionerMode",
24+
"version": 1
25+
},
26+
{
27+
"id": "thermostatCoolingSetpoint",
28+
"version": 1
29+
},
30+
{
31+
"id": "airConditionerFanMode",
32+
"version": 1
33+
},
34+
{
35+
"id": "fanSpeed",
36+
"version": 1
37+
},
38+
{
39+
"id": "temperatureMeasurement",
40+
"version": 1
41+
},
42+
{
43+
"id": "partyvoice23922.vtempset",
44+
"version": 1
45+
}
46+
],
47+
"categories": [
48+
{
49+
"name": "AirConditioner",
50+
"categoryType": "manufacturer"
51+
}
52+
]
53+
}
54+
],
55+
"createTime": "2024-06-19T20:18:45.407Z",
56+
"parentDeviceId": "e699599d-30f8-4cf0-8de7-6dbdba6a665f",
57+
"profile": {
58+
"id": "87f0ac35-e024-3c0a-8153-78ca27a6fe0c"
59+
},
60+
"lan": {
61+
"networkId": "vEdge_A/C_1718828324.999",
62+
"driverId": "0fd9a9a4-8863-4a83-97a7-5a288ff0f5a6",
63+
"executingLocally": true,
64+
"hubId": "e699599d-30f8-4cf0-8de7-6dbdba6a665f",
65+
"provisioningState": "TYPED"
66+
},
67+
"type": "LAN",
68+
"restrictionTier": 0,
69+
"allowed": null,
70+
"indoorMap": {
71+
"coordinates": [130.0, 36.0, 378.0],
72+
"rotation": [270.0, 0.0, 0.0],
73+
"visible": true,
74+
"data": null
75+
},
76+
"executionContext": "LOCAL",
77+
"relationships": []
78+
}
79+
],
80+
"_links": {}
81+
}

tests/components/smartthings/snapshots/test_climate.ambr

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,68 @@
11
# serializer version: 1
2+
# name: test_all_entities[aux_ac][climate.aux_a_c_on_off-entry]
3+
EntityRegistryEntrySnapshot({
4+
'aliases': set({
5+
}),
6+
'area_id': None,
7+
'capabilities': dict({
8+
'fan_modes': None,
9+
'hvac_modes': list([
10+
<HVACMode.OFF: 'off'>,
11+
]),
12+
'max_temp': 35,
13+
'min_temp': 7,
14+
}),
15+
'config_entry_id': <ANY>,
16+
'config_subentry_id': <ANY>,
17+
'device_class': None,
18+
'device_id': <ANY>,
19+
'disabled_by': None,
20+
'domain': 'climate',
21+
'entity_category': None,
22+
'entity_id': 'climate.aux_a_c_on_off',
23+
'has_entity_name': True,
24+
'hidden_by': None,
25+
'icon': None,
26+
'id': <ANY>,
27+
'labels': set({
28+
}),
29+
'name': None,
30+
'options': dict({
31+
}),
32+
'original_device_class': None,
33+
'original_icon': None,
34+
'original_name': None,
35+
'platform': 'smartthings',
36+
'previous_unique_id': None,
37+
'supported_features': <ClimateEntityFeature: 393>,
38+
'translation_key': None,
39+
'unique_id': 'bf53a150-f8a4-45d1-aac4-86252475d551',
40+
'unit_of_measurement': None,
41+
})
42+
# ---
43+
# name: test_all_entities[aux_ac][climate.aux_a_c_on_off-state]
44+
StateSnapshot({
45+
'attributes': ReadOnlyDict({
46+
'current_temperature': 20.0,
47+
'fan_mode': 'auto',
48+
'fan_modes': None,
49+
'friendly_name': 'AUX A/C on-off',
50+
'hvac_modes': list([
51+
<HVACMode.OFF: 'off'>,
52+
]),
53+
'max_temp': 35,
54+
'min_temp': 7,
55+
'supported_features': <ClimateEntityFeature: 393>,
56+
'temperature': 20.0,
57+
}),
58+
'context': <ANY>,
59+
'entity_id': 'climate.aux_a_c_on_off',
60+
'last_changed': <ANY>,
61+
'last_reported': <ANY>,
62+
'last_updated': <ANY>,
63+
'state': 'off',
64+
})
65+
# ---
266
# name: test_all_entities[bosch_radiator_thermostat_ii][climate.radiator_thermostat_ii_m_wohnzimmer-entry]
367
EntityRegistryEntrySnapshot({
468
'aliases': set({

tests/components/smartthings/snapshots/test_init.ambr

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,39 @@
6868
'via_device_id': None,
6969
})
7070
# ---
71+
# name: test_devices[aux_ac]
72+
DeviceRegistryEntrySnapshot({
73+
'area_id': None,
74+
'config_entries': <ANY>,
75+
'config_entries_subentries': <ANY>,
76+
'configuration_url': 'https://account.smartthings.com',
77+
'connections': set({
78+
}),
79+
'disabled_by': None,
80+
'entry_type': None,
81+
'hw_version': None,
82+
'id': <ANY>,
83+
'identifiers': set({
84+
tuple(
85+
'smartthings',
86+
'bf53a150-f8a4-45d1-aac4-86252475d551',
87+
),
88+
}),
89+
'is_new': False,
90+
'labels': set({
91+
}),
92+
'manufacturer': None,
93+
'model': None,
94+
'model_id': None,
95+
'name': 'AUX A/C on-off',
96+
'name_by_user': None,
97+
'primary_config_entry': <ANY>,
98+
'serial_number': None,
99+
'suggested_area': None,
100+
'sw_version': None,
101+
'via_device_id': None,
102+
})
103+
# ---
71104
# name: test_devices[base_electric_meter]
72105
DeviceRegistryEntrySnapshot({
73106
'area_id': None,

tests/components/smartthings/snapshots/test_sensor.ambr

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,58 @@
154154
'state': 'unknown',
155155
})
156156
# ---
157+
# name: test_all_entities[aux_ac][sensor.aux_a_c_on_off_temperature-entry]
158+
EntityRegistryEntrySnapshot({
159+
'aliases': set({
160+
}),
161+
'area_id': None,
162+
'capabilities': dict({
163+
'state_class': <SensorStateClass.MEASUREMENT: 'measurement'>,
164+
}),
165+
'config_entry_id': <ANY>,
166+
'config_subentry_id': <ANY>,
167+
'device_class': None,
168+
'device_id': <ANY>,
169+
'disabled_by': None,
170+
'domain': 'sensor',
171+
'entity_category': None,
172+
'entity_id': 'sensor.aux_a_c_on_off_temperature',
173+
'has_entity_name': True,
174+
'hidden_by': None,
175+
'icon': None,
176+
'id': <ANY>,
177+
'labels': set({
178+
}),
179+
'name': None,
180+
'options': dict({
181+
}),
182+
'original_device_class': <SensorDeviceClass.TEMPERATURE: 'temperature'>,
183+
'original_icon': None,
184+
'original_name': 'Temperature',
185+
'platform': 'smartthings',
186+
'previous_unique_id': None,
187+
'supported_features': 0,
188+
'translation_key': None,
189+
'unique_id': 'bf53a150-f8a4-45d1-aac4-86252475d551.temperature',
190+
'unit_of_measurement': <UnitOfTemperature.CELSIUS: '°C'>,
191+
})
192+
# ---
193+
# name: test_all_entities[aux_ac][sensor.aux_a_c_on_off_temperature-state]
194+
StateSnapshot({
195+
'attributes': ReadOnlyDict({
196+
'device_class': 'temperature',
197+
'friendly_name': 'AUX A/C on-off Temperature',
198+
'state_class': <SensorStateClass.MEASUREMENT: 'measurement'>,
199+
'unit_of_measurement': <UnitOfTemperature.CELSIUS: '°C'>,
200+
}),
201+
'context': <ANY>,
202+
'entity_id': 'sensor.aux_a_c_on_off_temperature',
203+
'last_changed': <ANY>,
204+
'last_reported': <ANY>,
205+
'last_updated': <ANY>,
206+
'state': '20.0',
207+
})
208+
# ---
157209
# name: test_all_entities[base_electric_meter][sensor.aeon_energy_monitor_energy-entry]
158210
EntityRegistryEntrySnapshot({
159211
'aliases': set({

0 commit comments

Comments
 (0)