diff --git a/mirobo/device.py b/mirobo/device.py index 0eee0a520..4385dd81a 100644 --- a/mirobo/device.py +++ b/mirobo/device.py @@ -2,7 +2,7 @@ import datetime import socket import logging -from typing import Any, List # noqa: F401 +from typing import Any, List, Optional # noqa: F401 from .protocol import Message @@ -15,6 +15,26 @@ class DeviceException(Exception): class DeviceInfo: def __init__(self, data): + """ + Response of a Xiaomi Smart WiFi Plug + + {'ap': {'bssid': 'FF:FF:FF:FF:FF:FF', 'rssi': -68, 'ssid': 'network'}, + 'cfg_time': 0, + 'fw_ver': '1.2.4_16', + 'hw_ver': 'MW300', + 'life': 24, + 'mac': '28:FF:FF:FF:FF:FF', + 'mmfree': 30312, + 'model': 'chuangmi.plug.m1', + 'netif': {'gw': '192.168.xxx.x', + 'localIp': '192.168.xxx.x', + 'mask': '255.255.255.0'}, + 'ot': 'otu', + 'ott_stat': [0, 0, 0, 0], + 'otu_stat': [320, 267, 3, 0, 3, 742], + 'token': '2b00042f7481c7b056c4b410d28f33cf', + 'wifi_fw_ver': 'SD878x-14.76.36.p84-702.1.0-WM'} + """ self.data = data def __repr__(self): @@ -32,6 +52,12 @@ def netif(self): def ap(self): return self.data["ap"] + @property + def model(self) -> Optional[str]: + if self.data["model"] is not None: + return self.data["model"] + return None + @property def raw(self): return self.data