bulb.py 542 B

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