Library for controlling Xiaomi Yeelight Smart LED Bulb.
Install the NuGet package into your application.
Install-Package Yeelight
dotnet add package Yeelight
All functions take an IPAddress
for the target light.
let address = IPAddress.Parse "192.168.0.x"
Many functions take an Effect
that determines the behaviour of an operation.
type Effect =
// Instantaneous with no delay
| Sudden
// Gradual with the specified duration in milliseconds
| Smooth of uint32
All functions return a Response
with the value Ok
for a successful request, or an Error
that contains a message.
type Response = Ok | Error of string
type Power = Off | On
// Set power
address |> Yeelight.setPower Yeelight.Off Yeelight.Sudden
address |> Yeelight.setPower Yeelight.On Yeelight.Sudden
// Switch off and on
address |> Yeelight.off Yeelight.Sudden
address |> Yeelight.on Yeelight.Sudden
// Toggle off and on
address |> Yeelight.toggle
// Percentage: 1 - 100
type Brightness = int
// Set brightness to 50%
address |> Yeelight.setBrightness 50 Yeelight.Sudden
// Kelvin: 1700 - 6500
type Temperature = int
// Set temperature to 3500 K
address |> Yeelight.setTemperature 3500 Yeelight.Sudden
Color can be set using either RGB or HSV.
// 0 - 255
type Red = int
type Green = int
type Blue = int
// 0 - 359
type Hue = int
// 0 - 100
type Saturation = int
type Color =
// Triple of red, green, blue
| Rgb of Red * Green * Blue
// Tuple of hue, saturation
| Hsv of Hue * Saturation
// Set color to red = 255, green = 0, blue = 127
address |> Yeelight.setColor (Yeelight.Rgb (255, 0, 127)) Yeelight.Sudden
// Set color to hue = 180, saturation = 50
address |> Yeelight.setColor (Yeelight.Hsv (180, 50)) Yeelight.Sudden
type Name = string
// Set name to "Bedroom"
address |> Yeelight.setName "Bedroom"
Note: When using the Yeelight official app, the device name is stored in the cloud. This method instead stores the name in device's persistent memory, so the two names may differ.