Yeelight LAN protocol · .NET 10
A complete .NET client for Yeelight lights
Find Yeelight lights on your network, switch them, colour them and follow what they do, from any .NET application on Windows, Linux or macOS. Every command of the Yeelight LAN protocol is a typed, async C# member, a light's state follows the light whoever changes it, and the client stays within the limits of the lights (four connections, 60 commands a minute) by itself.
dotnet add package YeelightClient --prerelease
using Yeelight;
await using var client = new YeelightClient();
var lights = await client.DiscoverAsync(TimeSpan.FromSeconds(4));
foreach (var light in lights)
{
await light.TurnOnAsync();
await light.SetBrightnessAsync(60, TimeSpan.FromSeconds(1));
if (light.SupportsColor)
{
await light.SetRgbAsync(255, 140, 0);
}
}
Why Yeelight Client
Finds lights on real networks
A search goes out as a multicast and as a broadcast, three times, from every network of the computer. Announcements are heard too, and one address can be asked directly, across a VPN or on another subnet.
The whole protocol, typed and async
Power, brightness, colour temperature, RGB, HSV, colour flows, scenes, timers, adjustments and background lights: a method for every command of the specification, with the arguments checked before anything is sent.
A state that follows the light
A light reports every change to its connections, so its properties are what it says, whoever changes it: the app, a remote, the wall switch. INotifyPropertyChanged and events tell you when.
Music mode for streaming effects
Put a light in music mode and send it commands without the limit of 60 a minute, to follow music or a screen. The client runs the server that the light connects to.
A connection you can rely on
One connection per light that is made again when it is lost, commands that fail at once instead of hanging, a limit of 60 commands a minute that the client keeps for you, and only one of the four connections that a light takes.
Tested against a simulated light
The tests run against a simulated light on the loopback, and add property-based tests, fuzzing of what a light could send, and a chaos test that cuts, stalls and refuses the connection at random while commands run.
A quick tour
using Yeelight;
await using var client = new YeelightClient();
// Search for four seconds ...
var lights = await client.DiscoverAsync(TimeSpan.FromSeconds(4));
// ... or ask one address, which also works across a VPN or on another subnet.
var light = await client.ProbeAsync("192.168.1.50");
Compatibility
| Area | Support |
|---|---|
| Lights | Yeelight WiFi lights that follow the Yeelight WiFi Light Inter-Operation Specification, with LAN Control switched on in the Yeelight app (select the light, settings, LAN Control). What a light can do is what it lists: a mono light has no colours, and only some ceiling lights have a background light. |
| Target frameworks | net10.0, the current LTS release of .NET (supported until November 2028). An application on .NET 11 or a later version uses it too. Earlier versions of .NET are not supported. |
| Platforms | Windows, Linux and macOS: the client only uses sockets, and its tests run on all three in CI. |
| Dependencies | Microsoft.Extensions.Logging.Abstractions 10.0.0, which has the ILogger that the client logs to. |
| License | MIT |
| Affiliation | Yeelight Client is an independent open source project. It is not affiliated with or endorsed by Yeelight. |
Where next
Getting started
Switch on LAN Control, install the package, find a light and switch it.
Finding lights
Searching, listening and probing, and what to do on a VPN or another subnet.
The test app
A Windows app to try every command by hand, against your own lights or against simulated ones.
API reference
Every type and member of the library, generated from the source.