Fix SmartThings fan (#139962)
parent
59073d47a1
commit
f38a32477e
|
@ -119,7 +119,7 @@ class SmartThingsFan(SmartThingsEntity, FanEntity):
|
|||
@property
|
||||
def is_on(self) -> bool:
|
||||
"""Return true if fan is on."""
|
||||
return self.get_attribute_value(Capability.SWITCH, Attribute.SWITCH)
|
||||
return self.get_attribute_value(Capability.SWITCH, Attribute.SWITCH) == "on"
|
||||
|
||||
@property
|
||||
def percentage(self) -> int | None:
|
||||
|
@ -135,6 +135,8 @@ class SmartThingsFan(SmartThingsEntity, FanEntity):
|
|||
|
||||
Requires FanEntityFeature.PRESET_MODE.
|
||||
"""
|
||||
if not self.supports_capability(Capability.AIR_CONDITIONER_FAN_MODE):
|
||||
return None
|
||||
return self.get_attribute_value(
|
||||
Capability.AIR_CONDITIONER_FAN_MODE, Attribute.FAN_MODE
|
||||
)
|
||||
|
@ -145,6 +147,8 @@ class SmartThingsFan(SmartThingsEntity, FanEntity):
|
|||
|
||||
Requires FanEntityFeature.PRESET_MODE.
|
||||
"""
|
||||
if not self.supports_capability(Capability.AIR_CONDITIONER_FAN_MODE):
|
||||
return None
|
||||
return self.get_attribute_value(
|
||||
Capability.AIR_CONDITIONER_FAN_MODE, Attribute.SUPPORTED_AC_FAN_MODES
|
||||
)
|
||||
|
|
|
@ -119,6 +119,7 @@ def mock_smartthings() -> Generator[AsyncMock]:
|
|||
"ecobee_sensor",
|
||||
"ecobee_thermostat",
|
||||
"fake_fan",
|
||||
"generic_fan_3_speed",
|
||||
]
|
||||
)
|
||||
def device_fixture(
|
||||
|
|
|
@ -0,0 +1,19 @@
|
|||
{
|
||||
"components": {
|
||||
"main": {
|
||||
"refresh": {},
|
||||
"fanSpeed": {
|
||||
"fanSpeed": {
|
||||
"value": 0,
|
||||
"timestamp": "2025-03-06T11:47:32.683Z"
|
||||
}
|
||||
},
|
||||
"switch": {
|
||||
"switch": {
|
||||
"value": "off",
|
||||
"timestamp": "2025-03-06T11:47:32.697Z"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,63 @@
|
|||
{
|
||||
"items": [
|
||||
{
|
||||
"deviceId": "6d95a8b7-4ee3-429a-a13a-00ec9354170c",
|
||||
"name": "GE In-Wall Smart Dimmer",
|
||||
"label": "Bedroom Fan",
|
||||
"manufacturerName": "SmartThingsEdge",
|
||||
"presentationId": "generic-fan-3-speed",
|
||||
"deviceManufacturerCode": "0063-4944-3131",
|
||||
"locationId": "f1313f27-6732-481d-a2a9-c7bbf900f867",
|
||||
"ownerId": "e5216062-ac82-79b8-20db-ea65fa3d3fdd",
|
||||
"roomId": "5f77f7cf-ece8-485e-a409-98f7b128a41a",
|
||||
"components": [
|
||||
{
|
||||
"id": "main",
|
||||
"label": "Bedroom Fan",
|
||||
"capabilities": [
|
||||
{
|
||||
"id": "fanSpeed",
|
||||
"version": 1
|
||||
},
|
||||
{
|
||||
"id": "switch",
|
||||
"version": 1
|
||||
},
|
||||
{
|
||||
"id": "refresh",
|
||||
"version": 1
|
||||
}
|
||||
],
|
||||
"categories": [
|
||||
{
|
||||
"name": "Fan",
|
||||
"categoryType": "manufacturer"
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"createTime": "2018-01-12T22:12:15Z",
|
||||
"parentDeviceId": "4ceb9b86-2f0d-4e98-ba4e-3fbe705f7805",
|
||||
"profile": {
|
||||
"id": "9bd81754-fc81-3ed1-86c2-d1094d6cbf6d"
|
||||
},
|
||||
"zwave": {
|
||||
"networkId": "02",
|
||||
"driverId": "e7947a05-947d-4bb5-92c4-2aafaff6d69c",
|
||||
"executingLocally": true,
|
||||
"hubId": "4ceb9b86-2f0d-4e98-ba4e-3fbe705f7805",
|
||||
"networkSecurityLevel": "ZWAVE_LEGACY_NON_SECURE",
|
||||
"provisioningState": "PROVISIONED",
|
||||
"manufacturerId": 99,
|
||||
"productType": 18756,
|
||||
"productId": 12593
|
||||
},
|
||||
"type": "ZWAVE",
|
||||
"restrictionTier": 0,
|
||||
"allowed": null,
|
||||
"executionContext": "LOCAL",
|
||||
"relationships": []
|
||||
}
|
||||
],
|
||||
"_links": {}
|
||||
}
|
|
@ -62,6 +62,60 @@
|
|||
'last_changed': <ANY>,
|
||||
'last_reported': <ANY>,
|
||||
'last_updated': <ANY>,
|
||||
'state': 'on',
|
||||
'state': 'off',
|
||||
})
|
||||
# ---
|
||||
# name: test_all_entities[generic_fan_3_speed][fan.bedroom_fan-entry]
|
||||
EntityRegistryEntrySnapshot({
|
||||
'aliases': set({
|
||||
}),
|
||||
'area_id': None,
|
||||
'capabilities': dict({
|
||||
'preset_modes': None,
|
||||
}),
|
||||
'config_entry_id': <ANY>,
|
||||
'config_subentry_id': <ANY>,
|
||||
'device_class': None,
|
||||
'device_id': <ANY>,
|
||||
'disabled_by': None,
|
||||
'domain': 'fan',
|
||||
'entity_category': None,
|
||||
'entity_id': 'fan.bedroom_fan',
|
||||
'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': <FanEntityFeature: 49>,
|
||||
'translation_key': None,
|
||||
'unique_id': '6d95a8b7-4ee3-429a-a13a-00ec9354170c',
|
||||
'unit_of_measurement': None,
|
||||
})
|
||||
# ---
|
||||
# name: test_all_entities[generic_fan_3_speed][fan.bedroom_fan-state]
|
||||
StateSnapshot({
|
||||
'attributes': ReadOnlyDict({
|
||||
'friendly_name': 'Bedroom Fan',
|
||||
'percentage': 0,
|
||||
'percentage_step': 33.333333333333336,
|
||||
'preset_mode': None,
|
||||
'preset_modes': None,
|
||||
'supported_features': <FanEntityFeature: 49>,
|
||||
}),
|
||||
'context': <ANY>,
|
||||
'entity_id': 'fan.bedroom_fan',
|
||||
'last_changed': <ANY>,
|
||||
'last_reported': <ANY>,
|
||||
'last_updated': <ANY>,
|
||||
'state': 'off',
|
||||
})
|
||||
# ---
|
||||
|
|
|
@ -626,6 +626,39 @@
|
|||
'via_device_id': None,
|
||||
})
|
||||
# ---
|
||||
# name: test_devices[generic_fan_3_speed]
|
||||
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',
|
||||
'6d95a8b7-4ee3-429a-a13a-00ec9354170c',
|
||||
),
|
||||
}),
|
||||
'is_new': False,
|
||||
'labels': set({
|
||||
}),
|
||||
'manufacturer': None,
|
||||
'model': None,
|
||||
'model_id': None,
|
||||
'name': 'Bedroom Fan',
|
||||
'name_by_user': None,
|
||||
'primary_config_entry': <ANY>,
|
||||
'serial_number': None,
|
||||
'suggested_area': None,
|
||||
'sw_version': None,
|
||||
'via_device_id': None,
|
||||
})
|
||||
# ---
|
||||
# name: test_devices[hue_color_temperature_bulb]
|
||||
DeviceRegistryEntrySnapshot({
|
||||
'area_id': None,
|
||||
|
|
Loading…
Reference in New Issue