Skip to content

Commit 3cd4b30

Browse files
syssirytilahti
authored andcommitted
Abstract device model exteded by model name (identifier) (#64)
* Abstract device model exteded by model name (identifier). * DeviceInfo example added. Typing flaw fixed.
1 parent 8d9e30c commit 3cd4b30

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

mirobo/device.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,26 @@ class DeviceException(Exception):
1616
class DeviceInfo:
1717
"""Presentation of miIO device information."""
1818
def __init__(self, data):
19+
"""
20+
Response of a Xiaomi Smart WiFi Plug
21+
22+
{'ap': {'bssid': 'FF:FF:FF:FF:FF:FF', 'rssi': -68, 'ssid': 'network'},
23+
'cfg_time': 0,
24+
'fw_ver': '1.2.4_16',
25+
'hw_ver': 'MW300',
26+
'life': 24,
27+
'mac': '28:FF:FF:FF:FF:FF',
28+
'mmfree': 30312,
29+
'model': 'chuangmi.plug.m1',
30+
'netif': {'gw': '192.168.xxx.x',
31+
'localIp': '192.168.xxx.x',
32+
'mask': '255.255.255.0'},
33+
'ot': 'otu',
34+
'ott_stat': [0, 0, 0, 0],
35+
'otu_stat': [320, 267, 3, 0, 3, 742],
36+
'token': '2b00042f7481c7b056c4b410d28f33cf',
37+
'wifi_fw_ver': 'SD878x-14.76.36.p84-702.1.0-WM'}
38+
"""
1939
self.data = data
2040

2141
def __repr__(self):
@@ -36,6 +56,12 @@ def accesspoint(self):
3656
"""Return information about connected wlan accesspoint."""
3757
return self.data["ap"]
3858

59+
@property
60+
def model(self) -> Optional[str]:
61+
if self.data["model"] is not None:
62+
return self.data["model"]
63+
return None
64+
3965
@property
4066
def raw(self):
4167
"""Return raw data returned by the device."""

0 commit comments

Comments
 (0)