Skip to content

Commit

Permalink
Merge pull request #35 from haext/elarsson1-fix-fanentityfeatures
Browse files Browse the repository at this point in the history
Fix to Fan TURN_ON and TURN_OFF features required for HA 2025.1
  • Loading branch information
gdgib authored Jan 6, 2025
2 parents 96a58cd + 542883b commit 6fa4a6a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
8 changes: 4 additions & 4 deletions custom_components/vesync/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,15 +84,15 @@ async def async_update_data():
hass.data[DOMAIN][config_entry.entry_id]["coordinator"] = coordinator

device_dict = await async_process_devices(hass, manager)
platforms_list: list = []

for _, vs_p in PLATFORMS.items():
for p, vs_p in PLATFORMS.items():
hass.data[DOMAIN][config_entry.entry_id][vs_p] = []
if device_dict[vs_p]:
hass.data[DOMAIN][config_entry.entry_id][vs_p].extend(device_dict[vs_p])
platforms_list.append(p)

await hass.config_entries.async_forward_entry_setups(
config_entry, list(PLATFORMS.keys())
)
await hass.config_entries.async_forward_entry_setups(config_entry, platforms_list)

async def async_new_device_discovery(service: ServiceCall) -> None:
"""Discover if new devices should be added."""
Expand Down
9 changes: 7 additions & 2 deletions custom_components/vesync/fan.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,14 @@ def __init__(self, fan, coordinator) -> None:
def supported_features(self):
"""Flag supported features."""
return (
FanEntityFeature.SET_SPEED | FanEntityFeature.PRESET_MODE
FanEntityFeature.TURN_ON
| FanEntityFeature.TURN_OFF
| FanEntityFeature.SET_SPEED
| FanEntityFeature.PRESET_MODE
if self.speed_count > 1
else FanEntityFeature.SET_SPEED
else FanEntityFeature.TURN_ON
| FanEntityFeature.TURN_OFF
| FanEntityFeature.SET_SPEED
)

@property
Expand Down

0 comments on commit 6fa4a6a

Please sign in to comment.