mirror of
https://github.com/python-kasa/python-kasa.git
synced 2025-10-14 19:38:02 +00:00
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:
@@ -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)
|
||||
|
||||
|
Reference in New Issue
Block a user