mirror of
https://github.com/home-assistant/core.git
synced 2025-08-05 21:55:10 +02:00
Do not create Tuya fan entities without control
This commit is contained in:
@@ -45,6 +45,8 @@ TUYA_SUPPORT_TYPE = {
|
|||||||
"ks",
|
"ks",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_SWITCH_DP_CODES = (DPCode.SWITCH_FAN, DPCode.FAN_SWITCH, DPCode.SWITCH)
|
||||||
|
|
||||||
|
|
||||||
async def async_setup_entry(
|
async def async_setup_entry(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
@@ -60,7 +62,9 @@ async def async_setup_entry(
|
|||||||
entities: list[TuyaFanEntity] = []
|
entities: list[TuyaFanEntity] = []
|
||||||
for device_id in device_ids:
|
for device_id in device_ids:
|
||||||
device = hass_data.manager.device_map[device_id]
|
device = hass_data.manager.device_map[device_id]
|
||||||
if device and device.category in TUYA_SUPPORT_TYPE:
|
if device.category in TUYA_SUPPORT_TYPE and any(
|
||||||
|
code in device.status for code in _SWITCH_DP_CODES
|
||||||
|
):
|
||||||
entities.append(TuyaFanEntity(device, hass_data.manager))
|
entities.append(TuyaFanEntity(device, hass_data.manager))
|
||||||
async_add_entities(entities)
|
async_add_entities(entities)
|
||||||
|
|
||||||
@@ -90,9 +94,7 @@ class TuyaFanEntity(TuyaEntity, FanEntity):
|
|||||||
"""Init Tuya Fan Device."""
|
"""Init Tuya Fan Device."""
|
||||||
super().__init__(device, device_manager)
|
super().__init__(device, device_manager)
|
||||||
|
|
||||||
self._switch = self.find_dpcode(
|
self._switch = self.find_dpcode(_SWITCH_DP_CODES, prefer_function=True)
|
||||||
(DPCode.SWITCH_FAN, DPCode.FAN_SWITCH, DPCode.SWITCH), prefer_function=True
|
|
||||||
)
|
|
||||||
|
|
||||||
self._attr_preset_modes = []
|
self._attr_preset_modes = []
|
||||||
if enum_type := self.find_dpcode(
|
if enum_type := self.find_dpcode(
|
||||||
|
@@ -43,8 +43,8 @@ DEVICE_MOCKS = {
|
|||||||
],
|
],
|
||||||
"cs_vmxuxszzjwp5smli": [
|
"cs_vmxuxszzjwp5smli": [
|
||||||
# https://github.com/home-assistant/core/issues/119865
|
# https://github.com/home-assistant/core/issues/119865
|
||||||
Platform.FAN,
|
# Platform.FAN, missing DPCodes in device status
|
||||||
Platform.HUMIDIFIER,
|
Platform.HUMIDIFIER
|
||||||
],
|
],
|
||||||
"cs_zibqa9dutqyaxym2": [
|
"cs_zibqa9dutqyaxym2": [
|
||||||
Platform.BINARY_SENSOR,
|
Platform.BINARY_SENSOR,
|
||||||
@@ -214,6 +214,10 @@ DEVICE_MOCKS = {
|
|||||||
# https://github.com/home-assistant/core/issues/143499
|
# https://github.com/home-assistant/core/issues/143499
|
||||||
Platform.SENSOR,
|
Platform.SENSOR,
|
||||||
],
|
],
|
||||||
|
"fs_ibytpo6fpnugft1c": [
|
||||||
|
# https://github.com/home-assistant/core/issues/135541
|
||||||
|
# Platform.FAN, missing DPCodes in device status
|
||||||
|
],
|
||||||
"gyd_lgekqfxdabipm3tn": [
|
"gyd_lgekqfxdabipm3tn": [
|
||||||
# https://github.com/home-assistant/core/issues/133173
|
# https://github.com/home-assistant/core/issues/133173
|
||||||
Platform.LIGHT,
|
Platform.LIGHT,
|
||||||
|
23
tests/components/tuya/fixtures/fs_ibytpo6fpnugft1c.json
Normal file
23
tests/components/tuya/fixtures/fs_ibytpo6fpnugft1c.json
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
{
|
||||||
|
"endpoint": "https://apigw.tuyaeu.com",
|
||||||
|
"terminal_id": "REDACTED",
|
||||||
|
"mqtt_connected": true,
|
||||||
|
"disabled_by": null,
|
||||||
|
"disabled_polling": false,
|
||||||
|
"id": "10706550a4e57c88b93a",
|
||||||
|
"name": "Ventilador Cama",
|
||||||
|
"category": "fs",
|
||||||
|
"product_id": "ibytpo6fpnugft1c",
|
||||||
|
"product_name": "Tower bladeless fan ",
|
||||||
|
"online": true,
|
||||||
|
"sub": false,
|
||||||
|
"time_zone": "+01:00",
|
||||||
|
"active_time": "2025-01-10T18:47:46+00:00",
|
||||||
|
"create_time": "2025-01-10T18:47:46+00:00",
|
||||||
|
"update_time": "2025-01-10T18:47:46+00:00",
|
||||||
|
"function": {},
|
||||||
|
"status_range": {},
|
||||||
|
"status": {},
|
||||||
|
"set_up": true,
|
||||||
|
"support_local": true
|
||||||
|
}
|
@@ -53,56 +53,6 @@
|
|||||||
'state': 'unavailable',
|
'state': 'unavailable',
|
||||||
})
|
})
|
||||||
# ---
|
# ---
|
||||||
# name: test_platform_setup_and_discovery[cs_vmxuxszzjwp5smli][fan.dehumidifier-entry]
|
|
||||||
EntityRegistryEntrySnapshot({
|
|
||||||
'aliases': set({
|
|
||||||
}),
|
|
||||||
'area_id': None,
|
|
||||||
'capabilities': dict({
|
|
||||||
}),
|
|
||||||
'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.dehumidifier',
|
|
||||||
'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': 'tuya',
|
|
||||||
'previous_unique_id': None,
|
|
||||||
'suggested_object_id': None,
|
|
||||||
'supported_features': 0,
|
|
||||||
'translation_key': None,
|
|
||||||
'unique_id': 'tuya.mock_device_id',
|
|
||||||
'unit_of_measurement': None,
|
|
||||||
})
|
|
||||||
# ---
|
|
||||||
# name: test_platform_setup_and_discovery[cs_vmxuxszzjwp5smli][fan.dehumidifier-state]
|
|
||||||
StateSnapshot({
|
|
||||||
'attributes': ReadOnlyDict({
|
|
||||||
'friendly_name': 'Dehumidifier ',
|
|
||||||
'supported_features': <FanEntityFeature: 0>,
|
|
||||||
}),
|
|
||||||
'context': <ANY>,
|
|
||||||
'entity_id': 'fan.dehumidifier',
|
|
||||||
'last_changed': <ANY>,
|
|
||||||
'last_reported': <ANY>,
|
|
||||||
'last_updated': <ANY>,
|
|
||||||
'state': 'unknown',
|
|
||||||
})
|
|
||||||
# ---
|
|
||||||
# name: test_platform_setup_and_discovery[cs_zibqa9dutqyaxym2][fan.dehumidifier-entry]
|
# name: test_platform_setup_and_discovery[cs_zibqa9dutqyaxym2][fan.dehumidifier-entry]
|
||||||
EntityRegistryEntrySnapshot({
|
EntityRegistryEntrySnapshot({
|
||||||
'aliases': set({
|
'aliases': set({
|
||||||
|
Reference in New Issue
Block a user