TapoSharp 1.0.1
There is a newer version of this package available.
See the version list below for details.
See the version list below for details.
dotnet add package TapoSharp --version 1.0.1
NuGet\Install-Package TapoSharp -Version 1.0.1
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="TapoSharp" Version="1.0.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add TapoSharp --version 1.0.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: TapoSharp, 1.0.1"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install TapoSharp as a Cake Addin #addin nuget:?package=TapoSharp&version=1.0.1 // Install TapoSharp as a Cake Tool #tool nuget:?package=TapoSharp&version=1.0.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
TapoSharp
TapoSharp is a .NET implementation of the Tapo Smart Plug API. It is written in .NET 6
Getting Started
Scanning for devices
var scanRange = "192.168.1.0/24"; // CIDR notation. /32 for single IP, /24 for 254 IPs
var clients = TapoClient.ScanForDevices(scanRange);
Console.WriteLine($"Found '{clients.Count}' devices in the range: '{scanRange}'");
Attaching an event handler
var _username = "{ENTER_TAPO_ACCOUNT_EMAIL_HERE}";
var _password = "{ENTER_TAPO_ACCOUNT_PASSWORD_HERE}";
TapoClient.OnDeviceDiscovered += (s, e) =>
{
// Attempt to login
var client = new P100Client(e.IpAddress);
if (client.Login(_username, _password))
{
var info = client.GetDeviceInfo();
Console.WriteLine(info.Print());
}
};
var scanRange = "192.168.1.0/24"; // CIDR notation. /32 for single IP, /24 for 254 IPs
var clients = TapoClient.ScanForDevices(scanRange);
Getting device information
var _username = "{ENTER_TAPO_ACCOUNT_EMAIL_HERE}";
var _password = "{ENTER_TAPO_ACCOUNT_PASSWORD_HERE}";
var device = IPAddress.Parse("192.168.1.10");
Console.WriteLine($"Connecting to device: '{device.ToString()}'");
var client = new TapoClient(device);
Console.WriteLine($"Logging into device: '{device.ToString()}'");
if (client.Login(_username, _password))
{
var info = client.GetDeviceInfo();
Console.WriteLine(info.Print());
}
Setting device state (On/Off)
var _username = "{ENTER_TAPO_ACCOUNT_EMAIL_HERE}";
var _password = "{ENTER_TAPO_ACCOUNT_PASSWORD_HERE}";
var device = IPAddress.Parse("192.168.1.10");
Console.WriteLine($"Connecting to device: '{device.ToString()}'");
var client = new P100Client(device);
Console.WriteLine($"Logging into device: '{device.ToString()}'");
if (client.Login(_username, _password))
{
Console.WriteLine($"Turning device ON: '{device.ToString()}'");
client.ChangeState(PowerState.ON);
Console.WriteLine($"Turning device OFF: '{device.ToString()}'");
stateResponse = client.ChangeState(PowerState.OFF);
}
Getting device power consumption (P110 Only)
var _username = "{ENTER_TAPO_ACCOUNT_EMAIL_HERE}";
var _password = "{ENTER_TAPO_ACCOUNT_PASSWORD_HERE}";
var device = IPAddress.Parse("192.168.1.10");
Console.WriteLine($"Connecting to device: '{device.ToString()}'");
var client = new P110Client(device);
Console.WriteLine($"Logging into device: '{device.ToString()}'");
if (client.Login(_username, _password))
{
Console.WriteLine($"Getting energy usage for: '{device.ToString()}'");
var usage = client.GetEnergyUsage();
Console.WriteLine($"Current power consumption: '{usage.CurrentPower_W.ToString("0.00")}W'");
}
Authors
Version History
- 1.0.1
- Added a merged login and handshake request
- Reworked the raised event args for OnDeviceDiscovered
- Added default constructors to the clients
- 1.0.0
- Initial Release
License
This project is licensed under the GNU GPLv3 License - see the LICENSE.md file for details
Acknowledgments
Thanks to the guys over on the Home Assistant community forum for their great work reverse engineering the device. Without them this API would not exist.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net6.0
- BouncyCastle.NetCore (>= 1.8.10)
- IPNetwork2 (>= 2.5.402)
- Portable.BouncyCastle (>= 1.9.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.