/// <summary> /// Starts a color flow asynchronously /// </summary> /// <param name="flow"></param> /// <param name="action"></param> /// <param name="count"></param> /// <returns></returns> public async Task <bool> BackgroundStartColorFlow(ColorFlow flow) { return(await Process((Device device) => { return device.BackgroundStartColorFlow(flow); })); }
/// <summary> /// Starts a color flow asynchronously /// </summary> /// <param name="flow"></param> /// <returns></returns> public async Task <bool> StartColorFlow(ColorFlow flow) { List <object> parameters = new List <object>() { flow.RepetitionCount *flow.Count, (int)flow.EndAction, flow.GetColorFlowExpression() }; CommandResult <List <string> > result = await ExecuteCommandWithResponse <List <string> >( method : METHODS.StartColorFlow, parameters : parameters); return(result.IsOk()); }
/// <summary> /// Starts a background color flow /// </summary> /// <param name="flow"></param> /// <param name="action"></param> /// <param name="count"></param> /// <returns></returns> public async Task <bool> BackgroundStartColorFlow(ColorFlow flow) { List <object> parameters = new List <object>() { flow.RepetitionCount, (int)flow.EndAction, flow.GetColorFlowExpression() }; CommandResult result = await ExecuteCommandWithResponse( method : METHODS.StartBackgroundLightColorFlow, id : (int)METHODS.StartBackgroundLightColorFlow, parameters : parameters); return(result.IsOk()); }
// Function for setting lamp flicker private static void SetFlicker(bool enable) { if (enable) { ColorFlow flow = new ColorFlow(0, ColorFlowEndAction.Restore); flow.Add(new ColorFlowRGBExpression(lampColor[0], lampColor[1], lampColor[1], lampBrightness, 2000)); flow.Add(new ColorFlowRGBExpression(lampColor[0], lampColor[1], lampColor[2], lampBrightness - flickerAmount, 1000)); lamp.StartColorFlow(flow); lampFlicker = true; } else { lampFlicker = false; lamp.StopColorFlow(); } }
public static async Task StartLightFlow() { if (device.IsConnected) { Random rand = new Random(); ColorFlow flow = new ColorFlow(0, ColorFlowEndAction.Restore); flow.Add(new ColorFlowRGBExpression(27, 149, 211, 100, rand.Next(200, 450))); // color : red / brightness : 1% / duration : 500 flow.Add(new ColorFlowRGBExpression(206, 95, 26, 100, rand.Next(200, 450))); // color : green / brightness : 100% / duration : 500 flow.Add(new ColorFlowRGBExpression(31, 88, 162, 100, rand.Next(200, 450))); // color : blue / brightness : 50% / duration : 500 flow.Add(new ColorFlowRGBExpression(213, 122, 25, 100, rand.Next(200, 450))); flow.Add(new ColorFlowRGBExpression(104, 62, 139, 100, rand.Next(200, 450))); flow.Add(new ColorFlowRGBExpression(232, 178, 20, 100, rand.Next(200, 450))); flow.Add(new ColorFlowRGBExpression(163, 65, 141, 100, rand.Next(200, 450))); flow.Add(new ColorFlowRGBExpression(253, 236, 16, 100, rand.Next(200, 450))); flow.Add(new ColorFlowRGBExpression(200, 46, 129, 100, rand.Next(200, 450))); flow.Add(new ColorFlowRGBExpression(129, 178, 61, 100, rand.Next(200, 450))); await device.StartColorFlow(flow); // start } }
private static async Task <bool> ExecuteTests(IDeviceController device, int?smooth = null) { bool success = true, globalSuccess = true; int delay = 1500; await Try(async() => { Console.WriteLine("powering on ..."); success = await device.SetPower(true, smooth); globalSuccess &= success; WriteLineWithColor($"command success : {success}", ConsoleColor.DarkCyan); await Task.Delay(delay); }); await Try(async() => { Console.WriteLine("turn off ..."); success = await device.TurnOff(smooth); globalSuccess &= success; WriteLineWithColor($"command success : {success}", ConsoleColor.DarkCyan); await Task.Delay(delay); }); await Try(async() => { Console.WriteLine("turn on ..."); success = await device.TurnOn(smooth); globalSuccess &= success; WriteLineWithColor($"command success : {success}", ConsoleColor.DarkCyan); await Task.Delay(delay); }); await Try(async() => { Console.WriteLine("add cron ..."); success = await device.CronAdd(15, YeelightAPI.Models.Cron.CronType.PowerOff); globalSuccess &= success; WriteLineWithColor($"command success : {success}", ConsoleColor.DarkCyan); await Task.Delay(delay); }); if (device is IDeviceReader deviceReader) { await Try(async() => { Console.WriteLine("get cron ..."); CronResult cronResult = await deviceReader.CronGet(YeelightAPI.Models.Cron.CronType.PowerOff); globalSuccess &= (cronResult != null); WriteLineWithColor($"command success : {success}", ConsoleColor.DarkCyan); await Task.Delay(delay); }); string name = null; await Try(async() => { Console.WriteLine("getting current name ..."); name = (await deviceReader.GetProp(PROPERTIES.name))?.ToString(); Console.WriteLine($"current name : {name}"); }); await Task.Delay(delay); await Try(async() => { Console.WriteLine("setting name 'test' ..."); success &= await deviceReader.SetName("test"); WriteLineWithColor($"command success : {success}", ConsoleColor.DarkCyan); await Task.Delay(2000); }); await Task.Delay(delay); await Try(async() => { Console.WriteLine("restoring name '{0}' ...", name); success &= await deviceReader.SetName(name); WriteLineWithColor($"command success : {success}", ConsoleColor.DarkCyan); await Task.Delay(2000); }); await Try(async() => { Console.WriteLine("getting all props ..."); Dictionary <PROPERTIES, object> result = await deviceReader.GetAllProps(); Console.WriteLine($"\tprops : {JsonConvert.SerializeObject(result)}"); await Task.Delay(2000); }); } await Try(async() => { Console.WriteLine("delete cron ..."); success = await device.CronDelete(YeelightAPI.Models.Cron.CronType.PowerOff); globalSuccess &= success; WriteLineWithColor($"command success : {success}", ConsoleColor.DarkCyan); await Task.Delay(delay); }); if (device is IBackgroundDeviceController backgroundDevice) { await Try(async() => { Console.WriteLine("powering on ..."); success = await backgroundDevice.BackgroundSetPower(true, smooth); globalSuccess &= success; WriteLineWithColor($"command success : {success}", ConsoleColor.DarkCyan); await Task.Delay(delay); }); await Try(async() => { Console.WriteLine("turn off ..."); success = await backgroundDevice.BackgroundTurnOff(smooth); globalSuccess &= success; WriteLineWithColor($"command success : {success}", ConsoleColor.DarkCyan); await Task.Delay(delay); }); await Try(async() => { Console.WriteLine("turn on ..."); success = await backgroundDevice.BackgroundTurnOn(smooth, PowerOnMode.RGB); globalSuccess &= success; WriteLineWithColor($"command success : {success}", ConsoleColor.DarkCyan); await Task.Delay(delay); }); await Try(async() => { Console.WriteLine("Setting Brightness to One..."); success = await backgroundDevice.BackgroundSetBrightness(1, smooth); globalSuccess &= success; WriteLineWithColor($"command success : {success}", ConsoleColor.DarkCyan); await Task.Delay(delay); }); await Try(async() => { Console.WriteLine("Setting brightness increase..."); success = await backgroundDevice.BackgroundSetAdjust(YeelightAPI.Models.Adjust.AdjustAction.increase, YeelightAPI.Models.Adjust.AdjustProperty.bright); globalSuccess &= success; WriteLineWithColor($"command success : {success}", ConsoleColor.DarkCyan); await Task.Delay(delay); }); await Try(async() => { Console.WriteLine("Setting Brightness to 100 %..."); success = await backgroundDevice.BackgroundSetBrightness(100, smooth); globalSuccess &= success; WriteLineWithColor($"command success : {success}", ConsoleColor.DarkCyan); await Task.Delay(delay); }); await Try(async() => { Console.WriteLine("Setting brightness decrease..."); success = await backgroundDevice.BackgroundSetAdjust(YeelightAPI.Models.Adjust.AdjustAction.decrease, YeelightAPI.Models.Adjust.AdjustProperty.bright); globalSuccess &= success; WriteLineWithColor($"command success : {success}", ConsoleColor.DarkCyan); await Task.Delay(delay); }); await Try(async() => { Console.WriteLine("Setting Brightness to 50 %..."); success = await backgroundDevice.BackgroundSetBrightness(50, smooth); globalSuccess &= success; WriteLineWithColor($"command success : {success}", ConsoleColor.DarkCyan); await Task.Delay(delay); }); await Try(async() => { Console.WriteLine("Setting RGB color to red ..."); success = await backgroundDevice.BackgroundSetRGBColor(255, 0, 0, smooth); globalSuccess &= success; WriteLineWithColor($"command success : {success}", ConsoleColor.DarkCyan); await Task.Delay(delay); }); await Try(async() => { Console.WriteLine("Setting RGB color to green..."); success = await backgroundDevice.BackgroundSetRGBColor(0, 255, 0, smooth); globalSuccess &= success; WriteLineWithColor($"command success : {success}", ConsoleColor.DarkCyan); await Task.Delay(delay); }); await Try(async() => { Console.WriteLine("Setting color increase circle..."); success = await backgroundDevice.BackgroundSetAdjust(YeelightAPI.Models.Adjust.AdjustAction.circle, YeelightAPI.Models.Adjust.AdjustProperty.color); globalSuccess &= success; WriteLineWithColor($"command success : {success}", ConsoleColor.DarkCyan); await Task.Delay(delay); }); await Try(async() => { Console.WriteLine("Setting RGB color to blue..."); success = await backgroundDevice.BackgroundSetRGBColor(0, 0, 255, smooth); globalSuccess &= success; WriteLineWithColor($"command success : {success}", ConsoleColor.DarkCyan); await Task.Delay(delay); }); await Try(async() => { Console.WriteLine("Setting HSV color to red..."); success = await backgroundDevice.BackgroundSetHSVColor(0, 100, smooth); globalSuccess &= success; WriteLineWithColor($"command success : {success}", ConsoleColor.DarkCyan); await Task.Delay(delay); }); await Try(async() => { Console.WriteLine("Setting HSV color to green..."); success = await backgroundDevice.BackgroundSetHSVColor(120, 100, smooth); globalSuccess &= success; WriteLineWithColor($"command success : {success}", ConsoleColor.DarkCyan); await Task.Delay(delay); }); await Try(async() => { Console.WriteLine("Setting HSV color to blue..."); success = await backgroundDevice.BackgroundSetHSVColor(240, 100, smooth); globalSuccess &= success; WriteLineWithColor($"command success : {success}", ConsoleColor.DarkCyan); await Task.Delay(delay); }); await Try(async() => { Console.WriteLine("Setting Color Temperature to 1700k ..."); success = await backgroundDevice.BackgroundSetColorTemperature(1700, smooth); globalSuccess &= success; WriteLineWithColor($"command success : {success}", ConsoleColor.DarkCyan); await Task.Delay(delay); }); await Try(async() => { Console.WriteLine("Setting color temperature increase ..."); success = await backgroundDevice.BackgroundSetAdjust(YeelightAPI.Models.Adjust.AdjustAction.increase, YeelightAPI.Models.Adjust.AdjustProperty.ct); globalSuccess &= success; WriteLineWithColor($"command success : {success}", ConsoleColor.DarkCyan); await Task.Delay(delay); }); await Try(async() => { Console.WriteLine("Setting Color Temperature to 6500k ..."); success = await backgroundDevice.BackgroundSetColorTemperature(6500, smooth); globalSuccess &= success; WriteLineWithColor($"command success : {success}", ConsoleColor.DarkCyan); await Task.Delay(delay); }); await Try(async() => { Console.WriteLine("Starting color flow ..."); int repeat = 0; ColorFlow flow = new ColorFlow(repeat, ColorFlowEndAction.Restore) { new ColorFlowRGBExpression(255, 0, 0, 1, 500), new ColorFlowRGBExpression(0, 255, 0, 100, 500), new ColorFlowRGBExpression(0, 0, 255, 50, 500), new ColorFlowSleepExpression(2000), new ColorFlowTemperatureExpression(2700, 100, 500), new ColorFlowTemperatureExpression(5000, 1, 500) }; success = await backgroundDevice.BackgroundStartColorFlow(flow); globalSuccess &= success; WriteLineWithColor($"command success : {success}", ConsoleColor.DarkCyan); await Task.Delay(10 * 1000); }); await Try(async() => { Console.WriteLine("Stoping color flow ..."); success = await backgroundDevice.BackgroundStopColorFlow(); globalSuccess &= success; WriteLineWithColor($"command success : {success}", ConsoleColor.DarkCyan); await Task.Delay(delay); }); await Try(async() => { Console.WriteLine("Starting fluent color flow ..."); FluentFlow fflow = await backgroundDevice.BackgroundFlow() .RgbColor(255, 0, 0, 50, 1000) .Sleep(2000) .RgbColor(0, 255, 0, 50, 1000) .Sleep(2000) .RgbColor(0, 0, 255, 50, 1000) .Sleep(2000) .Temperature(2700, 100, 1000) .Sleep(2000) .Temperature(6500, 100, 1000) .Play(ColorFlowEndAction.Keep); await fflow.StopAfter(5000); WriteLineWithColor($"Color flow ended", ConsoleColor.DarkCyan); }); await Try(async() => { Console.WriteLine("adjust brightness ++"); success = await backgroundDevice.BackgroundAdjustBright(50, smooth); globalSuccess &= success; WriteLineWithColor($"command success : {success}", ConsoleColor.DarkCyan); await Task.Delay(delay); }); await Try(async() => { Console.WriteLine("adjust brightness --"); success = await backgroundDevice.BackgroundAdjustBright(-50, smooth); globalSuccess &= success; WriteLineWithColor($"command success : {success}", ConsoleColor.DarkCyan); await Task.Delay(delay); }); await Try(async() => { Console.WriteLine("adjust color ++"); success = await backgroundDevice.BackgroundAdjustColor(50, smooth); globalSuccess &= success; WriteLineWithColor($"command success : {success}", ConsoleColor.DarkCyan); await Task.Delay(delay); }); await Try(async() => { Console.WriteLine("adjust color --"); success = await backgroundDevice.BackgroundAdjustColor(-50, smooth); globalSuccess &= success; WriteLineWithColor($"command success : {success}", ConsoleColor.DarkCyan); await Task.Delay(delay); }); await Try(async() => { Console.WriteLine("adjust color temperature ++"); success = await backgroundDevice.BackgroundAdjustColorTemperature(50, smooth); globalSuccess &= success; WriteLineWithColor($"command success : {success}", ConsoleColor.DarkCyan); await Task.Delay(delay); }); await Try(async() => { Console.WriteLine("adjust color temperature --"); success = await backgroundDevice.BackgroundAdjustColorTemperature(-50, smooth); globalSuccess &= success; WriteLineWithColor($"command success : {success}", ConsoleColor.DarkCyan); await Task.Delay(delay); }); await Try(async() => { Console.WriteLine("Toggling bulb state..."); success = await backgroundDevice.BackgroundToggle(); globalSuccess &= success; WriteLineWithColor($"command success : {success}", ConsoleColor.DarkCyan); await Task.Delay(delay); }); } await Try(async() => { Console.WriteLine("Setting Brightness to One..."); success = await device.SetBrightness(1, smooth); globalSuccess &= success; WriteLineWithColor($"command success : {success}", ConsoleColor.DarkCyan); await Task.Delay(delay); }); await Try(async() => { Console.WriteLine("Setting brightness increase..."); success = await device.SetAdjust(YeelightAPI.Models.Adjust.AdjustAction.increase, YeelightAPI.Models.Adjust.AdjustProperty.bright); globalSuccess &= success; WriteLineWithColor($"command success : {success}", ConsoleColor.DarkCyan); await Task.Delay(delay); }); await Try(async() => { Console.WriteLine("Setting Brightness to 100 %..."); success = await device.SetBrightness(100, smooth); globalSuccess &= success; WriteLineWithColor($"command success : {success}", ConsoleColor.DarkCyan); await Task.Delay(delay); }); await Try(async() => { Console.WriteLine("Setting brightness decrease..."); success = await device.SetAdjust(YeelightAPI.Models.Adjust.AdjustAction.decrease, YeelightAPI.Models.Adjust.AdjustProperty.bright); globalSuccess &= success; WriteLineWithColor($"command success : {success}", ConsoleColor.DarkCyan); await Task.Delay(delay); }); await Try(async() => { Console.WriteLine("Setting Brightness to 50 %..."); success = await device.SetBrightness(50, smooth); globalSuccess &= success; WriteLineWithColor($"command success : {success}", ConsoleColor.DarkCyan); await Task.Delay(delay); }); await Try(async() => { Console.WriteLine("Setting RGB color to red ..."); success = await device.SetRGBColor(255, 0, 0, smooth); globalSuccess &= success; WriteLineWithColor($"command success : {success}", ConsoleColor.DarkCyan); await Task.Delay(delay); }); await Try(async() => { Console.WriteLine("Setting RGB color to green..."); success = await device.SetRGBColor(0, 255, 0, smooth); globalSuccess &= success; WriteLineWithColor($"command success : {success}", ConsoleColor.DarkCyan); await Task.Delay(delay); }); await Try(async() => { Console.WriteLine("Setting color increase circle..."); success = await device.SetAdjust(YeelightAPI.Models.Adjust.AdjustAction.circle, YeelightAPI.Models.Adjust.AdjustProperty.color); globalSuccess &= success; WriteLineWithColor($"command success : {success}", ConsoleColor.DarkCyan); await Task.Delay(delay); }); await Try(async() => { Console.WriteLine("Setting RGB color to blue..."); success = await device.SetRGBColor(0, 0, 255, smooth); globalSuccess &= success; WriteLineWithColor($"command success : {success}", ConsoleColor.DarkCyan); await Task.Delay(delay); }); await Try(async() => { Console.WriteLine("Setting HSV color to red..."); success = await device.SetHSVColor(0, 100, smooth); globalSuccess &= success; WriteLineWithColor($"command success : {success}", ConsoleColor.DarkCyan); await Task.Delay(delay); }); await Try(async() => { Console.WriteLine("Setting HSV color to green..."); success = await device.SetHSVColor(120, 100, smooth); globalSuccess &= success; WriteLineWithColor($"command success : {success}", ConsoleColor.DarkCyan); await Task.Delay(delay); }); await Try(async() => { Console.WriteLine("Setting HSV color to blue..."); success = await device.SetHSVColor(240, 100, smooth); globalSuccess &= success; WriteLineWithColor($"command success : {success}", ConsoleColor.DarkCyan); await Task.Delay(delay); }); await Try(async() => { Console.WriteLine("Setting Color Temperature to 1700k ..."); success = await device.SetColorTemperature(1700, smooth); globalSuccess &= success; WriteLineWithColor($"command success : {success}", ConsoleColor.DarkCyan); await Task.Delay(delay); }); await Try(async() => { Console.WriteLine("Setting color temperature increase ..."); success = await device.SetAdjust(YeelightAPI.Models.Adjust.AdjustAction.increase, YeelightAPI.Models.Adjust.AdjustProperty.ct); globalSuccess &= success; WriteLineWithColor($"command success : {success}", ConsoleColor.DarkCyan); await Task.Delay(delay); }); await Try(async() => { Console.WriteLine("Setting Color Temperature to 6500k ..."); success = await device.SetColorTemperature(6500, smooth); globalSuccess &= success; WriteLineWithColor($"command success : {success}", ConsoleColor.DarkCyan); await Task.Delay(delay); }); await Try(async() => { Console.WriteLine("Starting color flow ..."); int repeat = 0; ColorFlow flow = new ColorFlow(repeat, ColorFlowEndAction.Restore) { new ColorFlowRGBExpression(255, 0, 0, 1, 500), new ColorFlowRGBExpression(0, 255, 0, 100, 500), new ColorFlowRGBExpression(0, 0, 255, 50, 500), new ColorFlowSleepExpression(2000), new ColorFlowTemperatureExpression(2700, 100, 500), new ColorFlowTemperatureExpression(5000, 1, 500) }; success = await device.StartColorFlow(flow); globalSuccess &= success; WriteLineWithColor($"command success : {success}", ConsoleColor.DarkCyan); await Task.Delay(10 * 1000); }); await Try(async() => { Console.WriteLine("Stoping color flow ..."); success = await device.StopColorFlow(); globalSuccess &= success; WriteLineWithColor($"command success : {success}", ConsoleColor.DarkCyan); await Task.Delay(delay); }); await Try(async() => { Console.WriteLine("Starting fluent color flow ..."); FluentFlow fflow = await device.Flow() .RgbColor(255, 0, 0, 50, 1000) .Sleep(2000) .RgbColor(0, 255, 0, 50, 1000) .Sleep(2000) .RgbColor(0, 0, 255, 50, 1000) .Sleep(2000) .Temperature(2700, 100, 1000) .Sleep(2000) .Temperature(6500, 100, 1000) .Play(ColorFlowEndAction.Keep); await fflow.StopAfter(5000); WriteLineWithColor($"Color flow ended", ConsoleColor.DarkCyan); }); await Try(async() => { Console.WriteLine("adjust brightness ++"); success = await device.AdjustBright(50, smooth); globalSuccess &= success; WriteLineWithColor($"command success : {success}", ConsoleColor.DarkCyan); await Task.Delay(delay); }); await Try(async() => { Console.WriteLine("adjust brightness --"); success = await device.AdjustBright(-50, smooth); globalSuccess &= success; WriteLineWithColor($"command success : {success}", ConsoleColor.DarkCyan); await Task.Delay(delay); }); await Try(async() => { Console.WriteLine("adjust color ++"); success = await device.AdjustColor(50, smooth); globalSuccess &= success; WriteLineWithColor($"command success : {success}", ConsoleColor.DarkCyan); await Task.Delay(delay); }); await Try(async() => { Console.WriteLine("adjust color --"); success = await device.AdjustColor(-50, smooth); globalSuccess &= success; WriteLineWithColor($"command success : {success}", ConsoleColor.DarkCyan); await Task.Delay(delay); }); await Try(async() => { Console.WriteLine("adjust color temperature ++"); success = await device.AdjustColorTemperature(50, smooth); globalSuccess &= success; WriteLineWithColor($"command success : {success}", ConsoleColor.DarkCyan); await Task.Delay(delay); }); await Try(async() => { Console.WriteLine("adjust color temperature --"); success = await device.AdjustColorTemperature(-50, smooth); globalSuccess &= success; WriteLineWithColor($"command success : {success}", ConsoleColor.DarkCyan); await Task.Delay(delay); }); await Try(async() => { Console.WriteLine("Toggling bulb state..."); success = await device.Toggle(); globalSuccess &= success; WriteLineWithColor($"command success : {success}", ConsoleColor.DarkCyan); await Task.Delay(delay); }); if (success) { WriteLineWithColor($"Tests are successful", ConsoleColor.DarkGreen); } else { WriteLineWithColor($"Tests failed", ConsoleColor.DarkRed); } return(globalSuccess); }
private static async Task Main(string[] args) { //NetworkDiscovery.PingAll(); DeviceLocator.UseAllAvailableMulticastAddresses = true; IEnumerable <Device> lights = await DeviceLocator.DiscoverAsync(); if (lights.Count() < 1) { Console.Out.WriteLine("No lights found."); return; } DeviceGroup deviceGroup = new DeviceGroup(); foreach (Device light in lights) { Console.Out.WriteLine($"Found Light: {light.Model} on {light.Hostname}"); deviceGroup.Add(light); } Console.Out.WriteLine($"Found {deviceGroup.Count} lights."); //YeelightAPI.Device device = new Device(IP); await deviceGroup.Connect(); await deviceGroup.SetRGBColor(255, 255, 255); await deviceGroup.SetBrightness(100); ConsoleKeyInfo input = new ConsoleKeyInfo(); do { input = Console.ReadKey(true); switch (input.Key) { case ConsoleKey.UpArrow: ColorFlow flow = new ColorFlow(0, ColorFlowEndAction.Restore); flow.Add(new ColorFlowRGBExpression(255, 0, 0, 1, 500)); flow.Add(new ColorFlowRGBExpression(0, 255, 0, 1, 500)); Console.Out.WriteLine("BLINK"); await deviceGroup.StartColorFlow(flow); break; case ConsoleKey.DownArrow: await deviceGroup.StopColorFlow(); Console.Out.WriteLine("STOP"); break; } Thread.Sleep(40); }while (input.Key != ConsoleKey.Escape); }
private static async Task <bool> ExecuteTests(IDeviceController device, int?smooth = null) { bool success = true, globalSuccess = true; int delay = 1500; Console.WriteLine("powering on ..."); success = await device.SetPower(true); globalSuccess &= success; WriteLineWithColor($"command success : {success}", ConsoleColor.DarkCyan); await Task.Delay(delay); Console.WriteLine("Setting Brightness to One..."); success = await device.SetBrightness(01); globalSuccess &= success; WriteLineWithColor($"command success : {success}", ConsoleColor.DarkCyan); await Task.Delay(delay); Console.WriteLine("Setting brightness increase..."); success = await device.SetAdjust(YeelightAPI.Models.Adjust.AdjustAction.increase, YeelightAPI.Models.Adjust.AdjustProperty.bright); globalSuccess &= success; WriteLineWithColor($"command success : {success}", ConsoleColor.DarkCyan); await Task.Delay(delay); Console.WriteLine("Setting Brightness to 100 %..."); success = await device.SetBrightness(100, smooth); globalSuccess &= success; WriteLineWithColor($"command success : {success}", ConsoleColor.DarkCyan); await Task.Delay(delay); Console.WriteLine("Setting brightness decrease..."); success = await device.SetAdjust(YeelightAPI.Models.Adjust.AdjustAction.decrease, YeelightAPI.Models.Adjust.AdjustProperty.bright); globalSuccess &= success; WriteLineWithColor($"command success : {success}", ConsoleColor.DarkCyan); await Task.Delay(delay); Console.WriteLine("Setting Brightness to 50 %..."); success = await device.SetBrightness(50, smooth); globalSuccess &= success; WriteLineWithColor($"command success : {success}", ConsoleColor.DarkCyan); await Task.Delay(delay); Console.WriteLine("Setting RGB color to red ..."); success = await device.SetRGBColor(255, 0, 0, smooth); globalSuccess &= success; WriteLineWithColor($"command success : {success}", ConsoleColor.DarkCyan); await Task.Delay(delay); Console.WriteLine("Setting RGB color to green..."); success = await device.SetRGBColor(0, 255, 0, smooth); globalSuccess &= success; WriteLineWithColor($"command success : {success}", ConsoleColor.DarkCyan); await Task.Delay(delay); Console.WriteLine("Setting color increase circle..."); success = await device.SetAdjust(YeelightAPI.Models.Adjust.AdjustAction.circle, YeelightAPI.Models.Adjust.AdjustProperty.color); globalSuccess &= success; WriteLineWithColor($"command success : {success}", ConsoleColor.DarkCyan); await Task.Delay(delay); Console.WriteLine("Setting RGB color to blue..."); success = await device.SetRGBColor(0, 0, 255, smooth); globalSuccess &= success; WriteLineWithColor($"command success : {success}", ConsoleColor.DarkCyan); await Task.Delay(delay); Console.WriteLine("Setting HSV color to red..."); success = await device.SetHSVColor(0, 100, smooth); globalSuccess &= success; WriteLineWithColor($"command success : {success}", ConsoleColor.DarkCyan); await Task.Delay(delay); Console.WriteLine("Setting HSV color to green..."); success = await device.SetHSVColor(120, 100, smooth); globalSuccess &= success; WriteLineWithColor($"command success : {success}", ConsoleColor.DarkCyan); await Task.Delay(delay); Console.WriteLine("Setting HSV color to blue..."); success = await device.SetHSVColor(240, 100, smooth); globalSuccess &= success; WriteLineWithColor($"command success : {success}", ConsoleColor.DarkCyan); await Task.Delay(delay); Console.WriteLine("Setting Color Temperature to 1700k ..."); success = await device.SetColorTemperature(1700, smooth); globalSuccess &= success; WriteLineWithColor($"command success : {success}", ConsoleColor.DarkCyan); await Task.Delay(delay); Console.WriteLine("Setting color temperature increase ..."); success = await device.SetAdjust(YeelightAPI.Models.Adjust.AdjustAction.increase, YeelightAPI.Models.Adjust.AdjustProperty.ct); globalSuccess &= success; WriteLineWithColor($"command success : {success}", ConsoleColor.DarkCyan); await Task.Delay(delay); Console.WriteLine("Setting Color Temperature to 6500k ..."); success = await device.SetColorTemperature(6500, smooth); globalSuccess &= success; WriteLineWithColor($"command success : {success}", ConsoleColor.DarkCyan); await Task.Delay(delay); Console.WriteLine("Starting color flow ..."); int repeat = 0; ColorFlow flow = new ColorFlow(repeat, ColorFlowEndAction.Restore) { new ColorFlowRGBExpression(255, 0, 0, 1, 500), new ColorFlowRGBExpression(0, 255, 0, 100, 500), new ColorFlowRGBExpression(0, 0, 255, 50, 500), new ColorFlowSleepExpression(2000), new ColorFlowTemperatureExpression(2700, 100, 500), new ColorFlowTemperatureExpression(5000, 1, 500) }; success = await device.StartColorFlow(flow); globalSuccess &= success; WriteLineWithColor($"command success : {success}", ConsoleColor.DarkCyan); await Task.Delay(10 * 1000); Console.WriteLine("Stoping color flow ..."); success = await device.StopColorFlow(); globalSuccess &= success; WriteLineWithColor($"command success : {success}", ConsoleColor.DarkCyan); await Task.Delay(delay); Console.WriteLine("Toggling bulb state..."); success = await device.Toggle(); globalSuccess &= success; WriteLineWithColor($"command success : {success}", ConsoleColor.DarkCyan); await Task.Delay(delay); if (success) { WriteLineWithColor($"Tests are successful", ConsoleColor.DarkGreen); } else { WriteLineWithColor($"Tests failed", ConsoleColor.DarkRed); } return(globalSuccess); }