Skip to content

Commit

Permalink
Disable lazy discover in xiaomi_miio (#82601)
Browse files Browse the repository at this point in the history
* Add lazy discover config option to xiaomi_miio (#59215)

* disable lazy_discover for default

* extend tests to support lazy_discover

* revert config option
  • Loading branch information
mrwogu authored Apr 7, 2023
1 parent b8abc13 commit 7eccef8
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions homeassistant/components/xiaomi_miio/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,7 @@ async def async_create_miio_device_and_coordinator(
name = entry.title
device: MiioDevice | None = None
migrate = False
lazy_discover = False
update_method = _async_update_data_default
coordinator_class: type[DataUpdateCoordinator[Any]] = DataUpdateCoordinator

Expand All @@ -307,38 +308,41 @@ async def async_create_miio_device_and_coordinator(

# Humidifiers
if model in MODELS_HUMIDIFIER_MIOT:
device = AirHumidifierMiot(host, token)
device = AirHumidifierMiot(host, token, lazy_discover=lazy_discover)
migrate = True
elif model in MODELS_HUMIDIFIER_MJJSQ:
device = AirHumidifierMjjsq(host, token, model=model)
device = AirHumidifierMjjsq(
host, token, lazy_discover=lazy_discover, model=model
)
migrate = True
elif model in MODELS_HUMIDIFIER_MIIO:
device = AirHumidifier(host, token, model=model)
device = AirHumidifier(host, token, lazy_discover=lazy_discover, model=model)
migrate = True
# Airpurifiers and Airfresh
elif model in MODELS_PURIFIER_MIOT:
device = AirPurifierMiot(host, token)
device = AirPurifierMiot(host, token, lazy_discover=lazy_discover)
elif model.startswith("zhimi.airpurifier."):
device = AirPurifier(host, token)
device = AirPurifier(host, token, lazy_discover=lazy_discover)
elif model.startswith("zhimi.airfresh."):
device = AirFresh(host, token)
device = AirFresh(host, token, lazy_discover=lazy_discover)
elif model == MODEL_AIRFRESH_A1:
device = AirFreshA1(host, token)
device = AirFreshA1(host, token, lazy_discover=lazy_discover)
elif model == MODEL_AIRFRESH_T2017:
device = AirFreshT2017(host, token)
device = AirFreshT2017(host, token, lazy_discover=lazy_discover)
elif (
model in MODELS_VACUUM
or model.startswith(ROBOROCK_GENERIC)
or model.startswith(ROCKROBO_GENERIC)
):
# TODO: add lazy_discover as argument when python-miio add support # pylint: disable=fixme
device = RoborockVacuum(host, token)
update_method = _async_update_data_vacuum
coordinator_class = DataUpdateCoordinator[VacuumCoordinatorData]
# Pedestal fans
elif model in MODEL_TO_CLASS_MAP:
device = MODEL_TO_CLASS_MAP[model](host, token)
device = MODEL_TO_CLASS_MAP[model](host, token, lazy_discover=lazy_discover)
elif model in MODELS_FAN_MIIO:
device = Fan(host, token, model=model)
device = Fan(host, token, lazy_discover=lazy_discover, model=model)
else:
_LOGGER.error(
(
Expand Down

0 comments on commit 7eccef8

Please sign in to comment.