public ManagerBitLockerUnlockHandler(IBroadcaster broadcaster, IDeviceController deviceController, ISession session, CryptoProvider cryptor)
 {
     this.broadcaster      = broadcaster;
     this.deviceController = deviceController;
     this.session          = session;
     this.cryptor          = cryptor;
 }
Example #2
0
        public Form1(IDeviceController controller)
        {
            InitializeComponent();
            mapper  = new SquaredScreenRectDecorator(new ScreenToCoordinateMapper());
            display = new PPIDisplay(ppi_pb, mapper);

            display.DmeStateChanged += Display_DmeStateChanged;
            this.controller          = controller;
            UpdateForm(controller.Model);
            Visible = true;
        }
Example #3
0
        public RobotController(LeapListener leapListener, Device device)
        {
            Console.WriteLine(device.ToString());
            _leapListener = leapListener;

            switch (device)
            {
                case Device.Platform:
                    deviceController = new PlatformController();
                    break;
                case Device.ArmBigger:
                    deviceController = new ArmBiggerController();
                    break;
                case Device.ArmSmaller:
                    deviceController = new ArmSmallerController();
                    break;
            }
            _controlThread = new Thread(controlRobot);
            _controlThread.Start();
        }
Example #4
0
        public MenuViewController(IDeviceController deviceController)
        {
            System.Diagnostics.Debug.Assert(deviceController != null);

            _deviceController = deviceController;
            _deviceController.OnStateChanged += OnStateChanged;

            _components = new System.ComponentModel.Container();
            _notifyIcon = new NotifyIcon(_components)
            {
                ContextMenuStrip = new ContextMenuStrip(),
                Icon             = Properties.Resources.NotReadyIcon,
                Text             = "Overlay is not found",
                Visible          = true,
            };

            _notifyIcon.ContextMenuStrip.Opening += ContextMenuStrip_Opening;

            _hiddenWindow = new System.Windows.Window();
            _hiddenWindow.Hide();
        }
Example #5
0
        public RobotController(LeapListener leapListener, Device device)
        {
            Console.WriteLine(device.ToString());
            _leapListener = leapListener;

            switch (device)
            {
            case Device.Platform:
                deviceController = new PlatformController();
                break;

            case Device.ArmBigger:
                deviceController = new ArmBiggerController();
                break;

            case Device.ArmSmaller:
                deviceController = new ArmSmallerController();
                break;
            }
            _controlThread = new Thread(controlRobot);
            _controlThread.Start();
        }
Example #6
0
        public STAApplicationContext()
        {
            SetupServer();

            if (!featureToggles[isDeviceMockedKey])
            {
                var touchOverlay = (new TouchOverlay()).AddToDisposeBag(_disposeBag);
                _deviceController   = (IDeviceController)touchOverlay;
                _touchInputProvider = (IInputProvider)touchOverlay;
            }
            else
            {
                var deviceMock = (new DeviceMock()).AddToDisposeBag(_disposeBag);
                _deviceController   = (IDeviceController)deviceMock;
                _touchInputProvider = (IInputProvider)deviceMock;
            }

            if (featureToggles[inputLoggingKey])
            {
                _inputSerializer = (new InputSerializer(_touchInputProvider))
                                   .AddToDisposeBag(_disposeBag);

                _inputLogger = (new InputLogger(_touchInputProvider))
                               .AddToDisposeBag(_disposeBag);
            }

            _tuioInputProvider = (new TuioObjectController(_touchInputProvider, _tangibleMarkerController))
                                 .AddToDisposeBag(_disposeBag);

            _tuioServer = (new TuioServer(_tuioInputProvider))
                          .AddToDisposeBag(_disposeBag);

            _menuViewController = (new MenuViewController(_deviceController))
                                  .AddToDisposeBag(_disposeBag);

            _deviceController.Init();
            _deviceController.Start();
        }
Example #7
0
        private void StartDriver()
        {
            IDeviceController driver = null;

            if (Name.Equals("Device", StringComparison.InvariantCulture))
            {
                driver = new PhoneWindowsPhoneDeviceController();
            }
            else
            {
                driver = ExecutingEmulatorVersion == WindowsPhoneVersion.Seven
                                 ? new EmulatorWindowsPhoneDeviceController(Name)
                                 : new Win8EmulatorWindowsPhoneDeviceController(Name, Port);
            }

            driver.Trace += (sender, args) => InvokeTrace(args);
            if (!driver.TryConnect())
            {
                throw new AutomationException("Unable to connect to driver");
            }

            DeviceController = driver;
        }
        public bool SetHSVColor(string deviceOrGroupName, int hue, int sat, int?smooth = null)
        {
            IDeviceController device = GetControllerDevice(deviceOrGroupName);

            return(device.SetHSVColor(hue, sat, smooth).Result);
        }
        public bool SetDefault(string deviceOrGroupName)
        {
            IDeviceController device = GetControllerDevice(deviceOrGroupName);

            return(device.SetDefault().Result);
        }
Example #10
0
 public Light(IDeviceController deviceController)
 {
     _deviceController = deviceController;
 }
Example #11
0
 public Light(IDeviceController deviceController, Color lightColor)
 {
     _deviceController = deviceController;
     LightColor = lightColor;
 }
Example #12
0
        public async Task <bool> SetPower(string deviceOrGroupName, bool state = true)
        {
            IDeviceController device = _all[deviceOrGroupName] as IDeviceController;

            return(await device.SetPower(state));
        }
        public bool Toggle(string deviceOrGroupName)
        {
            IDeviceController device = GetControllerDevice(deviceOrGroupName);

            return(device.Toggle().Result);
        }
        public bool TurnOn(string deviceOrGroupName, int?smooth = null, PowerOnMode mode = PowerOnMode.Normal)
        {
            IDeviceController device = GetControllerDevice(deviceOrGroupName);

            return(device.TurnOn(smooth, mode).Result);
        }
 public ManagerDevicesRequestHandler(IDeviceController deviceController, ISession session)
 {
     this.deviceController = deviceController;
     this.session          = session;
 }
Example #16
0
        public async Task <bool> TurnOn(string deviceOrGroupName, int?smooth = null, PowerOnMode mode = PowerOnMode.Normal)
        {
            IDeviceController device = _all[deviceOrGroupName] as IDeviceController;

            return(await device.TurnOn(smooth, mode));
        }
Example #17
0
        public async Task <bool> TurnOff(string deviceOrGroupName, int?smooth = null)
        {
            IDeviceController device = _all[deviceOrGroupName] as IDeviceController;

            return(await device.TurnOff(smooth));
        }
Example #18
0
        public async Task <bool> Toggle(string deviceOrGroupName)
        {
            IDeviceController device = _all[deviceOrGroupName] as IDeviceController;

            return(await device.Toggle());
        }
Example #19
0
        public async Task <bool> SetRGBColor(string deviceOrGroupName, int red, int green, int blue, int?smooth = null)
        {
            IDeviceController device = _all[deviceOrGroupName] as IDeviceController;

            return(await device.SetRGBColor(red, green, blue, smooth));
        }
        public bool SetPower(string deviceOrGroupName, bool state = true)
        {
            IDeviceController device = GetControllerDevice(deviceOrGroupName);

            return(device.SetPower(state).Result);
        }
        public bool SetRGBColor(string deviceOrGroupName, int red, int green, int blue, int?smooth = null)
        {
            IDeviceController device = GetControllerDevice(deviceOrGroupName);

            return(device.SetRGBColor(red, green, blue, smooth).Result);
        }
Example #22
0
 public Light(IDeviceController deviceController, Color lightColor)
 {
     _deviceController = deviceController;
     LightColor        = lightColor;
 }
        public bool TurnOff(string deviceOrGroupName, int?smooth = null)
        {
            IDeviceController device = GetControllerDevice(deviceOrGroupName);

            return(device.TurnOff(smooth).Result);
        }
Example #24
0
        public async Task <bool> SetHSVColor(string deviceOrGroupName, int hue, int sat, int?smooth = null)
        {
            IDeviceController device = _all[deviceOrGroupName] as IDeviceController;

            return(await device.SetHSVColor(hue, sat, smooth));
        }
Example #25
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="device"></param>
 /// <param name="start"></param>
 /// <param name="stop"></param>
 internal FluentFlow(IDeviceController device, Func <ColorFlow.ColorFlow, Task <bool> > start, Func <Task <bool> > stop)
 {
     this._device = device;
     this._startColorFlowMethod = start;
     this._stopColorFlowMethod  = stop;
 }
        public bool AdjustBrightness(string deviceOrGroupName, int percent, int?duration)
        {
            IDeviceController device = GetControllerDevice(deviceOrGroupName);

            return(device.AdjustBright(percent, duration).Result);
        }
Example #27
0
 public Light(IDeviceController deviceController)
 {
     _deviceController = deviceController;
 }
        public bool AdjustColorTemperature(string deviceOrGroupName, int percent, int?duration)
        {
            IDeviceController device = GetControllerDevice(deviceOrGroupName);

            return(device.AdjustColorTemperature(percent, duration).Result);
        }
Example #29
0
 public LightFactory(IDeviceController deviceController)
 {
     _controller = deviceController;
 }
        public bool SetAdjust(string deviceOrGroupName, AdjustAction adjustAction, AdjustProperty adjustProperty)
        {
            IDeviceController device = GetControllerDevice(deviceOrGroupName);

            return(device.SetAdjust(adjustAction, adjustProperty).Result);
        }
Example #31
0
 public LightFactory(IDeviceController deviceController)
 {
     _controller = deviceController;
 }
        public bool SetBrightness(string deviceOrGroupName, int brightness, int?smooth = null)
        {
            IDeviceController device = GetControllerDevice(deviceOrGroupName);

            return(device.SetBrightness(brightness, smooth).Result);
        }
Example #33
0
        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);
        }
        public bool SetColorTemperature(string deviceOrGroupName, int temperature, int?smooth = null)
        {
            IDeviceController device = GetControllerDevice(deviceOrGroupName);

            return(device.SetColorTemperature(temperature, smooth).Result);
        }