From 75a1899048ccda96227b5a7f4bd4c1a1f0dc8c9e Mon Sep 17 00:00:00 2001 From: Sebastian Muszynski Date: Wed, 6 Sep 2017 08:20:47 +0200 Subject: [PATCH] Abstract device model exteded by model name (identifier). --- mirobo/device.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/mirobo/device.py b/mirobo/device.py index 8eac3fd1d..8ab2b7a76 100644 --- a/mirobo/device.py +++ b/mirobo/device.py @@ -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 @@ -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 @@ -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."""