vacuum.py 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. """Library to handle connection with Switchbot."""
  2. from __future__ import annotations
  3. from typing import Any
  4. from .device import SwitchbotSequenceDevice, update_after_operation
  5. COMMAND_CLEAN_UP = {
  6. 1: "570F5A00FFFF7001",
  7. 2: "5A400101010126",
  8. }
  9. COMMAND_RETURN_DOCK = {
  10. 1: "570F5A00FFFF7002",
  11. 2: "5A400101010225",
  12. }
  13. class SwitchbotVacuum(SwitchbotSequenceDevice):
  14. """Representation of a Switchbot Vacuum."""
  15. @update_after_operation
  16. async def clean_up(self, protocol_version: int) -> bool:
  17. """Send command to perform a spot clean-up."""
  18. return await self._send_command(COMMAND_CLEAN_UP[protocol_version])
  19. @update_after_operation
  20. async def return_to_dock(self, protocol_version: int) -> bool:
  21. """Send command to return the dock."""
  22. return await self._send_command(COMMAND_RETURN_DOCK[protocol_version])
  23. async def get_basic_info(self) -> dict[str, Any] | None:
  24. """Only support get the ble version through the command."""
  25. if not (_data := await self._get_basic_info()):
  26. return None
  27. return {
  28. "firmware": _data[2],
  29. }
  30. def get_soc_version(self) -> str:
  31. """Return device soc version."""
  32. return self._get_adv_value("soc_version")
  33. def get_last_step(self) -> int:
  34. """Return device last step after network configuration."""
  35. return self._get_adv_value("step")
  36. def get_mqtt_connnect_status(self) -> bool:
  37. """Return device mqtt connect status."""
  38. return self._get_adv_value("mqtt_connected")
  39. def get_battery(self) -> int:
  40. """Return device battery."""
  41. return self._get_adv_value("battery")
  42. def get_work_status(self) -> int:
  43. """Return device work status."""
  44. return self._get_adv_value("work_status")
  45. def get_dustbin_bound_status(self) -> bool:
  46. """Return the dustbin bound status"""
  47. return self._get_adv_value("dustbin_bound")
  48. def get_dustbin_connnected_status(self) -> bool:
  49. """Return the dustbin connected status"""
  50. return self._get_adv_value("dusbin_connected")
  51. def get_network_connected_status(self) -> bool:
  52. """Return the network connected status"""
  53. return self._get_adv_value("network_connected")