Add new Roborock Integration (#89456)

* init roborock commit

* init commit of roborock

* removed some non-vacuum related code

* removed some non-needed constants

* removed translations

* removed options flow

* removed manual control

* remove password login

* removed go-to

* removed unneeded function and improved device_stat

* removed utils as it is unused

* typing changes in vacuum.py

* fixed test patch paths

* removed unneeded records

* removing unneeded code in tests

* remove password from strings

* removed maps in code

* changed const, reworked functions

* remove menu

* fixed tests

* 100% code coverage config_flow

* small changes

* removed unneeded patch

* bump to 0.1.7

* removed services

* removed extra functions and mop

* add () to configEntryNotReady

* moved coordinator into seperate file

* update roborock testing

* removed stale options code

* normalize username for unique id

* removed unneeded variables

* fixed linter problems

* removed stale comment

* additional pr changes

* simplify config_flow

* fix config flow test

* Apply suggestions from code review

Co-authored-by: Allen Porter <allen.porter@gmail.com>

* First pass at resolving PR comments

* reworked config flow

* moving vacuum attr

* attempt to clean up conflig flow more

* update package and use offline functionality

* Fixed errors and fan bug

* rework model and some other small changes

* bump version

* used default factory

* moved some client creation into coord

* fixed patch

* Update homeassistant/components/roborock/coordinator.py

Co-authored-by: Allen Porter <allen.porter@gmail.com>

* moved async functions into gather

* reworked gathers

* removed random line

* error catch if networking doesn't exist or timeout

* bump to 0.6.5

* fixed mocked data reference url

* change checking if we have no network information

Co-authored-by: Allen Porter <allen.porter@gmail.com>

---------

Co-authored-by: Allen Porter <allen.porter@gmail.com>
Co-authored-by: Allen Porter <allen@thebends.org>
This commit is contained in:
Luke 2023-04-20 10:02:58 -04:00 committed by GitHub
parent af193094b5
commit b4e0a1f1fc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
22 changed files with 1218 additions and 4 deletions

View file

@ -0,0 +1,62 @@
"""Support for Roborock device base class."""
from typing import Any
from roborock.containers import Status
from roborock.typing import RoborockCommand
from homeassistant.helpers.entity import DeviceInfo
from homeassistant.helpers.update_coordinator import CoordinatorEntity
from . import RoborockDataUpdateCoordinator
from .const import DOMAIN
from .models import RoborockHassDeviceInfo
class RoborockCoordinatedEntity(CoordinatorEntity[RoborockDataUpdateCoordinator]):
"""Representation of a base a coordinated Roborock Entity."""
_attr_has_entity_name = True
def __init__(
self,
unique_id: str,
device_info: RoborockHassDeviceInfo,
coordinator: RoborockDataUpdateCoordinator,
) -> None:
"""Initialize the coordinated Roborock Device."""
super().__init__(coordinator)
self._attr_unique_id = unique_id
self._device_name = device_info.device.name
self._device_id = device_info.device.duid
self._device_model = device_info.product.model
self._fw_version = device_info.device.fv
@property
def _device_status(self) -> Status:
"""Return the status of the device."""
data = self.coordinator.data
if data:
device_data = data.get(self._device_id)
if device_data:
status = device_data.status
if status:
return status
return Status({})
@property
def device_info(self) -> DeviceInfo:
"""Return the device info."""
return DeviceInfo(
name=self._device_name,
identifiers={(DOMAIN, self._device_id)},
manufacturer="Roborock",
model=self._device_model,
sw_version=self._fw_version,
)
async def send(
self, command: RoborockCommand, params: dict[str, Any] | list[Any] | None = None
) -> dict:
"""Send a command to a vacuum cleaner."""
return await self.coordinator.api.send_command(self._device_id, command, params)