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:
Steven B.
2024-11-20 14:59:32 +00:00
committed by GitHub
parent a4258cc75b
commit f7778aaa53
4 changed files with 70 additions and 13 deletions

View File

@@ -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