mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 13:17:32 +00:00
Support generic xiaomi_miio vacuums (#59317)
* Support generic xiaomi_miio vacuums Signed-off-by: Kevin Hellemun <17928966+OGKevin@users.noreply.github.com> * Fix lint Signed-off-by: Kevin Hellemun <17928966+OGKevin@users.noreply.github.com> * Remove warning log Signed-off-by: Kevin Hellemun <17928966+OGKevin@users.noreply.github.com>
This commit is contained in:
parent
bb1203c61d
commit
20b93132dd
@ -66,6 +66,8 @@ from .const import (
|
|||||||
MODELS_PURIFIER_MIOT,
|
MODELS_PURIFIER_MIOT,
|
||||||
MODELS_SWITCH,
|
MODELS_SWITCH,
|
||||||
MODELS_VACUUM,
|
MODELS_VACUUM,
|
||||||
|
ROBOROCK_GENERIC,
|
||||||
|
ROCKROBO_GENERIC,
|
||||||
AuthException,
|
AuthException,
|
||||||
SetupException,
|
SetupException,
|
||||||
)
|
)
|
||||||
@ -267,7 +269,7 @@ async def async_create_miio_device_and_coordinator(
|
|||||||
hass: core.HomeAssistant, entry: config_entries.ConfigEntry
|
hass: core.HomeAssistant, entry: config_entries.ConfigEntry
|
||||||
):
|
):
|
||||||
"""Set up a data coordinator and one miio device to service multiple entities."""
|
"""Set up a data coordinator and one miio device to service multiple entities."""
|
||||||
model = entry.data[CONF_MODEL]
|
model: str = entry.data[CONF_MODEL]
|
||||||
host = entry.data[CONF_HOST]
|
host = entry.data[CONF_HOST]
|
||||||
token = entry.data[CONF_TOKEN]
|
token = entry.data[CONF_TOKEN]
|
||||||
name = entry.title
|
name = entry.title
|
||||||
@ -280,6 +282,8 @@ async def async_create_miio_device_and_coordinator(
|
|||||||
model not in MODELS_HUMIDIFIER
|
model not in MODELS_HUMIDIFIER
|
||||||
and model not in MODELS_FAN
|
and model not in MODELS_FAN
|
||||||
and model not in MODELS_VACUUM
|
and model not in MODELS_VACUUM
|
||||||
|
and not model.startswith(ROBOROCK_GENERIC)
|
||||||
|
and not model.startswith(ROCKROBO_GENERIC)
|
||||||
):
|
):
|
||||||
return
|
return
|
||||||
|
|
||||||
@ -304,7 +308,11 @@ async def async_create_miio_device_and_coordinator(
|
|||||||
device = AirPurifier(host, token)
|
device = AirPurifier(host, token)
|
||||||
elif model.startswith("zhimi.airfresh."):
|
elif model.startswith("zhimi.airfresh."):
|
||||||
device = AirFresh(host, token)
|
device = AirFresh(host, token)
|
||||||
elif model in MODELS_VACUUM:
|
elif (
|
||||||
|
model in MODELS_VACUUM
|
||||||
|
or model.startswith(ROBOROCK_GENERIC)
|
||||||
|
or model.startswith(ROCKROBO_GENERIC)
|
||||||
|
):
|
||||||
device = Vacuum(host, token)
|
device = Vacuum(host, token)
|
||||||
update_method = _async_update_data_vacuum
|
update_method = _async_update_data_vacuum
|
||||||
coordinator_class = DataUpdateCoordinator[VacuumCoordinatorData]
|
coordinator_class = DataUpdateCoordinator[VacuumCoordinatorData]
|
||||||
|
@ -202,7 +202,8 @@ ROCKROBO_S4_MAX = "roborock.vacuum.a19"
|
|||||||
ROCKROBO_S5_MAX = "roborock.vacuum.s5e"
|
ROCKROBO_S5_MAX = "roborock.vacuum.s5e"
|
||||||
ROCKROBO_S6_PURE = "roborock.vacuum.a08"
|
ROCKROBO_S6_PURE = "roborock.vacuum.a08"
|
||||||
ROCKROBO_E2 = "roborock.vacuum.e2"
|
ROCKROBO_E2 = "roborock.vacuum.e2"
|
||||||
ROCKROBO_GENERIC = "roborock.vacuum"
|
ROBOROCK_GENERIC = "roborock.vacuum"
|
||||||
|
ROCKROBO_GENERIC = "rockrobo.vacuum"
|
||||||
MODELS_VACUUM = [
|
MODELS_VACUUM = [
|
||||||
ROCKROBO_V1,
|
ROCKROBO_V1,
|
||||||
ROCKROBO_E2,
|
ROCKROBO_E2,
|
||||||
@ -214,6 +215,7 @@ MODELS_VACUUM = [
|
|||||||
ROCKROBO_S6_MAXV,
|
ROCKROBO_S6_MAXV,
|
||||||
ROCKROBO_S6_PURE,
|
ROCKROBO_S6_PURE,
|
||||||
ROCKROBO_S7,
|
ROCKROBO_S7,
|
||||||
|
ROBOROCK_GENERIC,
|
||||||
ROCKROBO_GENERIC,
|
ROCKROBO_GENERIC,
|
||||||
]
|
]
|
||||||
MODELS_VACUUM_WITH_MOP = [
|
MODELS_VACUUM_WITH_MOP = [
|
||||||
|
@ -81,6 +81,8 @@ from .const import (
|
|||||||
MODELS_PURIFIER_MIIO,
|
MODELS_PURIFIER_MIIO,
|
||||||
MODELS_PURIFIER_MIOT,
|
MODELS_PURIFIER_MIOT,
|
||||||
MODELS_VACUUM,
|
MODELS_VACUUM,
|
||||||
|
ROBOROCK_GENERIC,
|
||||||
|
ROCKROBO_GENERIC,
|
||||||
)
|
)
|
||||||
from .device import XiaomiCoordinatedMiioEntity, XiaomiMiioEntity
|
from .device import XiaomiCoordinatedMiioEntity, XiaomiMiioEntity
|
||||||
from .gateway import XiaomiGatewayDevice
|
from .gateway import XiaomiGatewayDevice
|
||||||
@ -592,7 +594,7 @@ async def async_setup_entry(hass, config_entry, async_add_entities):
|
|||||||
elif config_entry.data[CONF_FLOW_TYPE] == CONF_DEVICE:
|
elif config_entry.data[CONF_FLOW_TYPE] == CONF_DEVICE:
|
||||||
host = config_entry.data[CONF_HOST]
|
host = config_entry.data[CONF_HOST]
|
||||||
token = config_entry.data[CONF_TOKEN]
|
token = config_entry.data[CONF_TOKEN]
|
||||||
model = config_entry.data[CONF_MODEL]
|
model: str = config_entry.data[CONF_MODEL]
|
||||||
|
|
||||||
if model in (MODEL_FAN_ZA1, MODEL_FAN_ZA3, MODEL_FAN_ZA4, MODEL_FAN_P5):
|
if model in (MODEL_FAN_ZA1, MODEL_FAN_ZA3, MODEL_FAN_ZA4, MODEL_FAN_P5):
|
||||||
return
|
return
|
||||||
@ -624,7 +626,11 @@ async def async_setup_entry(hass, config_entry, async_add_entities):
|
|||||||
sensors = PURIFIER_MIIO_SENSORS
|
sensors = PURIFIER_MIIO_SENSORS
|
||||||
elif model in MODELS_PURIFIER_MIOT:
|
elif model in MODELS_PURIFIER_MIOT:
|
||||||
sensors = PURIFIER_MIOT_SENSORS
|
sensors = PURIFIER_MIOT_SENSORS
|
||||||
elif model in MODELS_VACUUM:
|
elif (
|
||||||
|
model in MODELS_VACUUM
|
||||||
|
or model.startswith(ROBOROCK_GENERIC)
|
||||||
|
or model.startswith(ROCKROBO_GENERIC)
|
||||||
|
):
|
||||||
return _setup_vacuum_sensors(hass, config_entry, async_add_entities)
|
return _setup_vacuum_sensors(hass, config_entry, async_add_entities)
|
||||||
|
|
||||||
for sensor, description in SENSOR_TYPES.items():
|
for sensor, description in SENSOR_TYPES.items():
|
||||||
|
Loading…
x
Reference in New Issue
Block a user