Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replaced deprecated constants and wildcard imports (HA >= 2023.1) #420

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Thanks also to [@NeoAcheron](https://github.com/NeoAcheron/midea-ac-py).

⭐If this component is helpful for you, please star it, it encourages me a lot.

***❗Note: Home Assistant 2022.5 or higher required for this integration***
***❗Note: Home Assistant 2023.1 or higher required for this integration***

# Supported brands

Expand Down
2 changes: 1 addition & 1 deletion README_hans.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

⭐如果本集成对你有所帮助, 请不吝为它点个星, 这将是对我的极大激励。

***❗注意: 本集成需要Home Assistant 2022.5或更高版本***
***❗注意: 本集成需要Home Assistant 2023.1或更高版本***

# 已支持的品牌

Expand Down
29 changes: 24 additions & 5 deletions custom_components/midea_ac_lan/climate.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,32 @@
from homeassistant.components.climate import *
from homeassistant.components.climate.const import *
from homeassistant.components.climate import (
ATTR_HVAC_MODE,
ClimateEntity,
ClimateEntityFeature,
FAN_AUTO,
FAN_HIGH,
FAN_LOW,
FAN_MEDIUM,
HVACMode,
PRESET_AWAY,
PRESET_BOOST,
PRESET_COMFORT,
PRESET_ECO,
PRESET_NONE,
PRESET_SLEEP,
SWING_BOTH,
SWING_HORIZONTAL,
SWING_OFF,
SWING_ON,
SWING_VERTICAL,
)
from homeassistant.const import (
Platform,
TEMP_CELSIUS,
UnitOfTemperature,
PRECISION_WHOLE,
PRECISION_HALVES,
ATTR_TEMPERATURE,
CONF_DEVICE_ID,
CONF_SWITCHES
CONF_SWITCHES,
)

from .const import (
Expand Down Expand Up @@ -77,7 +96,7 @@ def max_temp(self):

@property
def temperature_unit(self):
return TEMP_CELSIUS
return UnitOfTemperature.CELSIUS

@property
def target_temperature_low(self):
Expand Down
14 changes: 8 additions & 6 deletions custom_components/midea_ac_lan/fan.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
from homeassistant.components.fan import *
from typing import Any

from homeassistant.components.fan import FanEntity, FanEntityFeature
from homeassistant.const import (
Platform,
CONF_DEVICE_ID,
Expand Down Expand Up @@ -115,21 +117,21 @@ def update_state(self, status):
class MideaFAFan(MideaFan):
def __init__(self, device, entity_key):
super().__init__(device, entity_key)
self._attr_supported_features = SUPPORT_SET_SPEED | SUPPORT_OSCILLATE | SUPPORT_PRESET_MODE
self._attr_supported_features = FanEntityFeature.SET_SPEED | FanEntityFeature.OSCILLATE | FanEntityFeature.PRESET_MODE
self._attr_speed_count = self._device.speed_count


class MideaB6Fan(MideaFan):
def __init__(self, device, entity_key):
super().__init__(device, entity_key)
self._attr_supported_features = SUPPORT_SET_SPEED | SUPPORT_PRESET_MODE
self._attr_supported_features = FanEntityFeature.SET_SPEED | FanEntityFeature.PRESET_MODE
self._attr_speed_count = self._device.speed_count


class MideaACFreshAirFan(MideaFan):
def __init__(self, device, entity_key):
super().__init__(device, entity_key)
self._attr_supported_features = SUPPORT_SET_SPEED | SUPPORT_PRESET_MODE
self._attr_supported_features = FanEntityFeature.SET_SPEED | FanEntityFeature.PRESET_MODE
self._attr_speed_count = 100

@property
Expand Down Expand Up @@ -173,7 +175,7 @@ def preset_mode(self):
class MideaCEFan(MideaFan):
def __init__(self, device, entity_key):
super().__init__(device, entity_key)
self._attr_supported_features = SUPPORT_SET_SPEED | SUPPORT_PRESET_MODE
self._attr_supported_features = FanEntityFeature.SET_SPEED | FanEntityFeature.PRESET_MODE
self._attr_speed_count = self._device.speed_count

def turn_on(self, percentage, preset_mode, **kwargs):
Expand All @@ -186,7 +188,7 @@ async def async_set_percentage(self, percentage: int):
class Midea40Fan(MideaFan):
def __init__(self, device, entity_key):
super().__init__(device, entity_key)
self._attr_supported_features = SUPPORT_SET_SPEED | SUPPORT_OSCILLATE
self._attr_supported_features = FanEntityFeature.SET_SPEED | FanEntityFeature.OSCILLATE
self._attr_speed_count = 2

@property
Expand Down
7 changes: 5 additions & 2 deletions custom_components/midea_ac_lan/humidifier.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
from homeassistant.components.humidifier import *
from homeassistant.components.humidifier.const import *
from homeassistant.components.humidifier import (
HumidifierDeviceClass,
HumidifierEntity,
HumidifierEntityFeature,
)
from homeassistant.const import (
Platform,
CONF_DEVICE_ID,
Expand Down
14 changes: 13 additions & 1 deletion custom_components/midea_ac_lan/light.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
import logging
from homeassistant.components.light import *
from typing import Any

from homeassistant.components.light import (
ATTR_BRIGHTNESS,
ATTR_COLOR_TEMP,
ATTR_EFFECT,
LightEntity,
LightEntityFeature,
SUPPORT_BRIGHTNESS,
SUPPORT_COLOR,
SUPPORT_COLOR_TEMP,
SUPPORT_EFFECT,
)
from homeassistant.const import (
Platform,
CONF_DEVICE_ID,
Expand Down
Loading