|
2 | 2 |
|
3 | 3 | from __future__ import annotations |
4 | 4 |
|
| 5 | +from typing import Any |
5 | 6 |
|
6 | | -def process_worelay_switch_1pm( |
| 7 | + |
| 8 | +def process_relay_switch_common_data( |
7 | 9 | data: bytes | None, mfr_data: bytes | None |
8 | | -) -> dict[str, bool | int]: |
9 | | - """Process WoStrip services data.""" |
| 10 | +) -> dict[str, Any]: |
| 11 | + """Process relay switch 1 and 1PM common data.""" |
10 | 12 | if mfr_data is None: |
11 | 13 | return {} |
12 | 14 | return { |
13 | 15 | "switchMode": True, # for compatibility, useless |
14 | 16 | "sequence_number": mfr_data[6], |
15 | 17 | "isOn": bool(mfr_data[7] & 0b10000000), |
16 | | - "power": ((mfr_data[10] << 8) + mfr_data[11]) / 10, |
17 | | - "voltage": 0, |
18 | | - "current": 0, |
19 | 18 | } |
20 | 19 |
|
21 | 20 |
|
22 | | -def process_worelay_switch_1( |
| 21 | +def process_garage_door_opener( |
| 22 | + data: bytes | None, mfr_data: bytes | None |
| 23 | +) -> dict[str, Any]: |
| 24 | + """Process garage door opener services data.""" |
| 25 | + if mfr_data is None: |
| 26 | + return {} |
| 27 | + common_data = process_relay_switch_common_data(data, mfr_data) |
| 28 | + common_data["door_open"] = not bool(mfr_data[7] & 0b00100000) |
| 29 | + return common_data |
| 30 | + |
| 31 | + |
| 32 | +def process_relay_switch_2pm( |
23 | 33 | data: bytes | None, mfr_data: bytes | None |
24 | | -) -> dict[str, bool | int]: |
25 | | - """Process WoStrip services data.""" |
| 34 | +) -> dict[int, dict[str, Any]]: |
| 35 | + """Process Relay Switch 2PM services data.""" |
26 | 36 | if mfr_data is None: |
27 | 37 | return {} |
| 38 | + |
28 | 39 | return { |
29 | | - "switchMode": True, # for compatibility, useless |
30 | | - "sequence_number": mfr_data[6], |
31 | | - "isOn": bool(mfr_data[7] & 0b10000000), |
| 40 | + 1: { |
| 41 | + **process_relay_switch_common_data(data, mfr_data), |
| 42 | + }, |
| 43 | + 2: { |
| 44 | + "switchMode": True, # for compatibility, useless |
| 45 | + "sequence_number": mfr_data[6], |
| 46 | + "isOn": bool(mfr_data[7] & 0b01000000), |
| 47 | + }, |
32 | 48 | } |
0 commit comments