private static async Task DemoModifyCollections(LifxClient client) { Group group = (await client.ListGroups()).FirstOrDefault(); if (group == null) { Console.WriteLine("No groups"); } else { Console.WriteLine("Using group: {0}", group); Console.WriteLine("Toggling group"); await group.TogglePower(); Console.WriteLine("Turning group green"); await group.SetColor(LifxColor.Green); } Location location = (await client.ListLocations()).FirstOrDefault(); if (location == null) { Console.WriteLine("No locations"); } else { Console.WriteLine("Using location: {0}", location); Console.WriteLine("Turning off location"); await location.SetPower(false); Console.WriteLine("Turning location pink"); await location.SetColor(LifxColor.Pink); } }
private static async Task DemoModifyCollections(LifxClient client) { Console.WriteLine(); List <Light> lights = (await client.ListLights(new Selector.LightLabel("LIFX 027d98"))); Group group = (await client.ListGroups()).FirstOrDefault(); if (group == null) { Console.WriteLine("No groups"); } else { Console.WriteLine("Using group: {0}", group); Console.WriteLine("Toggling group, 3 second duration."); await group.TogglePower(3); await Task.Delay(DELAY + 3000); Console.WriteLine("Turning group green"); await group.SetColor(LifxColor.Green, 0); await Task.Delay(DELAY); } Location location = (await client.ListLocations()).FirstOrDefault(); await Task.Delay(DELAY); if (location == null) { Console.WriteLine("No locations"); } else { Console.WriteLine("Using location: {0}", location); Console.WriteLine("Turning off location"); await location.SetPower(PowerState.Off); await Task.Delay(DELAY); Console.WriteLine("Setting color to white with 5 second duration."); await location.SetColor(new LifxColor.White(1), 5); await Task.Delay(DELAY + 5000); Console.WriteLine("Set light to a blue color, using 90% brightness override. Uses SetState explicitely."); await location.SetState(PowerState.On, new LifxColor.HSBK(180, 1, 1, 2000), 0.9, 2); await Task.Delay(DELAY); } }
private static async Task DemoListing(LifxClient client) { Console.WriteLine(); Console.WriteLine("Lights:"); foreach (var light in await client.ListLights()) { Console.WriteLine("{0} - {1}", light, light.Color); } Console.WriteLine(); Console.WriteLine("Groups:"); foreach (var group in await client.ListGroups()) { Console.WriteLine("{0} - {1} lights", group, group.Count()); } Console.WriteLine(); Console.WriteLine("Locations:"); foreach (var group in await client.ListLocations()) { Console.WriteLine("{0} - {1} lights", group, group.Count()); } }