8000 Add 'internal_state' to return the results from the last update query… · allandaly/python-kasa@b61c0fe · GitHub
[go: up one dir, main page]

Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit b61c0fe

Browse files
authored
Add 'internal_state' to return the results from the last update query (python-kasa#306)
This can be useful for debugging purposes, e.g., for homeassistant diagnostics
1 parent 700f385 commit b61c0fe

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

kasa/smartdevice.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -721,6 +721,15 @@ def is_color(self) -> bool:
721721
"""Return True if the device supports color changes."""
722722
return False
723723

724+
@property
725+
def internal_state(self) -> Any:
726+
"""Return the internal state of the instance.
727+
728+
The returned object contains the raw results from the last update call.
729+
This should only be used for debugging purposes.
730+
"""
731+
return self._last_update
732+
724733
def __repr__(self):
725734
if self._last_update is None:
726735
return f"<{self._device_type} at {self.host} - update() needed>"

kasa/tests/test_smartdevice.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,3 +134,8 @@ async def test_childrens(dev):
134134
assert len(dev.children) > 0
135135
else:
136136
assert len(dev.children) == 0
137+
138+
139+
async def test_internal_state(dev):
140+
"""Make sure the internal state returns the last update results."""
141+
assert dev.internal_state == dev._last_update

0 commit comments

Comments
 (0)
0