File: ceiling_light.py

package info (click to toggle)
pyswitchbot 0.72.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 876 kB
  • sloc: python: 12,717; makefile: 2
file content (26 lines) | stat: -rw-r--r-- 668 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
"""Ceiling Light adv parser."""

from __future__ import annotations

import logging

_LOGGER = logging.getLogger(__name__)

# Off d94b2d012b3c4864106124
# on  d94b2d012b3c4a641061a4
# Off d94b2d012b3c4b64106124
# on  d94b2d012b3c4d641061a4
#     00112233445566778899AA


def process_woceiling(data: bytes, mfr_data: bytes | None) -> dict[str, bool | int]:
    """Process WoCeiling services data."""
    if mfr_data is None:
        return {}
    return {
        "sequence_number": mfr_data[6],
        "isOn": bool(mfr_data[10] & 0b10000000),
        "brightness": mfr_data[7] & 0b01111111,
        "cw": int(mfr_data[8:10].hex(), 16),
        "color_mode": 1,
    }