Skip to content

Commit

Permalink
Abstract device model exteded by model name (identifier).
Browse files Browse the repository at this point in the history
  • Loading branch information
syssi committed Sep 6, 2017
1 parent b374872 commit 75a1899
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions 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
from typing import Any, List, Optional

from .protocol import Message

Expand All @@ -25,13 +25,19 @@ def __repr__(self):
self.data["token"])

@property
def netif(self):
def netif(self) -> str:
return self.data["netif"]

@property
def ap(self):
def ap(self) -> str:
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 Expand Up @@ -184,6 +190,9 @@ def raw_command(self, cmd, params):
def info(self):
return DeviceInfo(self.send("miIO.info", []))

def model(self):
return self.info().model

@property
def _id(self) -> int:
"""Returns running id."""
Expand Down

0 comments on commit 75a1899

Please sign in to comment.