1
0

bulb.py 577 B

12345678910111213141516
  1. """Bulb parser."""
  2. from __future__ import annotations
  3. def process_color_bulb(data: bytes, mfr_data: bytes | None) -> dict[str, bool | int]:
  4. """Process WoBulb services data."""
  5. return {
  6. "sequence_number": mfr_data[6],
  7. "isOn": bool(mfr_data[7] & 0b10000000),
  8. "brightness": mfr_data[7] & 0b01111111,
  9. "delay": bool(mfr_data[8] & 0b10000000),
  10. "preset": bool(mfr_data[8] & 0b00001000),
  11. "light_state": mfr_data[8] & 0b00000111,
  12. "speed": mfr_data[9] & 0b01111111,
  13. "loop_index": mfr_data[10] & 0b11111110,
  14. }