mirror of
https://github.com/home-assistant/core.git
synced 2025-07-10 06:47:09 +00:00
Disable lazy discover in xiaomi_miio (#82601)
* Add lazy discover config option to xiaomi_miio (#59215) * disable lazy_discover for default * extend tests to support lazy_discover * revert config option
This commit is contained in:
parent
b8abc1350a
commit
7eccef87c2
@ -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
|
||||
|
||||
@ -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(
|
||||
(
|
||||
|
Loading…
x
Reference in New Issue
Block a user