/// <summary> /// Gets a list of all scenes currently stored in the bridge. /// </summary> /// <remarks> /// <para> /// Gets a list of all scenes currently stored in the bridge. /// Scenes are represented by a scene id, a name and a list of lights which are part of the scene. /// The name resource can contain a "friendly name" or can contain a unique code. /// Scenes are stored in the bridge. /// This means that scene light state settings can easily be retrieved by developers (using ADD link) and shown in their respective UI’s. /// Cached scenes (scenes stored with PUT) will be deprecated in the future. /// </para> /// <para> /// Additionally, bridge scenes should not be confused with the preset scenes stored in the Android and iOS Hue apps. /// In the apps these scenes are stored internally. /// Once activated they may then appear as a bridge scene. /// </para> /// </remarks> /// <param name="cancellationToken"></param> /// <returns>Returns a list of all scenes in the bridge.</returns> public async Task <IReadOnlyList <HueScene> > GetScenesAsync(CancellationToken cancellationToken = default) { var response = await _httpClient.GetAsync($"http://{_ipAddress}/api/{UserName}/scenes", cancellationToken); response.EnsureSuccessStatusCode(); var json = await response.Content.ReadAsStringAsync(); var root = JsonConvert.DeserializeObject <JObject>(json); var scenes = new List <HueScene>(root.Count); foreach (var p in root) { var scene = new HueScene { Id = p.Key }; JsonConvert.PopulateObject(p.Value.ToString(), scene); scenes.Add(scene); } return(scenes); }
public Task SetSceneAsync(HueScene scene, CancellationToken cancellationToken = default) => SetSceneAsync(scene.Id, cancellationToken);