Git Product home page Git Product logo

tapoconnect's Introduction

TapoConnect

Unofficial TP-Link Tapo smart device library for C#.

Updates

  • Ported to dotnet 8.0
  • Linux friendly

Build clients to interact with Tapo Cloud or smart device.

TapoCloudClient cloudClient = new TapoCloudClient();
TapoDeviceClient deviceClient = new TapoDeviceClient();

//Specify order of login protocols to try.
TapoDeviceClient deviceClient = new TapoDeviceClient(new List<ITapoDeviceClient>
{
	new KlapDeviceClient(),
	new SecurePassthroughDeviceClient(),
});

Get devices from cloud.

CloudLoginResult cloudKey = await cloudClient.LoginAsync("<Username>", "<Password>");
CloudListDeviceResult deviceResult = await cloudClient.ListDevicesAsync(cloudKey.Token);

Select devices by type.

IEnumerable<TapoDeviceDto> devices = deviceResult.DeviceList
    .Where(x => x.DeviceType == TapoUtils.TapoBulbDeviceType);

Select device by alias.

TapoDeviceDto device = deviceResult.DeviceList.First(x => x.Alias == "<Device Name>")

Login to device by known IP address.

TapoDeviceKey deviceKey = await deviceClient.LoginByIpAsync("<Username>", "<Password>", "<IpAddress>");

Login to device by known MAC address (finds the MAC address on local network through a Windows ARP request).

string ip = TapoUtils.GetIpAddressByMacAddress(device.DeviceMac);
TapoDeviceKey deviceKey = await deviceClient.LoginByIpAsync("<Username>", "<Password>", ip);

Get Device info.

DeviceGetInfoResult deviceInfo = await deviceClient.GetDeviceInfoAsync(deviceKey);

Set Device's power, brightness, color, and state.

await deviceClient.SetPowerAsync(deviceKey, true);

await deviceClient.SetBrightnessAsync(deviceKey, 80);

await deviceClient.SetColorAsync(deviceKey, TapoColor.FromHex("#e8d974"));
await deviceClient.SetColorAsync(deviceKey, TapoColor.FromHsl(200, 100, 100));
await deviceClient.SetColorAsync(deviceKey, TapoColor.FromRgb(100, 25, 32));
await deviceClient.SetColorAsync(deviceKey, TapoColor.FromTemperature(3500));

await deviceClient.SetStateAsync(deviceKey, new TapoSetBulbState(
    color: TapoColor.FromTemperature(3800, brightness: 1),
    deviceOn: true));

Disclaimer

This is an unofficial SDK that has no affiliation with TP-Link. TP-Link and all respective product names are copyright TP-Link Technologies Co, Ltd. and/or its subsidiaries and affiliates.

Credits

Credit to this API go to:

Many thanks to cwakefie27 for this fork.

tapoconnect's People

Contributors

andervanse avatar cwakefie27 avatar t1mmos avatar lcervo avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.