Skip to content

Commit

Permalink
Fix Home Assistant 2024.01 deprecations (#245)
Browse files Browse the repository at this point in the history
  • Loading branch information
override80 committed Jul 7, 2024
1 parent 1c6eb91 commit 2b025ac
Showing 1 changed file with 20 additions and 23 deletions.
43 changes: 20 additions & 23 deletions custom_components/xiaomi_miio_fan/fan.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,10 @@
import voluptuous as vol
from homeassistant.components.fan import (
PLATFORM_SCHEMA,
SUPPORT_DIRECTION,
SUPPORT_OSCILLATE,
SUPPORT_PRESET_MODE,
SUPPORT_SET_SPEED,
FanEntity,
FanEntityFeature,
)

from homeassistant.const import (
ATTR_ENTITY_ID,
ATTR_MODE,
Expand Down Expand Up @@ -725,15 +723,14 @@ def __init__(self, name, device, model, unique_id, retries, preset_modes_overrid
self._state_attrs.update(
{attribute: None for attribute in self._available_attributes}
)

@property
def supported_features(self) -> int:
"""Supported features."""
return (
SUPPORT_SET_SPEED
| SUPPORT_PRESET_MODE
| SUPPORT_OSCILLATE
| SUPPORT_DIRECTION
FanEntityFeature.SET_SPEED
| FanEntityFeature.PRESET_MODE
| FanEntityFeature.OSCILLATE
| FanEntityFeature.DIRECTION
)

async def async_update(self):
Expand Down Expand Up @@ -1102,7 +1099,7 @@ def __init__(self, name, device, model, unique_id, retries, preset_modes_overrid
@property
def supported_features(self) -> int:
"""Supported features."""
return SUPPORT_SET_SPEED | SUPPORT_PRESET_MODE | SUPPORT_OSCILLATE
return FanEntityFeature.SET_SPEED | FanEntityFeature.PRESET_MODE | FanEntityFeature.OSCILLATE

async def async_update(self):
"""Fetch state from the device."""
Expand Down Expand Up @@ -1240,7 +1237,7 @@ def __init__(self, name, device, model, unique_id, retries, preset_modes_overrid
@property
def supported_features(self) -> int:
"""Supported features."""
return SUPPORT_SET_SPEED | SUPPORT_PRESET_MODE | SUPPORT_OSCILLATE
return FanEntityFeature.SET_SPEED | FanEntityFeature.PRESET_MODE | FanEntityFeature.OSCILLATE

async def async_update(self):
"""Fetch state from the device."""
Expand Down Expand Up @@ -1416,10 +1413,10 @@ def __init__(self, name, device, model, unique_id, retries, preset_modes_overrid
@property
def supported_features(self) -> int:
return (
SUPPORT_DIRECTION
| SUPPORT_OSCILLATE
| SUPPORT_PRESET_MODE
| SUPPORT_SET_SPEED
FanEntityFeature.DIRECTION
| FanEntityFeature.OSCILLATE
| FanEntityFeature.PRESET_MODE
| FanEntityFeature.SET_SPEED
)

async def async_update(self):
Expand Down Expand Up @@ -1857,10 +1854,10 @@ def __init__(self, name, device, model, unique_id, retries, preset_modes_overrid
@property
def supported_features(self) -> int:
return (
SUPPORT_DIRECTION
| SUPPORT_OSCILLATE
| SUPPORT_PRESET_MODE
| SUPPORT_SET_SPEED
FanEntityFeature.DIRECTION
| FanEntityFeature.OSCILLATE
| FanEntityFeature.PRESET_MODE
| FanEntityFeature.SET_SPEED
)

"""
Expand Down Expand Up @@ -2164,10 +2161,10 @@ def __init__(self, name, device, model, unique_id, retries, preset_modes_overrid
@property
def supported_features(self) -> int:
return (
SUPPORT_DIRECTION
| SUPPORT_OSCILLATE
| SUPPORT_PRESET_MODE
| SUPPORT_SET_SPEED
FanEntityFeature.DIRECTION
| FanEntityFeature.OSCILLATE
| FanEntityFeature.PRESET_MODE
| FanEntityFeature.SET_SPEED
)

async def async_update(self):
Expand Down

0 comments on commit 2b025ac

Please sign in to comment.