mirror of
https://github.com/python-kasa/python-kasa.git
synced 2024-12-23 03:33:35 +00:00
Raise an exception when trying to access data prior updating
This commit is contained in:
parent
3a7836cd33
commit
bb013e75da
@ -4,6 +4,8 @@ import logging
|
|||||||
from abc import ABC, abstractmethod
|
from abc import ABC, abstractmethod
|
||||||
from typing import TYPE_CHECKING
|
from typing import TYPE_CHECKING
|
||||||
|
|
||||||
|
from ..exceptions import SmartDeviceException
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
from kasa import SmartDevice
|
from kasa import SmartDevice
|
||||||
|
|
||||||
@ -44,6 +46,11 @@ class Module(ABC):
|
|||||||
@property
|
@property
|
||||||
def data(self):
|
def data(self):
|
||||||
"""Return the module specific raw data from the last update."""
|
"""Return the module specific raw data from the last update."""
|
||||||
|
if self._module not in self._device._last_update:
|
||||||
|
raise SmartDeviceException(
|
||||||
|
f"You need to call update() prior accessing module data for '{self._module}'"
|
||||||
|
)
|
||||||
|
|
||||||
return self._device._last_update[self._module]
|
return self._device._last_update[self._module]
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
Loading…
Reference in New Issue
Block a user