move has_emeter implementation from SmartDevice to SmartPlug, avoid using features() internally (#93)

* move has_emeter implementation from SmartDevice to SmartPlug, avoid using features() internally

* add stacklevel to deprecation warnings to see where they are really called

* make tests pass on a real device. if PLUG_IP is not None, the tests will be run on a device at the defined IP address
This commit is contained in:
Teemu R
2017-10-07 17:36:49 +02:00
committed by GitHub
parent af90a36153
commit d22eceefae
3 changed files with 43 additions and 17 deletions

View File

@@ -99,7 +99,8 @@ class SmartDevice(object):
warnings.warn(
"features works only on plugs and its use is discouraged, "
"and it will likely to be removed at some point",
DeprecationWarning
DeprecationWarning,
stacklevel=2
)
warnings.simplefilter('default', DeprecationWarning)
if "feature" not in self.sys_info:
@@ -117,12 +118,13 @@ class SmartDevice(object):
@property
def has_emeter(self) -> bool:
"""
Checks feature list for energey meter support.
Checks feature list for energy meter support.
Note: this has to be implemented on a device specific class.
:return: True if energey meter is available
False if energymeter is missing
"""
return SmartDevice.FEATURE_ENERGY_METER in self.features
raise NotImplementedError()
@property
def sys_info(self) -> Dict[str, Any]:
@@ -154,7 +156,8 @@ class SmartDevice(object):
warnings.simplefilter('always', DeprecationWarning)
warnings.warn(
"use alias and model instead of idenfity()",
DeprecationWarning
DeprecationWarning,
stacklevel=2
)
warnings.simplefilter('default', DeprecationWarning)