keypad.py 548 B

12345678910111213141516171819202122
  1. """Keypad parser."""
  2. from __future__ import annotations
  3. import logging
  4. _LOGGER = logging.getLogger(__name__)
  5. def process_wokeypad(
  6. data: bytes | None,
  7. mfr_data: bytes | None,
  8. ) -> dict[str, bool | int | None]:
  9. """Process woKeypad services data."""
  10. if data is None or mfr_data is None:
  11. return {"battery": None, "attempt_state": None}
  12. _LOGGER.debug("mfr_data: %s", mfr_data.hex())
  13. if data:
  14. _LOGGER.debug("data: %s", data.hex())
  15. return {"battery": data[2] & 0b01111111, "attempt_state": mfr_data[6]}