ceiling_light.py 668 B

1234567891011121314151617181920212223242526
  1. """Ceiling Light adv parser."""
  2. from __future__ import annotations
  3. import logging
  4. _LOGGER = logging.getLogger(__name__)
  5. # Off d94b2d012b3c4864106124
  6. # on d94b2d012b3c4a641061a4
  7. # Off d94b2d012b3c4b64106124
  8. # on d94b2d012b3c4d641061a4
  9. # 00112233445566778899AA
  10. def process_woceiling(data: bytes, mfr_data: bytes | None) -> dict[str, bool | int]:
  11. """Process WoCeiling services data."""
  12. if mfr_data is None:
  13. return {}
  14. return {
  15. "sequence_number": mfr_data[6],
  16. "isOn": bool(mfr_data[10] & 0b10000000),
  17. "brightness": mfr_data[7] & 0b01111111,
  18. "cw": int(mfr_data[8:10].hex(), 16),
  19. "color_mode": 1,
  20. }