vacuum.py 2.3 KB

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