YeelightAPI 1.0.5

There is a newer version of this package available.
See the version list below for details.
dotnet add package YeelightAPI --version 1.0.5
NuGet\Install-Package YeelightAPI -Version 1.0.5
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="YeelightAPI" Version="1.0.5" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add YeelightAPI --version 1.0.5
#r "nuget: YeelightAPI, 1.0.5"
#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 YeelightAPI as a Cake Addin
#addin nuget:?package=YeelightAPI&version=1.0.5

// Install YeelightAPI as a Cake Tool
#tool nuget:?package=YeelightAPI&version=1.0.5

YeelightAPI

C# API to control Xiaomi Yeelight Color Bulbs

Prerequisites

The console project uses C# 7.1 "Async Main Method" Feature, make sure your visual studio version is up to date !

Usage

The YeelightAPI.DeviceManager allows you to connect to a bulb. Just instanciate the manager : DeviceManager manager = new DeviceManager(); and initiate connection to your bulb IP adress : manager.Connect("XXX.XXX.XXX.XXX");. Then you can use the manager to control the bulb :

  • Power on / off : manager.SetPower(true);
  • Toggle State : manager.Toggle();
  • Change brightness level : manager.SetBrightness(100);
  • Change color : manager.SetRGBColor(80, 244, 255);

Some methods use an optional parameter named "smooth", it refers to the duration in milliseconds of the effect you want to apply. For a progressive brightness change, use manager.SetBrightness(100, 3000);.

If you need a method that is not implemented, you can use the folowing methods :

  • ExecuteCommandWithResponse(METHODS method, int id = 0, List<object> parameters = null) (with response)
  • ExecuteCommand(METHODS method, int id = 0, List<object> parameters = null) (without response).

These methods are generic and use the METHODS enumeration and a list of parameters, which allows you to call any known method with any parameter.

Event

When you call a method that changes the state of the bulb, it sends a notification to inform that its state really change. You can receive these notification using the "NotificationReceived" Example :

   manager.NotificationReceived += (object sender, NotificationReceivedEventArgs arg) =>
   {
       Console.WriteLine("Notification received !! value : " + JsonConvert.SerializeObject(arg.Result));
   };

VNext

  • turn into a nuget package
  • handle dns host name for bulb discovery
  • add device discovery method in the DeviceManager
  • add more native methods in the DeviceManager
  • correct bugs if needed

Help

If there is a functionality that you need which is not implemented, or even worse if there is a bug, you can create a pull request.

Licence

Apache Licence

Source

This code is an implementation of the "Yeelight WiFi Light Inter-Operation Specification" as defined on January 1st, 2018

Product Compatible and additional computed target framework versions.
.NET Framework net45 is compatible.  net451 was computed.  net452 was computed.  net46 was computed.  net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories (2)

Showing the top 2 popular GitHub repositories that depend on YeelightAPI:

Repository Stars
RonSijm/ButtFish
Effortlessly transmitting Morse Code of chess moves to your butthole 💝
isaacrlevin/presencelight
PresenceLight is a solution to broadcast your various statuses to light bulbs.
Version Downloads Last updated
1.11.0-beta-CI-20221212-082524 168 12/12/2022
1.10.2 11,986 3/21/2021
1.10.1 1,399 2/8/2021
1.10.0 2,428 12/28/2020
1.9.0 3,803 8/11/2020
1.8.0 1,117 7/1/2020
1.7.0 1,378 12/15/2019
1.6.0 499 12/7/2019
1.5.2 640 10/14/2019
1.5.1 507 10/10/2019
1.5.0 2,456 8/25/2018
1.4.1 809 8/7/2018
1.4.0 1,028 7/13/2018
1.3.3 1,005 4/29/2018
1.3.2 827 4/3/2018
1.3.1 931 3/22/2018
1.3.0 918 3/5/2018
1.2.3 909 2/25/2018
1.2.2 929 2/22/2018
1.2.1 1,013 2/15/2018
1.2.0 944 2/15/2018
1.1.5 959 2/9/2018
1.1.4 911 2/7/2018
1.1.3 896 2/4/2018
1.1.2 840 1/28/2018
1.1.1 822 1/28/2018
1.1.0 921 1/27/2018
1.0.6 956 1/7/2018
1.0.5 1,052 1/7/2018
1.0.4 1,006 1/6/2018
1.0.2 977 1/3/2018
1.0.1 940 1/3/2018
1.0.0 953 1/3/2018

Renaming workspace