Skip to content

Commit

Permalink
fix old versions compatibility (#35)
Browse files Browse the repository at this point in the history
  • Loading branch information
caibinqing authored May 29, 2024
1 parent 5411738 commit 928f4e2
Showing 1 changed file with 31 additions and 14 deletions.
45 changes: 31 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,8 @@
CONF_PROTOCOL,
CONF_TOKEN,
CONF_TYPE,
MAJOR_VERSION,
MINOR_VERSION,
)
from homeassistant.core import HomeAssistant
from homeassistant.helpers.typing import ConfigType
Expand Down Expand Up @@ -164,20 +166,35 @@ async def async_setup_entry(hass: HomeAssistant, config_entry: ConfigEntry) -> b
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 hass.async_add_import_executor_job(
device_selector,
name,
device_id,
device_type,
ip_address,
port,
token,
key,
protocol,
model,
subtype,
customize,
)
if (MAJOR_VERSION, MINOR_VERSION) >= (2024, 3):
device = await hass.async_add_import_executor_job(
device_selector,
name,
device_id,
device_type,
ip_address,
port,
token,
key,
protocol,
model,
subtype,
customize,
)
else:
device = device_selector(
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,
)
if refresh_interval is not None:
device.set_refresh_interval(refresh_interval)
if device:
Expand Down

0 comments on commit 928f4e2

Please sign in to comment.