Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Abstract device model exteded by model name (identifier) #64

Merged
merged 2 commits into from
Sep 6, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
28 changes: 27 additions & 1 deletion mirobo/device.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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):
Expand All @@ -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
Expand Down