8000 Support generic xiaomi_miio vacuums by OGKevin · Pull Request #59317 · home-assistant/core · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Support generic xiaomi_miio vacuums #59317

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Nov 8, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files. 8000
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions homeassistant/components/xiaomi_miio/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@
MODELS_PURIFIER_MIOT,
MODELS_SWITCH,
MODELS_VACUUM,
ROBOROCK_GENERIC,
ROCKROBO_GENERIC,
AuthException,
SetupException,
)
Expand Down Expand Up @@ -267,7 +269,7 @@ async def async_create_miio_device_and_coordinator(
hass: core.HomeAssistant, entry: config_entries.ConfigEntry
):
"""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]
token = entry.data[CONF_TOKEN]
name = entry.title
Expand All @@ -280,6 +282,8 @@ async def async_create_miio_device_and_coordinator(
model not in MODELS_HUMIDIFIER
and model not in MODELS_FAN
and model not in MODELS_VACUUM
and not model.startswith(ROBOROCK_GENERIC)
and not model.startswith(ROCKROBO_GENERIC)
):
return

Expand All @@ -304,7 +308,11 @@ async def async_create_miio_device_and_coordinator(
device = AirPurifier(host, token)
elif model.startswith("zhimi.airfresh."):
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)
update_method = _async_update_data_vacuum
coordinator_class = DataUpdateCoordinator[VacuumCoordinatorData]
Expand Down
4 changes: 3 additions & 1 deletion homeassistant/components/xiaomi_miio/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,8 @@ class SetupException(Exception):
ROCKROBO_S5_MAX = "roborock.vacuum.s5e"
ROCKROBO_S6_PURE = "roborock.vacuum.a08"
ROCKROBO_E2 = "roborock.vacuum.e2"
ROCKROBO_GENERIC = "roborock.vacuum"
ROBOROCK_GENERIC = "roborock.vacuum"
ROCKROBO_GENERIC = "rockrobo.vacuum"
MODELS_VACUUM = [
ROCKROBO_V1,
ROCKROBO_E2,
Expand All @@ -214,6 +215,7 @@ class SetupException(Exception):
ROCKROBO_S6_MAXV,
ROCKROBO_S6_PURE,
ROCKROBO_S7,
ROBOROCK_GENERIC,
ROCKROBO_GENERIC,
]
MODELS_VACUUM_WITH_MOP = [
Expand Down
10 changes: 8 additions & 2 deletions homeassistant/components/xiaomi_miio/sensor.py
8000
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@
MODELS_PURIFIER_MIIO,
MODELS_PURIFIER_MIOT,
MODELS_VACUUM,
ROBOROCK_GENERIC,
ROCKROBO_GENERIC,
)
from .device import XiaomiCoordinatedMiioEntity, XiaomiMiioEntity
from .gateway import XiaomiGatewayDevice
Expand Down Expand Up @@ -593,7 +595,7 @@ async def async_setup_entry(hass, config_entry, async_add_entities):
elif config_entry.data[CONF_FLOW_TYPE] == CONF_DEVICE:
host = config_entry.data[CONF_HOST]
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):
return
Expand Down Expand Up @@ -625,7 +627,11 @@ async def async_setup_entry(hass, config_entry, async_add_entities):
sensors = PURIFIER_MIIO_SENSORS
elif model in MODELS_PURIFIER_MIOT:
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)

for sensor, description in SENSOR_TYPES.items():
Expand Down
0