Move has_emeter to device level for multiple plug outlets (#41)

This commit is contained in:
Andrew May 2020-04-12 07:00:15 -07:00 committed by GitHub
parent c90465c5dd
commit b6c3a7c54b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 26 deletions

View File

@ -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.

View File

@ -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:

View File

@ -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: