motion.py 603 B

12345678910111213141516
  1. """Motion sensor parser."""
  2. from __future__ import annotations
  3. def process_wopresence(data: bytes, mfr_data: bytes | None) -> dict[str, bool | int]:
  4. """Process WoPresence Sensor services data."""
  5. return {
  6. "tested": bool(data[1] & 0b10000000),
  7. "motion_detected": bool(data[1] & 0b01000000),
  8. "battery": data[2] & 0b01111111,
  9. "led": (data[5] & 0b00100000) >> 5,
  10. "iot": (data[5] & 0b00010000) >> 4,
  11. "sense_distance": (data[5] & 0b00001100) >> 2,
  12. "light_intensity": data[5] & 0b00000011,
  13. "is_light": bool(data[5] & 0b00000010),
  14. }