bot.py 432 B

12345678910111213
  1. """Library to handle connection with Switchbot."""
  2. from __future__ import annotations
  3. def process_wohand(data: bytes, mfr_data: bytes | None) -> dict[str, bool | int]:
  4. """Process woHand/Bot services data."""
  5. _switch_mode = bool(data[1] & 0b10000000)
  6. return {
  7. "switchMode": _switch_mode,
  8. "isOn": not bool(data[1] & 0b01000000) if _switch_mode else False,
  9. "battery": data[2] & 0b01111111,
  10. }