mirror of
https://github.com/python-kasa/python-kasa.git
synced 2025-01-09 06:17:08 +00:00
Fix every other query tries to fetch known unsupported features (#520)
* Fix every other query tries to fetch known unsupported features * ensure modules not being updated are preserved
This commit is contained in:
parent
84a501bcdc
commit
20b3f7a771
@ -336,7 +336,7 @@ class SmartDevice:
|
|||||||
|
|
||||||
request_list = []
|
request_list = []
|
||||||
est_response_size = 1024 if "system" in req else 0
|
est_response_size = 1024 if "system" in req else 0
|
||||||
for module_name, module in self.modules.items():
|
for module in self.modules.values():
|
||||||
if not module.is_supported:
|
if not module.is_supported:
|
||||||
_LOGGER.debug("Module %s not supported, skipping" % module)
|
_LOGGER.debug("Module %s not supported, skipping" % module)
|
||||||
continue
|
continue
|
||||||
@ -356,7 +356,11 @@ class SmartDevice:
|
|||||||
await self.protocol.query(request) for request in request_list if request
|
await self.protocol.query(request) for request in request_list if request
|
||||||
]
|
]
|
||||||
|
|
||||||
update: Dict = {}
|
# Preserve the last update and merge
|
||||||
|
# responses on top of it so we remember
|
||||||
|
# which modules are not supported, otherwise
|
||||||
|
# every other update will query for them
|
||||||
|
update: Dict = self._last_update.copy() if self._last_update else {}
|
||||||
for response in responses:
|
for response in responses:
|
||||||
update = {**update, **response}
|
update = {**update, **response}
|
||||||
self._last_update = update
|
self._last_update = update
|
||||||
|
@ -187,3 +187,10 @@ def test_device_class_ctors(device_class):
|
|||||||
assert dev.host == host
|
assert dev.host == host
|
||||||
assert dev.port == port
|
assert dev.port == port
|
||||||
assert dev.credentials == credentials
|
assert dev.credentials == credentials
|
||||||
|
|
||||||
|
|
||||||
|
async def test_modules_preserved(dev: SmartDevice):
|
||||||
|
"""Make modules that are not being updated are preserved between updates."""
|
||||||
|
dev._last_update["some_module_not_being_updated"] = "should_be_kept"
|
||||||
|
await dev.update()
|
||||||
|
assert dev._last_update["some_module_not_being_updated"] == "should_be_kept"
|
||||||
|
Loading…
Reference in New Issue
Block a user