mirror of
https://github.com/python-kasa/python-kasa.git
synced 2025-04-27 17:16:24 +00:00
Guard emeter accesses to avoid keyerrors (#304)
Raise an exception to inform the caller that update() is needed
This commit is contained in:
parent
9ea83388ac
commit
700f3859c2
@ -219,6 +219,8 @@ class SmartDevice:
|
|||||||
"""Raise an exception if there is no emeter."""
|
"""Raise an exception if there is no emeter."""
|
||||||
if not self.has_emeter:
|
if not self.has_emeter:
|
||||||
raise SmartDeviceException("Device has no emeter")
|
raise SmartDeviceException("Device has no emeter")
|
||||||
|
if self.emeter_type not in self._last_update:
|
||||||
|
raise SmartDeviceException("update() required prior accessing emeter")
|
||||||
|
|
||||||
async def _query_helper(
|
async def _query_helper(
|
||||||
self, target: str, cmd: str, arg: Optional[Dict] = None, child_ids=None
|
self, target: str, cmd: str, arg: Optional[Dict] = None, child_ids=None
|
||||||
|
Loading…
x
Reference in New Issue
Block a user