mirror of
https://github.com/python-kasa/python-kasa.git
synced 2025-12-02 06:08:17 +00:00
Migrate RuleModule to mashumaro (#1283)
Also fixes a bug whereby multiple queries for the same module would overwrite each other.
This commit is contained in:
@@ -412,7 +412,15 @@ class IotDevice(Device):
|
||||
# every other update will query for them
|
||||
update: dict = self._last_update.copy() if self._last_update else {}
|
||||
for response in responses:
|
||||
update = {**update, **response}
|
||||
for k, v in response.items():
|
||||
# The same module could have results in different responses
|
||||
# i.e. smartlife.iot.common.schedule for Usage and
|
||||
# Schedule, so need to call update(**v) here. If a module is
|
||||
# not supported the response
|
||||
# {'err_code': -1, 'err_msg': 'module not support'}
|
||||
# become top level key/values of the response so check for dict
|
||||
if isinstance(v, dict):
|
||||
update.setdefault(k, {}).update(**v)
|
||||
self._last_update = update
|
||||
|
||||
# IOT modules are added as default but could be unsupported post first update
|
||||
|
||||
Reference in New Issue
Block a user