2024-06-19 08:53:40 +00:00
|
|
|
"""Interact with child devices.
|
|
|
|
|
|
|
|
>>> from kasa import Discover
|
|
|
|
>>>
|
|
|
|
>>> dev = await Discover.discover_single(
|
|
|
|
>>> "127.0.0.1",
|
|
|
|
>>> username="user@example.com",
|
|
|
|
>>> password="great_password"
|
|
|
|
>>> )
|
|
|
|
>>> await dev.update()
|
|
|
|
>>> print(dev.alias)
|
|
|
|
Bedroom Power Strip
|
|
|
|
|
|
|
|
All methods act on the whole strip:
|
|
|
|
|
|
|
|
>>> for plug in dev.children:
|
|
|
|
>>> print(f"{plug.alias}: {plug.is_on}")
|
|
|
|
Plug 1: True
|
|
|
|
Plug 2: False
|
|
|
|
Plug 3: False
|
|
|
|
>>> dev.is_on
|
|
|
|
True
|
|
|
|
>>> await dev.turn_off()
|
|
|
|
>>> await dev.update()
|
|
|
|
|
|
|
|
Accessing individual plugs can be done using the `children` property:
|
|
|
|
|
|
|
|
>>> len(dev.children)
|
|
|
|
3
|
|
|
|
>>> for plug in dev.children:
|
|
|
|
>>> print(f"{plug.alias}: {plug.is_on}")
|
|
|
|
Plug 1: False
|
|
|
|
Plug 2: False
|
|
|
|
Plug 3: False
|
|
|
|
>>> await dev.children[1].turn_on()
|
|
|
|
>>> await dev.update()
|
|
|
|
>>> dev.is_on
|
|
|
|
True
|
|
|
|
"""
|
2024-02-22 19:46:19 +00:00
|
|
|
|
2024-02-19 17:01:31 +00:00
|
|
|
from ..smartmodule import SmartModule
|
|
|
|
|
|
|
|
|
2024-05-11 18:28:18 +00:00
|
|
|
class ChildDevice(SmartModule):
|
2024-02-19 17:01:31 +00:00
|
|
|
"""Implementation for child devices."""
|
|
|
|
|
|
|
|
REQUIRED_COMPONENT = "child_device"
|
2024-03-15 16:18:13 +00:00
|
|
|
QUERY_GETTER_NAME = "get_child_device_list"
|