1
0

light_strip.py 617 B

1234567891011121314151617
  1. """Light strip adv parser."""
  2. from __future__ import annotations
  3. def process_wostrip(data: bytes, mfr_data: bytes | None) -> dict[str, bool | int]:
  4. """Process WoStrip services data."""
  5. assert mfr_data is not None
  6. return {
  7. "sequence_number": mfr_data[6],
  8. "isOn": bool(mfr_data[7] & 0b10000000),
  9. "brightness": mfr_data[7] & 0b01111111,
  10. "delay": bool(mfr_data[8] & 0b10000000),
  11. "preset": bool(mfr_data[8] & 0b00001000),
  12. "color_mode": mfr_data[8] & 0b00000111,
  13. "speed": mfr_data[9] & 0b01111111,
  14. "loop_index": mfr_data[10] & 0b11111110,
  15. }