From a9c1d08d66061e1f5a8977de75df9c2b7c18a5e8 Mon Sep 17 00:00:00 2001 From: Teemu Rytilahti Date: Thu, 14 Sep 2017 20:47:41 +0200 Subject: [PATCH] deprecate features and identify, use state_information in __repr__ instead of identify --- pyHS100/smartdevice.py | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/pyHS100/smartdevice.py b/pyHS100/smartdevice.py index 753d8ffb..9fd69d78 100644 --- a/pyHS100/smartdevice.py +++ b/pyHS100/smartdevice.py @@ -16,6 +16,7 @@ http://www.apache.org/licenses/LICENSE-2.0 import datetime import logging import socket +import warnings from collections import defaultdict from .types import SmartDeviceException @@ -86,6 +87,13 @@ class SmartDevice(object): :return: list of features :rtype: list """ + warnings.simplefilter('always', DeprecationWarning) + warnings.warn( + "features works only on plugs and its use is discouraged, " + "and it will likely to be removed at some point", + DeprecationWarning + ) + warnings.simplefilter('default', DeprecationWarning) if "feature" not in self.sys_info: return None @@ -135,6 +143,12 @@ class SmartDevice(object): :return: (alias, model, list of supported features) :rtype: tuple """ + warnings.simplefilter('always', DeprecationWarning) + warnings.warn( + "please use alias and model properties directly instead of idenfity()", + DeprecationWarning + ) + warnings.simplefilter('default', DeprecationWarning) info = self.sys_info @@ -483,5 +497,8 @@ class SmartDevice(object): raise NotImplementedError("Device subclass needs to implement this.") def __repr__(self): - return "<%s at %s: %s>" % (self.__class__.__name__, - self.ip_address, self.identify()) + return "<%s at %s (%s), is_on: %s - dev specific: %s>" % (self.__class__.__name__, + self.ip_address, + self.alias, + self.is_on, + self.state_information)