Debian Codegraph @

src/bthome_ble/event.py

raw symbols SCIP
1 """Event constants for BTHome measurements."""
2
3 from __future__ import annotations
4
5 from sensor_state_data.enum import StrEnum
6
7
8 class EventDeviceKeys(StrEnum):
9 """Keys for devices that send events."""
10
11 # Rocker switch
12 SWITCH = "switch"
13
14 # Dimmer
15 DIMMER = "dimmer"
16
17 # Button
18 BUTTON = "button"
19
20 # Command
21 COMMAND = "command"
22
23
24 BUTTON_EVENTS: dict[int, str | None] = {
25 0x00: None,
26 0x01: "press",
27 0x02: "double_press",
28 0x03: "triple_press",
29 0x04: "long_press",
30 0x05: "long_double_press",
31 0x06: "long_triple_press",
32 0x80: "hold_press",
33 }
34
35 DIMMER_EVENTS: dict[int, str | None] = {
36 0x00: None,
37 0x01: "rotate_left",
38 0x02: "rotate_right",
39 }
40
41 COMMAND_EVENTS: dict[int, str | None] = {
42 0x00: "off",
43 0x01: "on",
44 0x02: "toggle",
45 0x03: "step_up",
46 0x04: "step_down",
47 }