From e24d4de01ea0278722426c8d9bb1a3402546f7b4 Mon Sep 17 00:00:00 2001 From: override80 Date: Thu, 11 Jan 2024 17:59:13 +0100 Subject: [PATCH] fix: HA 2024.01 deprecations --- custom_components/xiaomi_miio_fan/fan.py | 43 +++++++++++------------- 1 file changed, 20 insertions(+), 23 deletions(-) diff --git a/custom_components/xiaomi_miio_fan/fan.py b/custom_components/xiaomi_miio_fan/fan.py index 28b750b..c47b5f1 100644 --- a/custom_components/xiaomi_miio_fan/fan.py +++ b/custom_components/xiaomi_miio_fan/fan.py @@ -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, @@ -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): @@ -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.""" @@ -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.""" @@ -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): @@ -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 ) """ @@ -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):