plug.py 441 B

1234567891011121314
  1. """Library to handle connection with Switchbot."""
  2. from __future__ import annotations
  3. def process_woplugmini(data: bytes, mfr_data: bytes | None) -> dict[str, bool | int]:
  4. """Process plug mini."""
  5. if mfr_data is None:
  6. return {}
  7. return {
  8. "switchMode": True,
  9. "isOn": mfr_data[7] == 0x80,
  10. "wifi_rssi": -mfr_data[9],
  11. "power": (((mfr_data[10] << 8) + mfr_data[11]) & 0x7FFF) / 10, # W
  12. }