Skip to content

Commit 4c8a705

Browse files
committed
Add support for detecting the hardware type
1 parent cb0bbf4 commit 4c8a705

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

dingz/constants.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,5 +43,10 @@
4343

4444
# Communication constants
4545
CONTENT_TYPE_JSON = "application/json"
46-
CONTENT_TYPE = 'Content-Type'
46+
CONTENT_TYPE = "Content-Type"
4747
CONTENT_TYPE_TEXT_PLAIN = "text/plain"
48+
49+
DEVICE_MAPPING = {
50+
"102": "myStrom Bulb",
51+
"108": "dingz",
52+
}

dingz/discovery.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
import logging
44
from typing import Optional, List
55

6+
from .constants import DEVICE_MAPPING
7+
68
_LOGGER = logging.getLogger(__name__)
79

810

@@ -25,6 +27,10 @@ def create_from_announce_msg(raw_addr, announce_msg):
2527

2628
device = DiscoveredDevice(host=raw_addr[0], mac=announce_msg[0:6].hex(":"))
2729
device.type = announce_msg[6]
30+
try:
31+
device.hardware = DEVICE_MAPPING[str(announce_msg[6])]
32+
except KeyError:
33+
device.hardware = "unknown"
2834
status = announce_msg[7]
2935

3036
# Parse status field

0 commit comments

Comments
 (0)