Esempio n. 1
0
 public SetColorCommand(IHystrixCommandOptions options, string lifxKey, string newColor, double?duration = null) :
     base(options)
 {
     _lifxClient = new LifxApi(lifxKey);
     _newColor   = newColor;
     _duration   = duration ?? 1;
 }
Esempio n. 2
0
 protected void OnApplicationSettingChangedEvent(ApplicationSettingChangedEventArgs e)
 {
     // ***
     // *** Check for when the key changes
     // ***
     if (e.PropertyName == MagicValue.Property.Name.LifxApiKey)
     {
         _api = null;
     }
 }
Esempio n. 3
0
        private async Task TestLifx()
        {
            // ***
            // *** Initialize the API
            // ***
            LifxApi api = new LifxApi("c1c1b8b4760452f88074f9457b728ce8b2c92f97cbabcd4dec6d7ccabd82011c");

            // ***
            // *** Validate a color
            // ***
            Color color = await api.ValidateColor("#ff0000");

            // ***
            // *** Lists the lights
            // ***
            IEnumerable <Light> lights = await api.ListLights(Selector.All);

            // ***
            // *** List the scenes
            // ***
            IEnumerable <Scene> sceneList = await api.ListScenes();

            // ***
            // *** Select a single light
            // ***
            Light light = lights.Where(t => t.Label == "iWindow").SingleOrDefault();

            // ***
            // ***
            // ***
            Mix mix = new Mix()
            {
                States = new SentState[]
                {
                    new SentState()
                    {
                        Brightness = 1, Color = "Red"
                    },
                    new SentState()
                    {
                        Brightness = 1, Color = "Green"
                    },
                    new SentState()
                    {
                        Brightness = 1, Color = "Blue"
                    },
                    new SentState()
                    {
                        Power = "off"
                    }
                },
                Defaults = new SentState()
                {
                    Power = "on", Duration = 1,
                }
            };

            await api.Cycle(light, mix);

            // ***
            // *** Create a list selector
            // ***
            ISelector items = Selector.CreateList(lights.ElementAt(0), lights.ElementAt(1));

            if (light != null)
            {
                await api.TogglePower(light, 3);

                await api.SetState(light, new SentState()
                {
                    Power = "on", Duration = 2, Color = "#1fa1b2"
                });
            }
        }