Support smart child modules queries (#967)

Required for the P300 firmware update with `auto_off` module on child
devices. Will query child modules for parent devices that are not hubs.

Coverage will be fixed when the P300 fixture is added
https://github.com/python-kasa/python-kasa/pull/915
This commit is contained in:
Steven B
2024-06-10 15:47:00 +01:00
committed by GitHub
parent 927fe648ac
commit db6276d3fd
6 changed files with 64 additions and 17 deletions

View File

@@ -3,6 +3,7 @@
from __future__ import annotations
import logging
from typing import Any
from ..device_type import DeviceType
from ..deviceconfig import DeviceConfig
@@ -34,7 +35,17 @@ class SmartChildDevice(SmartDevice):
self.protocol = _ChildProtocolWrapper(self._id, parent.protocol)
async def update(self, update_children: bool = True):
"""Noop update. The parent updates our internals."""
"""Update child module info.
The parent updates our internal info so just update modules with
their own queries.
"""
req: dict[str, Any] = {}
for module in self.modules.values():
if mod_query := module.query():
req.update(mod_query)
if req:
self._last_update = await self.protocol.query(req)
@classmethod
async def create(cls, parent: SmartDevice, child_info, child_components):