change functions that use query to await

This commit is contained in:
Bas Nijholt
2019-11-11 16:56:39 +01:00
parent 8f59d74e29
commit 0e0ab1dfc9
2 changed files with 4 additions and 4 deletions

View File

@@ -150,7 +150,7 @@ class SmartDevice:
self.cache[target][cmd] = response.copy()
self.cache[target][cmd]["last_updated"] = datetime.utcnow()
def _query_helper(self, target: str, cmd: str, arg: Optional[Dict] = None) -> Any:
async def _query_helper(self, target: str, cmd: str, arg: Optional[Dict] = None) -> Any:
"""Handle result unwrapping and error handling.
:param target: Target system {system, time, emeter, ..}
@@ -169,7 +169,7 @@ class SmartDevice:
response = self._result_from_cache(target, cmd)
if response is None:
_LOGGER.debug("Got no result from cache, querying the device.")
response = self.protocol.query(host=self.host, request=request)
response = await self.protocol.query(host=self.host, request=request)
self._insert_to_cache(target, cmd, response)
except Exception as ex:
raise SmartDeviceException(