Getting started
KasaTapoClient is for local device communication only. It does not implement TP-Link cloud control or remote cloud APIs.
Build the solution
# restore
dotnet restore KasaClient.slnx
# build
dotnet build KasaClient.slnx --configuration Release
Projects
KasaClient- the main libraryKasaClient.Console- the console clientKasaClient.Tests- MSTest coverage
Basic flow
- Discover or resolve a device configuration.
- Connect to the device.
- Refresh device state.
- Invoke control or inspection operations.
Discover devices with the library
using KasaTapoClient;
IReadOnlyList<DiscoveryResult> discoveredDevices = await Discover.DiscoverDevicesAsync().ConfigureAwait(false);
foreach (DiscoveryResult result in discoveredDevices)
{
Console.WriteLine($"{result.Host} -> {result.Model}");
}
DiscoveryResult firstDevice = discoveredDevices[0];
using KasaDevice device = await Discover.ConnectAsync(firstDevice.Configuration).ConfigureAwait(false);
await device.UpdateAsync().ConfigureAwait(false);
Discovery is the easiest first step when you want to inspect what supported devices are visible on the local network before deciding which one to control.
Connect to a known device
using KasaTapoClient;
DeviceConfiguration configuration = await Discover.ResolveConfigurationAsync(
new DeviceConfiguration("device-host-or-ip")).ConfigureAwait(false);
using KasaDevice device = await Discover.ConnectAsync(configuration).ConfigureAwait(false);
await device.TurnLightOnAsync().ConfigureAwait(false);
await device.UpdateAsync().ConfigureAwait(false);
Use the direct configuration path when you already know the target device and want a deterministic connection flow for applications or automation.