1
mirror of https://github.com/home-assistant/core synced 2024-09-12 15:16:21 +02:00
ha-core/homeassistant/components/roborock/models.py

26 lines
739 B
Python
Raw Normal View History

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>
2023-04-20 16:02:58 +02:00
"""Roborock Models."""
from dataclasses import dataclass
from typing import Any
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>
2023-04-20 16:02:58 +02:00
from roborock.containers import HomeDataDevice, HomeDataProduct, NetworkInfo
from roborock.roborock_typing import DeviceProp
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>
2023-04-20 16:02:58 +02:00
@dataclass
class RoborockHassDeviceInfo:
"""A model to describe roborock devices."""
device: HomeDataDevice
network_info: NetworkInfo
product: HomeDataProduct
props: DeviceProp
def as_dict(self) -> dict[str, dict[str, Any]]:
"""Turn RoborockHassDeviceInfo into a dictionary."""
return {
"device": self.device.as_dict(),
"network_info": self.network_info.as_dict(),
"product": self.product.as_dict(),
"props": self.props.as_dict(),
}