mirror of
https://github.com/python-kasa/python-kasa.git
synced 2024-12-22 19:23:34 +00:00
Add 'internal_state' to return the results from the last update query (#306)
This can be useful for debugging purposes, e.g., for homeassistant diagnostics
This commit is contained in:
parent
700f3859c2
commit
b61c0feea9
@ -721,6 +721,15 @@ class SmartDevice:
|
||||
"""Return True if the device supports color changes."""
|
||||
return False
|
||||
|
||||
@property
|
||||
def internal_state(self) -> Any:
|
||||
"""Return the internal state of the instance.
|
||||
|
||||
The returned object contains the raw results from the last update call.
|
||||
This should only be used for debugging purposes.
|
||||
"""
|
||||
return self._last_update
|
||||
|
||||
def __repr__(self):
|
||||
if self._last_update is None:
|
||||
return f"<{self._device_type} at {self.host} - update() needed>"
|
||||
|
@ -134,3 +134,8 @@ async def test_childrens(dev):
|
||||
assert len(dev.children) > 0
|
||||
else:
|
||||
assert len(dev.children) == 0
|
||||
|
||||
|
||||
async def test_internal_state(dev):
|
||||
"""Make sure the internal state returns the last update results."""
|
||||
assert dev.internal_state == dev._last_update
|
||||
|
Loading…
Reference in New Issue
Block a user