Discovering devices

API documentation

class kasa.Discover[source]

Discover TPLink Smart Home devices.

The main entry point for this library is, which returns a dictionary of the found devices. The key is the IP address of the device and the value contains ready-to-use, SmartDevice-derived device object.

discover_single() can be used to initialize a single device given its IP address. If the type of the device and its IP address is already known, you can initialize the corresponding device class directly without this.

The protocol uses UDP broadcast datagrams on port 9999 for discovery.


Discovery returns a list of discovered devices:

>>> import asyncio
>>> found_devices =
>>> [dev.alias for dev in found_devices]
['TP-LINK_Power Strip_CF69']

Discovery can also be targeted to a specific broadcast address instead of the


It is also possible to pass a coroutine to be executed for each found device:

>>> async def print_alias(dev):
>>>    print(f"Discovered {dev.alias}")
>>> devices =
DISCOVERY_QUERY = {'system': {'get_sysinfo': None}}
DISCOVERY_QUERY_2 = b'\x02\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00F<\xb5\xd3'
async static discover(*, target='', on_discovered=None, timeout=5, discovery_packets=3, interface=None, on_unsupported=None, credentials=None) Dict[str, kasa.smartdevice.SmartDevice][source]

Discover supported devices.

Sends discovery message to in order to detect available supported devices in the local network, and waits for given timeout for answers from devices. If you have multiple interfaces, you can use target parameter to specify the network for discovery.

If given, on_discovered coroutine will get awaited with a SmartDevice-derived object as parameter.

The results of the discovery are returned as a dict of SmartDevice-derived objects keyed with IP addresses. The devices are already initialized and all but emeter-related properties can be accessed directly.

  • target – The target address where to send the broadcast discovery queries if multi-homing (e.g.

  • on_discovered – coroutine to execute on discovery

  • timeout – How long to wait for responses, defaults to 5

  • discovery_packets – Number of discovery packets to broadcast

  • interface – Bind to specific interface


dictionary with discovered devices

async static discover_single(host: str, *, port: Optional[int] = None, timeout=5, credentials: Optional[kasa.credentials.Credentials] = None) kasa.smartdevice.SmartDevice[source]

Discover a single device by the given IP address.


host – Hostname of device to query

Return type



Object for querying/controlling found device.