Skip to content

Commit

Permalink
Feature/deattach-lib (#13)
Browse files Browse the repository at this point in the history
* feat(lib): migrate non hass items to midea-local

* chore: bump midea-local version

* chore(black): reformating code

* chore(flake8): code formating

* chore(isort): reformat code

* chore(manifest): bump version

* chore(requirements): bump midea-local version

* chore: bump version 0.4.0-alpha

* chore: isort lint
  • Loading branch information
rokam authored May 28, 2024
1 parent bbb590f commit 4c1b1d1
Show file tree
Hide file tree
Showing 86 changed files with 2,229 additions and 15,075 deletions.
28 changes: 14 additions & 14 deletions custom_components/midea_ac_lan/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
CONF_TYPE,
)
from homeassistant.core import HomeAssistant
from midealocal.devices import device_selector

from .const import (
ALL_PLATFORM,
Expand All @@ -25,7 +26,6 @@
DOMAIN,
EXTRA_SWITCH,
)
from .midea.devices import async_device_selector
from .midea_devices import MIDEA_DEVICES

_LOGGER = logging.getLogger(__name__)
Expand Down Expand Up @@ -153,19 +153,19 @@ async def async_setup_entry(hass: HomeAssistant, config_entry):
if protocol == 3 and (key is None or key is None):
_LOGGER.error("For V3 devices, the key and the token is required.")
return False
device = await async_device_selector(
hass=hass,
name=name,
device_id=device_id,
device_type=device_type,
ip_address=ip_address,
port=port,
token=token,
key=key,
protocol=protocol,
model=model,
subtype=subtype,
customize=customize,
device = await hass.async_add_import_executor_job(
device_selector,
name,
device_id,
device_type,
ip_address,
port,
token,
key,
protocol,
model,
subtype,
customize,
)
if refresh_interval is not None:
device.set_refresh_interval(refresh_interval)
Expand Down
10 changes: 5 additions & 5 deletions custom_components/midea_ac_lan/climate.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,13 @@
Platform,
UnitOfTemperature,
)
from midealocal.devices.ac import DeviceAttributes as ACAttributes
from midealocal.devices.c3 import DeviceAttributes as C3Attributes
from midealocal.devices.cc import DeviceAttributes as CCAttributes
from midealocal.devices.cf import DeviceAttributes as CFAttributes
from midealocal.devices.fb import DeviceAttributes as FBAttributes

from .const import DEVICES, DOMAIN
from .midea.devices.ac.device import DeviceAttributes as ACAttributes
from .midea.devices.c3.device import DeviceAttributes as C3Attributes
from .midea.devices.cc.device import DeviceAttributes as CCAttributes
from .midea.devices.cf.device import DeviceAttributes as CFAttributes
from .midea.devices.fb.device import DeviceAttributes as FBAttributes
from .midea_devices import MIDEA_DEVICES
from .midea_entity import MideaEntity

Expand Down
10 changes: 5 additions & 5 deletions custom_components/midea_ac_lan/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@
from homeassistant.core import callback
from homeassistant.helpers.aiohttp_client import async_create_clientsession
from homeassistant.util.json import load_json
from midealocal.cloud import get_midea_cloud
from midealocal.device import MideaDevice
from midealocal.discover import discover

from .const import (
CONF_ACCOUNT,
Expand All @@ -40,9 +43,6 @@
EXTRA_CONTROL,
EXTRA_SENSOR,
)
from .midea.core.cloud import get_midea_cloud
from .midea.core.device import MiedaDevice
from .midea.core.discover import discover
from .midea_devices import MIDEA_DEVICES

_LOGGER = logging.getLogger(__name__)
Expand Down Expand Up @@ -308,7 +308,7 @@ async def async_step_auto(self, user_input=None, error=None):
return await self.async_step_auto(error="preset_account")
keys = await self.cloud.get_keys(user_input[CONF_DEVICE])
for method, key in keys.items():
dm = MiedaDevice(
dm = MideaDevice(
name="",
device_id=device_id,
device_type=device.get(CONF_TYPE),
Expand Down Expand Up @@ -363,7 +363,7 @@ async def async_step_manually(self, user_input=None, error=None):
len(user_input[CONF_TOKEN]) == 0 or len(user_input[CONF_KEY]) == 0
):
return await self.async_step_manually(error="invalid_token")
dm = MiedaDevice(
dm = MideaDevice(
name="",
device_id=user_input[CONF_DEVICE_ID],
device_type=user_input[CONF_TYPE],
Expand Down
6 changes: 3 additions & 3 deletions custom_components/midea_ac_lan/fan.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@
STATE_ON,
Platform,
)
from midealocal.devices.ac import DeviceAttributes as ACAttributes
from midealocal.devices.ce import DeviceAttributes as CEAttributes
from midealocal.devices.x40 import DeviceAttributes as X40Attributes

from .const import DEVICES, DOMAIN
from .midea.devices.ac.device import DeviceAttributes as ACAttributes
from .midea.devices.ce.device import DeviceAttributes as CEAttributes
from .midea.devices.x40.device import DeviceAttributes as X40Attributes
from .midea_devices import MIDEA_DEVICES
from .midea_entity import MideaEntity

Expand Down
2 changes: 1 addition & 1 deletion custom_components/midea_ac_lan/light.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
LightEntityFeature,
)
from homeassistant.const import CONF_DEVICE_ID, CONF_SWITCHES, Platform
from midealocal.devices.x13 import DeviceAttributes as X13Attributes

from .const import DEVICES, DOMAIN
from .midea.devices.x13.device import DeviceAttributes as X13Attributes
from .midea_devices import MIDEA_DEVICES
from .midea_entity import MideaEntity

Expand Down
10 changes: 6 additions & 4 deletions custom_components/midea_ac_lan/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
"domain": "midea_ac_lan",
"name": "Midea AC LAN",
"codeowners": [
"@wuwentao"
"@wuwentao",
"@rokam"
],
"config_flow": true,
"dependencies": [],
Expand All @@ -11,7 +12,8 @@
"iot_class": "local_push",
"issue_tracker": "https://github.com/wuwentao/midea_ac_lan/issues",
"requirements": [
"pycryptodome"
"pycryptodome",
"midea-local==1.0.3"
],
"version": "v0.3.23"
}
"version": "v0.4.0-alpha"
}
35 changes: 0 additions & 35 deletions custom_components/midea_ac_lan/midea/backports/myenum.py

This file was deleted.

Loading

0 comments on commit 4c1b1d1

Please sign in to comment.