Skip to content

Commit

Permalink
enable python3 isort and fix with error
Browse files Browse the repository at this point in the history
  • Loading branch information
wuwentao committed May 21, 2024
1 parent efac6cd commit 1f76482
Show file tree
Hide file tree
Showing 54 changed files with 240 additions and 142 deletions.
27 changes: 21 additions & 6 deletions custom_components/midea_ac_lan/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,29 @@

import homeassistant.helpers.config_validation as cv
import voluptuous as vol
from homeassistant.const import (CONF_CUSTOMIZE, CONF_DEVICE_ID,
CONF_IP_ADDRESS, CONF_NAME, CONF_PORT,
CONF_PROTOCOL, CONF_TOKEN, CONF_TYPE)
from homeassistant.const import (
CONF_CUSTOMIZE,
CONF_DEVICE_ID,
CONF_IP_ADDRESS,
CONF_NAME,
CONF_PORT,
CONF_PROTOCOL,
CONF_TOKEN,
CONF_TYPE,
)
from homeassistant.core import HomeAssistant

from .const import (ALL_PLATFORM, CONF_ACCOUNT, CONF_KEY, CONF_MODEL,
CONF_REFRESH_INTERVAL, CONF_SUBTYPE, DEVICES, DOMAIN,
EXTRA_SWITCH)
from .const import (
ALL_PLATFORM,
CONF_ACCOUNT,
CONF_KEY,
CONF_MODEL,
CONF_REFRESH_INTERVAL,
CONF_SUBTYPE,
DEVICES,
DOMAIN,
EXTRA_SWITCH,
)
from .midea.devices import async_device_selector
from .midea_devices import MIDEA_DEVICES

Expand Down
45 changes: 32 additions & 13 deletions custom_components/midea_ac_lan/climate.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,37 @@
import logging

from homeassistant.components.climate import (ATTR_HVAC_MODE, FAN_AUTO,
FAN_HIGH, FAN_LOW, FAN_MEDIUM,
PRESET_AWAY, PRESET_BOOST,
PRESET_COMFORT, PRESET_ECO,
PRESET_NONE, PRESET_SLEEP,
SWING_BOTH, SWING_HORIZONTAL,
SWING_OFF, SWING_ON,
SWING_VERTICAL, ClimateEntity,
ClimateEntityFeature, HVACMode)
from homeassistant.const import (ATTR_TEMPERATURE, CONF_DEVICE_ID,
CONF_SWITCHES, MAJOR_VERSION, MINOR_VERSION,
PRECISION_HALVES, PRECISION_WHOLE, Platform,
UnitOfTemperature)
from homeassistant.components.climate import (
ATTR_HVAC_MODE,
FAN_AUTO,
FAN_HIGH,
FAN_LOW,
FAN_MEDIUM,
PRESET_AWAY,
PRESET_BOOST,
PRESET_COMFORT,
PRESET_ECO,
PRESET_NONE,
PRESET_SLEEP,
SWING_BOTH,
SWING_HORIZONTAL,
SWING_OFF,
SWING_ON,
SWING_VERTICAL,
ClimateEntity,
ClimateEntityFeature,
HVACMode,
)
from homeassistant.const import (
ATTR_TEMPERATURE,
CONF_DEVICE_ID,
CONF_SWITCHES,
MAJOR_VERSION,
MINOR_VERSION,
PRECISION_HALVES,
PRECISION_WHOLE,
Platform,
UnitOfTemperature,
)

from .const import DEVICES, DOMAIN
from .midea.devices.ac.device import DeviceAttributes as ACAttributes
Expand Down
32 changes: 25 additions & 7 deletions custom_components/midea_ac_lan/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,35 @@

import homeassistant.helpers.config_validation as cv
from homeassistant import config_entries
from homeassistant.const import (CONF_CUSTOMIZE, CONF_DEVICE, CONF_DEVICE_ID,
CONF_IP_ADDRESS, CONF_NAME, CONF_PASSWORD,
CONF_PORT, CONF_PROTOCOL, CONF_SENSORS,
CONF_SWITCHES, CONF_TOKEN, CONF_TYPE)
from homeassistant.const import (
CONF_CUSTOMIZE,
CONF_DEVICE,
CONF_DEVICE_ID,
CONF_IP_ADDRESS,
CONF_NAME,
CONF_PASSWORD,
CONF_PORT,
CONF_PROTOCOL,
CONF_SENSORS,
CONF_SWITCHES,
CONF_TOKEN,
CONF_TYPE,
)
from homeassistant.core import callback
from homeassistant.helpers.aiohttp_client import async_create_clientsession
from homeassistant.util.json import load_json

from .const import (CONF_ACCOUNT, CONF_KEY, CONF_MODEL, CONF_REFRESH_INTERVAL,
CONF_SERVER, CONF_SUBTYPE, DOMAIN, EXTRA_CONTROL,
EXTRA_SENSOR)
from .const import (
CONF_ACCOUNT,
CONF_KEY,
CONF_MODEL,
CONF_REFRESH_INTERVAL,
CONF_SERVER,
CONF_SUBTYPE,
DOMAIN,
EXTRA_CONTROL,
EXTRA_SENSOR,
)
from .midea.core.cloud import get_midea_cloud
from .midea.core.device import MiedaDevice
from .midea.core.discover import discover
Expand Down
9 changes: 7 additions & 2 deletions custom_components/midea_ac_lan/fan.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,13 @@
from typing import Any

from homeassistant.components.fan import FanEntity, FanEntityFeature
from homeassistant.const import (CONF_DEVICE_ID, CONF_SWITCHES, STATE_OFF,
STATE_ON, Platform)
from homeassistant.const import (
CONF_DEVICE_ID,
CONF_SWITCHES,
STATE_OFF,
STATE_ON,
Platform,
)

from .const import DEVICES, DOMAIN
from .midea.devices.ac.device import DeviceAttributes as ACAttributes
Expand Down
8 changes: 5 additions & 3 deletions custom_components/midea_ac_lan/humidifier.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import logging

from homeassistant.components.humidifier import (HumidifierDeviceClass,
HumidifierEntity,
HumidifierEntityFeature)
from homeassistant.components.humidifier import (
HumidifierDeviceClass,
HumidifierEntity,
HumidifierEntityFeature,
)
from homeassistant.const import CONF_DEVICE_ID, CONF_SWITCHES, Platform

from .const import DEVICES, DOMAIN
Expand Down
16 changes: 11 additions & 5 deletions custom_components/midea_ac_lan/light.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
import logging
from typing import Any

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

from .const import DEVICES, DOMAIN
Expand Down
8 changes: 6 additions & 2 deletions custom_components/midea_ac_lan/midea/core/cloud.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,12 @@

from aiohttp import ClientSession

from .security import (CloudSecurity, MeijuCloudSecurity, MideaAirSecurity,
MSmartCloudSecurity)
from .security import (
CloudSecurity,
MeijuCloudSecurity,
MideaAirSecurity,
MSmartCloudSecurity,
)

_LOGGER = logging.getLogger(__name__)

Expand Down
15 changes: 11 additions & 4 deletions custom_components/midea_ac_lan/midea/core/device.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,18 @@
import time
from enum import IntEnum

from .message import (MessageApplianceResponse, MessageQueryAppliance,
MessageQuestCustom, MessageType)
from .message import (
MessageApplianceResponse,
MessageQueryAppliance,
MessageQuestCustom,
MessageType,
)
from .packet_builder import PacketBuilder
from .security import (MSGTYPE_ENCRYPTED_REQUEST, MSGTYPE_HANDSHAKE_REQUEST,
LocalSecurity)
from .security import (
MSGTYPE_ENCRYPTED_REQUEST,
MSGTYPE_HANDSHAKE_REQUEST,
LocalSecurity,
)

_LOGGER = logging.getLogger(__name__)

Expand Down
9 changes: 7 additions & 2 deletions custom_components/midea_ac_lan/midea/devices/a1/message.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
from enum import IntEnum

from ...core.crc8 import calculate
from ...core.message import (MessageBody, MessageRequest, MessageResponse,
MessageType, NewProtocolMessageBody)
from ...core.message import (
MessageBody,
MessageRequest,
MessageResponse,
MessageType,
NewProtocolMessageBody,
)


class NewProtocolTags(IntEnum):
Expand Down
15 changes: 11 additions & 4 deletions custom_components/midea_ac_lan/midea/devices/ac/device.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
import json
import logging

from .message import (MessageACResponse, MessageGeneralSet,
MessageNewProtocolQuery, MessageNewProtocolSet,
MessagePowerQuery, MessageQuery, MessageSubProtocolQuery,
MessageSubProtocolSet, MessageToggleDisplay)
from .message import (
MessageACResponse,
MessageGeneralSet,
MessageNewProtocolQuery,
MessageNewProtocolSet,
MessagePowerQuery,
MessageQuery,
MessageSubProtocolQuery,
MessageSubProtocolSet,
MessageToggleDisplay,
)

try:
from enum import StrEnum
Expand Down
9 changes: 7 additions & 2 deletions custom_components/midea_ac_lan/midea/devices/ac/message.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
from enum import IntEnum

from ...core.crc8 import calculate
from ...core.message import (MessageBody, MessageRequest, MessageResponse,
MessageType, NewProtocolMessageBody)
from ...core.message import (
MessageBody,
MessageRequest,
MessageResponse,
MessageType,
NewProtocolMessageBody,
)

BB_AC_MODES = [0, 3, 1, 2, 4, 5]

Expand Down
3 changes: 1 addition & 2 deletions custom_components/midea_ac_lan/midea/devices/b0/message.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from ...core.message import (MessageBody, MessageRequest, MessageResponse,
MessageType)
from ...core.message import MessageBody, MessageRequest, MessageResponse, MessageType


class MessageB0Base(MessageRequest):
Expand Down
3 changes: 1 addition & 2 deletions custom_components/midea_ac_lan/midea/devices/b1/message.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from ...core.message import (MessageBody, MessageRequest, MessageResponse,
MessageType)
from ...core.message import MessageBody, MessageRequest, MessageResponse, MessageType


class MessageB1Base(MessageRequest):
Expand Down
3 changes: 1 addition & 2 deletions custom_components/midea_ac_lan/midea/devices/b3/message.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from ...core.message import (MessageBody, MessageRequest, MessageResponse,
MessageType)
from ...core.message import MessageBody, MessageRequest, MessageResponse, MessageType


class MessageB3Base(MessageRequest):
Expand Down
3 changes: 1 addition & 2 deletions custom_components/midea_ac_lan/midea/devices/b4/message.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from ...core.message import (MessageBody, MessageRequest, MessageResponse,
MessageType)
from ...core.message import MessageBody, MessageRequest, MessageResponse, MessageType


class MessageB4Base(MessageRequest):
Expand Down
3 changes: 1 addition & 2 deletions custom_components/midea_ac_lan/midea/devices/b6/message.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from ...core.message import (MessageBody, MessageRequest, MessageResponse,
MessageType)
from ...core.message import MessageBody, MessageRequest, MessageResponse, MessageType


class MessageB6Base(MessageRequest):
Expand Down
3 changes: 1 addition & 2 deletions custom_components/midea_ac_lan/midea/devices/bf/message.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from ...core.message import (MessageBody, MessageRequest, MessageResponse,
MessageType)
from ...core.message import MessageBody, MessageRequest, MessageResponse, MessageType


class MessageBFBase(MessageRequest):
Expand Down
3 changes: 1 addition & 2 deletions custom_components/midea_ac_lan/midea/devices/c2/message.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from enum import IntEnum

from ...core.message import (MessageBody, MessageRequest, MessageResponse,
MessageType)
from ...core.message import MessageBody, MessageRequest, MessageResponse, MessageType


class C2MessageEnum(IntEnum):
Expand Down
9 changes: 7 additions & 2 deletions custom_components/midea_ac_lan/midea/devices/c3/device.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
import logging

from .message import (MessageC3Response, MessageQuery, MessageSet,
MessageSetECO, MessageSetSilent)
from .message import (
MessageC3Response,
MessageQuery,
MessageSet,
MessageSetECO,
MessageSetSilent,
)

try:
from enum import StrEnum
Expand Down
3 changes: 1 addition & 2 deletions custom_components/midea_ac_lan/midea/devices/c3/message.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from ...core.message import (MessageBody, MessageRequest, MessageResponse,
MessageType)
from ...core.message import MessageBody, MessageRequest, MessageResponse, MessageType


class MessageC3Base(MessageRequest):
Expand Down
3 changes: 1 addition & 2 deletions custom_components/midea_ac_lan/midea/devices/ca/message.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from ...core.message import (MessageBody, MessageRequest, MessageResponse,
MessageType)
from ...core.message import MessageBody, MessageRequest, MessageResponse, MessageType


class MessageCABase(MessageRequest):
Expand Down
3 changes: 1 addition & 2 deletions custom_components/midea_ac_lan/midea/devices/cc/message.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from ...core.message import (MessageBody, MessageRequest, MessageResponse,
MessageType)
from ...core.message import MessageBody, MessageRequest, MessageResponse, MessageType


class MessageCCBase(MessageRequest):
Expand Down
3 changes: 1 addition & 2 deletions custom_components/midea_ac_lan/midea/devices/cd/message.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from ...core.message import (MessageBody, MessageRequest, MessageResponse,
MessageType)
from ...core.message import MessageBody, MessageRequest, MessageResponse, MessageType


class MessageCDBase(MessageRequest):
Expand Down
3 changes: 1 addition & 2 deletions custom_components/midea_ac_lan/midea/devices/ce/message.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from ...core.message import (MessageBody, MessageRequest, MessageResponse,
MessageType)
from ...core.message import MessageBody, MessageRequest, MessageResponse, MessageType


class MessageFABase(MessageRequest):
Expand Down
3 changes: 1 addition & 2 deletions custom_components/midea_ac_lan/midea/devices/cf/message.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from ...core.message import (MessageBody, MessageRequest, MessageResponse,
MessageType)
from ...core.message import MessageBody, MessageRequest, MessageResponse, MessageType


class MessageCFBase(MessageRequest):
Expand Down
3 changes: 1 addition & 2 deletions custom_components/midea_ac_lan/midea/devices/da/device.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import logging

from .message import (MessageDAResponse, MessagePower, MessageQuery,
MessageStart)
from .message import MessageDAResponse, MessagePower, MessageQuery, MessageStart

try:
from enum import StrEnum
Expand Down
3 changes: 1 addition & 2 deletions custom_components/midea_ac_lan/midea/devices/da/message.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from ...core.message import (MessageBody, MessageRequest, MessageResponse,
MessageType)
from ...core.message import MessageBody, MessageRequest, MessageResponse, MessageType


class MessageDABase(MessageRequest):
Expand Down
Loading

0 comments on commit 1f76482

Please sign in to comment.