prefer sync attribute over asyncio.run

This commit is contained in:
Bas Nijholt 2019-11-11 20:53:45 +01:00
parent 9907c6416b
commit 583c785611
2 changed files with 5 additions and 15 deletions

View File

@ -211,16 +211,6 @@ class SmartDevice:
""" """
raise NotImplementedError() raise NotImplementedError()
@property
def sys_info(self) -> Dict[str, Any]:
"""Return the complete system information.
:return: System information dict.
:rtype: dict
"""
return asyncio.run(self.get_sys_info())
async def get_sys_info(self) -> Dict: async def get_sys_info(self) -> Dict:
"""Retrieve system information. """Retrieve system information.
@ -601,11 +591,11 @@ class SmartDevice:
def __repr__(self): def __repr__(self):
return "<%s model %s at %s (%s), is_on: %s - dev specific: %s>" % ( return "<%s model %s at %s (%s), is_on: %s - dev specific: %s>" % (
self.__class__.__name__, self.__class__.__name__,
asyncio.run(self.get_model()), self.sync.get_model(),
self.host, self.host,
asyncio.run(self.get_alias()), self.sync.get_alias(),
asyncio.run(self.is_on()), self.sync.is_on(),
asyncio.run(self.get_state_information()), self.sync.get_state_information(),
) )

View File

@ -51,7 +51,7 @@ class SmartStrip(SmartPlug):
self._device_type = DeviceType.Strip self._device_type = DeviceType.Strip
self.plugs = {} self.plugs = {}
sys_info = asyncio.run(self.get_sys_info()) sys_info = self.sync.get_sys_info()
children = sys_info["children"] children = sys_info["children"]
self.num_children = len(children) self.num_children = len(children)
for plug in range(self.num_children): for plug in range(self.num_children):