Fix SmartThings ACs without supported AC modes (#140744)

This commit is contained in:
Joost Lekkerkerker 2025-03-16 20:06:50 +01:00 committed by GitHub
parent 56fe4319a0
commit d061f4ee05
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 309 additions and 6 deletions

View File

@ -571,12 +571,15 @@ class SmartThingsAirConditioner(SmartThingsEntity, ClimateEntity):
def _determine_hvac_modes(self) -> list[HVACMode]: def _determine_hvac_modes(self) -> list[HVACMode]:
"""Determine the supported HVAC modes.""" """Determine the supported HVAC modes."""
modes = [HVACMode.OFF] modes = [HVACMode.OFF]
modes.extend( if (
state ac_modes := self.get_attribute_value(
for mode in self.get_attribute_value(
Capability.AIR_CONDITIONER_MODE, Attribute.SUPPORTED_AC_MODES Capability.AIR_CONDITIONER_MODE, Attribute.SUPPORTED_AC_MODES
) )
if (state := AC_MODE_TO_STATE.get(mode)) is not None ) is not None:
if state not in modes modes.extend(
) state
for mode in ac_modes
if (state := AC_MODE_TO_STATE.get(mode)) is not None
if state not in modes
)
return modes return modes

View File

@ -137,6 +137,7 @@ def mock_smartthings() -> Generator[AsyncMock]:
"abl_light_b_001", "abl_light_b_001",
"tplink_p110", "tplink_p110",
"ikea_kadrilj", "ikea_kadrilj",
"aux_ac",
] ]
) )
def device_fixture( def device_fixture(

View File

@ -0,0 +1,69 @@
{
"components": {
"main": {
"partyvoice23922.vtempset": {
"vtemp": {
"value": 20,
"unit": "C",
"timestamp": "2024-12-05T20:03:33.161Z"
}
},
"airConditionerFanMode": {
"fanMode": {
"value": "auto",
"timestamp": "2024-12-05T20:03:32.930Z"
},
"supportedAcFanModes": {
"value": null
},
"availableAcFanModes": {
"value": null
}
},
"temperatureMeasurement": {
"temperatureRange": {
"value": null
},
"temperature": {
"value": 20.0,
"unit": "C",
"timestamp": "2024-12-05T20:03:33.066Z"
}
},
"airConditionerMode": {
"availableAcModes": {
"value": null
},
"supportedAcModes": {
"value": null
},
"airConditionerMode": {
"value": "cool",
"timestamp": "2024-12-05T20:03:32.845Z"
}
},
"fanSpeed": {
"fanSpeed": {
"value": 0,
"timestamp": "2024-12-05T20:03:33.334Z"
}
},
"thermostatCoolingSetpoint": {
"coolingSetpointRange": {
"value": null
},
"coolingSetpoint": {
"value": 20.0,
"unit": "C",
"timestamp": "2024-12-05T20:03:33.243Z"
}
},
"switch": {
"switch": {
"value": "off",
"timestamp": "2024-12-05T20:03:32.662Z"
}
}
}
}
}

View File

@ -0,0 +1,81 @@
{
"items": [
{
"deviceId": "bf53a150-f8a4-45d1-aac4-86252475d551",
"name": "vedgeaircon.v1",
"label": "AUX A/C on-off",
"manufacturerName": "SmartThingsCommunity",
"presentationId": "ab252042-5669-3c2c-8b1b-d606bbcc9e04",
"deviceManufacturerCode": "SmartThings Community",
"locationId": "5db1e3d8-ea26-44b4-8ed0-1ba9c841fd57",
"ownerId": "5404aa57-6a68-4fe2-83ff-168ef769d1c7",
"roomId": "564cdd9a-fa9f-4187-902f-95656ef22989",
"components": [
{
"id": "main",
"label": "main",
"capabilities": [
{
"id": "switch",
"version": 1
},
{
"id": "airConditionerMode",
"version": 1
},
{
"id": "thermostatCoolingSetpoint",
"version": 1
},
{
"id": "airConditionerFanMode",
"version": 1
},
{
"id": "fanSpeed",
"version": 1
},
{
"id": "temperatureMeasurement",
"version": 1
},
{
"id": "partyvoice23922.vtempset",
"version": 1
}
],
"categories": [
{
"name": "AirConditioner",
"categoryType": "manufacturer"
}
]
}
],
"createTime": "2024-06-19T20:18:45.407Z",
"parentDeviceId": "e699599d-30f8-4cf0-8de7-6dbdba6a665f",
"profile": {
"id": "87f0ac35-e024-3c0a-8153-78ca27a6fe0c"
},
"lan": {
"networkId": "vEdge_A/C_1718828324.999",
"driverId": "0fd9a9a4-8863-4a83-97a7-5a288ff0f5a6",
"executingLocally": true,
"hubId": "e699599d-30f8-4cf0-8de7-6dbdba6a665f",
"provisioningState": "TYPED"
},
"type": "LAN",
"restrictionTier": 0,
"allowed": null,
"indoorMap": {
"coordinates": [130.0, 36.0, 378.0],
"rotation": [270.0, 0.0, 0.0],
"visible": true,
"data": null
},
"executionContext": "LOCAL",
"relationships": []
}
],
"_links": {}
}

View File

@ -1,4 +1,68 @@
# serializer version: 1 # serializer version: 1
# name: test_all_entities[aux_ac][climate.aux_a_c_on_off-entry]
EntityRegistryEntrySnapshot({
'aliases': set({
}),
'area_id': None,
'capabilities': dict({
'fan_modes': None,
'hvac_modes': list([
<HVACMode.OFF: 'off'>,
]),
'max_temp': 35,
'min_temp': 7,
}),
'config_entry_id': <ANY>,
'config_subentry_id': <ANY>,
'device_class': None,
'device_id': <ANY>,
'disabled_by': None,
'domain': 'climate',
'entity_category': None,
'entity_id': 'climate.aux_a_c_on_off',
'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': <ClimateEntityFeature: 393>,
'translation_key': None,
'unique_id': 'bf53a150-f8a4-45d1-aac4-86252475d551',
'unit_of_measurement': None,
})
# ---
# name: test_all_entities[aux_ac][climate.aux_a_c_on_off-state]
StateSnapshot({
'attributes': ReadOnlyDict({
'current_temperature': 20.0,
'fan_mode': 'auto',
'fan_modes': None,
'friendly_name': 'AUX A/C on-off',
'hvac_modes': list([
<HVACMode.OFF: 'off'>,
]),
'max_temp': 35,
'min_temp': 7,
'supported_features': <ClimateEntityFeature: 393>,
'temperature': 20.0,
}),
'context': <ANY>,
'entity_id': 'climate.aux_a_c_on_off',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': 'off',
})
# ---
# name: test_all_entities[bosch_radiator_thermostat_ii][climate.radiator_thermostat_ii_m_wohnzimmer-entry] # name: test_all_entities[bosch_radiator_thermostat_ii][climate.radiator_thermostat_ii_m_wohnzimmer-entry]
EntityRegistryEntrySnapshot({ EntityRegistryEntrySnapshot({
'aliases': set({ 'aliases': set({

View File

@ -68,6 +68,39 @@
'via_device_id': None, 'via_device_id': None,
}) })
# --- # ---
# name: test_devices[aux_ac]
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': None,
'id': <ANY>,
'identifiers': set({
tuple(
'smartthings',
'bf53a150-f8a4-45d1-aac4-86252475d551',
),
}),
'is_new': False,
'labels': set({
}),
'manufacturer': None,
'model': None,
'model_id': None,
'name': 'AUX A/C on-off',
'name_by_user': None,
'primary_config_entry': <ANY>,
'serial_number': None,
'suggested_area': None,
'sw_version': None,
'via_device_id': None,
})
# ---
# name: test_devices[base_electric_meter] # name: test_devices[base_electric_meter]
DeviceRegistryEntrySnapshot({ DeviceRegistryEntrySnapshot({
'area_id': 'theater', 'area_id': 'theater',

View File

@ -154,6 +154,58 @@
'state': 'unknown', 'state': 'unknown',
}) })
# --- # ---
# name: test_all_entities[aux_ac][sensor.aux_a_c_on_off_temperature-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.aux_a_c_on_off_temperature',
'has_entity_name': True,
'hidden_by': None,
'icon': None,
'id': <ANY>,
'labels': set({
}),
'name': None,
'options': dict({
}),
'original_device_class': <SensorDeviceClass.TEMPERATURE: 'temperature'>,
'original_icon': None,
'original_name': 'Temperature',
'platform': 'smartthings',
'previous_unique_id': None,
'supported_features': 0,
'translation_key': None,
'unique_id': 'bf53a150-f8a4-45d1-aac4-86252475d551.temperature',
'unit_of_measurement': <UnitOfTemperature.CELSIUS: '°C'>,
})
# ---
# name: test_all_entities[aux_ac][sensor.aux_a_c_on_off_temperature-state]
StateSnapshot({
'attributes': ReadOnlyDict({
'device_class': 'temperature',
'friendly_name': 'AUX A/C on-off Temperature',
'state_class': <SensorStateClass.MEASUREMENT: 'measurement'>,
'unit_of_measurement': <UnitOfTemperature.CELSIUS: '°C'>,
}),
'context': <ANY>,
'entity_id': 'sensor.aux_a_c_on_off_temperature',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': '20.0',
})
# ---
# name: test_all_entities[base_electric_meter][sensor.aeon_energy_monitor_energy-entry] # name: test_all_entities[base_electric_meter][sensor.aeon_energy_monitor_energy-entry]
EntityRegistryEntrySnapshot({ EntityRegistryEntrySnapshot({
'aliases': set({ 'aliases': set({