mirror of
https://github.com/home-assistant/core.git
synced 2025-07-11 23:37:18 +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
|
name = entry.title
|
||||||
device: MiioDevice | None = None
|
device: MiioDevice | None = None
|
||||||
migrate = False
|
migrate = False
|
||||||
|
lazy_discover = False
|
||||||
update_method = _async_update_data_default
|
update_method = _async_update_data_default
|
||||||
coordinator_class: type[DataUpdateCoordinator[Any]] = DataUpdateCoordinator
|
coordinator_class: type[DataUpdateCoordinator[Any]] = DataUpdateCoordinator
|
||||||
|
|
||||||
@ -307,38 +308,41 @@ async def async_create_miio_device_and_coordinator(
|
|||||||
|
|
||||||
# Humidifiers
|
# Humidifiers
|
||||||
if model in MODELS_HUMIDIFIER_MIOT:
|
if model in MODELS_HUMIDIFIER_MIOT:
|
||||||
device = AirHumidifierMiot(host, token)
|
device = AirHumidifierMiot(host, token, lazy_discover=lazy_discover)
|
||||||
migrate = True
|
migrate = True
|
||||||
elif model in MODELS_HUMIDIFIER_MJJSQ:
|
elif model in MODELS_HUMIDIFIER_MJJSQ:
|
||||||
device = AirHumidifierMjjsq(host, token, model=model)
|
device = AirHumidifierMjjsq(
|
||||||
|
host, token, lazy_discover=lazy_discover, model=model
|
||||||
|
)
|
||||||
migrate = True
|
migrate = True
|
||||||
elif model in MODELS_HUMIDIFIER_MIIO:
|
elif model in MODELS_HUMIDIFIER_MIIO:
|
||||||
device = AirHumidifier(host, token, model=model)
|
device = AirHumidifier(host, token, lazy_discover=lazy_discover, model=model)
|
||||||
migrate = True
|
migrate = True
|
||||||
# Airpurifiers and Airfresh
|
# Airpurifiers and Airfresh
|
||||||
elif model in MODELS_PURIFIER_MIOT:
|
elif model in MODELS_PURIFIER_MIOT:
|
||||||
device = AirPurifierMiot(host, token)
|
device = AirPurifierMiot(host, token, lazy_discover=lazy_discover)
|
||||||
elif model.startswith("zhimi.airpurifier."):
|
elif model.startswith("zhimi.airpurifier."):
|
||||||
device = AirPurifier(host, token)
|
device = AirPurifier(host, token, lazy_discover=lazy_discover)
|
||||||
elif model.startswith("zhimi.airfresh."):
|
elif model.startswith("zhimi.airfresh."):
|
||||||
device = AirFresh(host, token)
|
device = AirFresh(host, token, lazy_discover=lazy_discover)
|
||||||
elif model == MODEL_AIRFRESH_A1:
|
elif model == MODEL_AIRFRESH_A1:
|
||||||
device = AirFreshA1(host, token)
|
device = AirFreshA1(host, token, lazy_discover=lazy_discover)
|
||||||
elif model == MODEL_AIRFRESH_T2017:
|
elif model == MODEL_AIRFRESH_T2017:
|
||||||
device = AirFreshT2017(host, token)
|
device = AirFreshT2017(host, token, lazy_discover=lazy_discover)
|
||||||
elif (
|
elif (
|
||||||
model in MODELS_VACUUM
|
model in MODELS_VACUUM
|
||||||
or model.startswith(ROBOROCK_GENERIC)
|
or model.startswith(ROBOROCK_GENERIC)
|
||||||
or model.startswith(ROCKROBO_GENERIC)
|
or model.startswith(ROCKROBO_GENERIC)
|
||||||
):
|
):
|
||||||
|
# TODO: add lazy_discover as argument when python-miio add support # pylint: disable=fixme
|
||||||
device = RoborockVacuum(host, token)
|
device = RoborockVacuum(host, token)
|
||||||
update_method = _async_update_data_vacuum
|
update_method = _async_update_data_vacuum
|
||||||
coordinator_class = DataUpdateCoordinator[VacuumCoordinatorData]
|
coordinator_class = DataUpdateCoordinator[VacuumCoordinatorData]
|
||||||
# Pedestal fans
|
# Pedestal fans
|
||||||
elif model in MODEL_TO_CLASS_MAP:
|
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:
|
elif model in MODELS_FAN_MIIO:
|
||||||
device = Fan(host, token, model=model)
|
device = Fan(host, token, lazy_discover=lazy_discover, model=model)
|
||||||
else:
|
else:
|
||||||
_LOGGER.error(
|
_LOGGER.error(
|
||||||
(
|
(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user