mirror of
https://github.com/python-kasa/python-kasa.git
synced 2024-12-22 19:23:34 +00:00
Move has_emeter to device level for multiple plug outlets (#41)
This commit is contained in:
parent
c90465c5dd
commit
b6c3a7c54b
@ -155,13 +155,17 @@ class SmartDevice:
|
||||
|
||||
return result
|
||||
|
||||
@property # type: ignore
|
||||
@requires_update
|
||||
def has_emeter(self) -> bool:
|
||||
"""Return if device has an energy meter.
|
||||
"""Return whether device has an energy meter.
|
||||
|
||||
:return: True if energey meter is available
|
||||
False if energymeter is missing
|
||||
:return: True if energy meter is available
|
||||
False otherwise
|
||||
"""
|
||||
raise NotImplementedError()
|
||||
sys_info = self.sys_info
|
||||
features = sys_info["feature"].split(":")
|
||||
return "ENE" in features
|
||||
|
||||
async def get_sys_info(self) -> Dict[str, Any]:
|
||||
"""Retrieve system information.
|
||||
|
@ -92,18 +92,6 @@ class SmartPlug(SmartDevice):
|
||||
sys_info = self.sys_info
|
||||
return "brightness" in sys_info
|
||||
|
||||
@property # type: ignore
|
||||
@requires_update
|
||||
def has_emeter(self):
|
||||
"""Return whether device has an energy meter.
|
||||
|
||||
:return: True if energy meter is available
|
||||
False otherwise
|
||||
"""
|
||||
sys_info = self.sys_info
|
||||
features = sys_info["feature"].split(":")
|
||||
return "ENE" in features
|
||||
|
||||
@property # type: ignore
|
||||
@requires_update
|
||||
def is_on(self) -> bool:
|
||||
|
@ -45,10 +45,6 @@ class SmartStrip(SmartDevice):
|
||||
and should be handled by the user of the library.
|
||||
"""
|
||||
|
||||
def has_emeter(self) -> bool:
|
||||
"""Return True as strips has always an emeter."""
|
||||
return True
|
||||
|
||||
def __init__(self, host: str, *, cache_ttl: int = 3) -> None:
|
||||
super().__init__(host=host)
|
||||
self.emeter_type = "emeter"
|
||||
@ -281,12 +277,6 @@ class SmartStripPlug(SmartPlug):
|
||||
"""
|
||||
return f"{self.mac}_{self.child_id}"
|
||||
|
||||
@property # type: ignore
|
||||
@requires_update
|
||||
def has_emeter(self):
|
||||
"""Single sockets have always an emeter."""
|
||||
return True
|
||||
|
||||
@property # type: ignore
|
||||
@requires_update
|
||||
def alias(self) -> str:
|
||||
|
Loading…
Reference in New Issue
Block a user