File: keypad.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 (22 lines) | stat: -rw-r--r-- 548 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
"""Keypad parser."""

from __future__ import annotations

import logging

_LOGGER = logging.getLogger(__name__)


def process_wokeypad(
    data: bytes | None,
    mfr_data: bytes | None,
) -> dict[str, bool | int | None]:
    """Process woKeypad services data."""
    if data is None or mfr_data is None:
        return {"battery": None, "attempt_state": None}

    _LOGGER.debug("mfr_data: %s", mfr_data.hex())
    if data:
        _LOGGER.debug("data: %s", data.hex())

    return {"battery": data[2] & 0b01111111, "attempt_state": mfr_data[6]}