Fix post update hook for iot child devices (#1011)

`_post_update_hook` not being called on child `iot` devices, causing
missing emeter features for children
This commit is contained in:
Steven B 2024-06-25 18:58:07 +01:00 committed by GitHub
parent 0f5bafaa43
commit 07fa0d7a7b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 18 additions and 2 deletions

View File

@ -361,6 +361,9 @@ class IotStripPlug(IotPlug):
Needed for properties that are decorated with `requires_update`.
"""
await self._modular_update({})
for module in self._modules.values():
module._post_update_hook()
if not self._features:
await self._initialize_features()

View File

@ -2,10 +2,10 @@ from datetime import datetime
import pytest
from kasa import KasaException
from kasa import Device, KasaException, Module
from kasa.iot import IotStrip
from .conftest import handle_turn_on, strip, turn_on
from .conftest import handle_turn_on, strip, strip_iot, turn_on
@strip
@ -147,3 +147,16 @@ def test_children_api(dev):
first = dev.children[0]
first_by_get_child_device = dev.get_child_device(first.device_id)
assert first == first_by_get_child_device
@strip_iot
async def test_children_energy(dev: Device):
if Module.Energy not in dev.modules:
pytest.skip(f"skipping device {dev.model} does not support energy")
for plug in dev.children:
# For now all known strips with energy support these
energy = plug.modules[Module.Energy]
assert "voltage" in energy._module_features
assert "current" in energy._module_features
assert "current_consumption" in energy._module_features