From 4fd750f8e04692a6539d3366405805080b3a71a2 Mon Sep 17 00:00:00 2001 From: Yorick Rommers Date: Thu, 3 Dec 2015 11:33:25 +0100 Subject: [PATCH] excepted light --- HueUWP/APIHandler.cs | 23 +++++++++-------------- HueUWP/Light.cs | 3 +++ 2 files changed, 12 insertions(+), 14 deletions(-) diff --git a/HueUWP/APIHandler.cs b/HueUWP/APIHandler.cs index e2e6413..b0da5d8 100755 --- a/HueUWP/APIHandler.cs +++ b/HueUWP/APIHandler.cs @@ -73,25 +73,20 @@ namespace HueUWP try { var json = await nwh.AllLights(); JObject o = JObject.Parse(json); + Debug.WriteLine(o.ToString()); foreach(var i in o) { var light = o["" + i.Key]; var state = light["state"]; - alllights.Add(new Light() { api = this,ID = Int32.Parse( i.Key), Brightness = (int)state["bri"], IsOn = ((string)state["on"]).ToLower() == "true" ? true : false, Hue = (int)state["hue"], Saturation = (int)state["sat"], Name = (string)light["name"], Type = (string)light["type"] }); - //Debug.WriteLine("Added light number " + i + " " + state["on"]); + if ((String)light["type"] != "Dimmable light") + { + alllights.Add(new Light() { api = this, ID = Int32.Parse(i.Key), Brightness = (int)state["bri"], SaturationEnabled = true, HueEnabled = true, IsOn = ((string)state["on"]).ToLower() == "true" ? true : false, Hue = (int)state["hue"], Saturation = (int)state["sat"], Name = (string)light["name"], Type = (string)light["type"] }); + } + else + { + alllights.Add(new Light() { api = this, ID = Int32.Parse(i.Key), Brightness = (int)state["bri"], SaturationEnabled = false,HueEnabled = false,IsOn = ((string)state["on"]).ToLower() == "true" ? true : false, Hue =-1, Saturation = 254, Name = (string)light["name"], Type = (string)light["type"] }); + }//Debug.WriteLine("Added light number " + i + " " + state["on"]); } - - //lightlist = lightlist.OrderBy(q => q.Name).ToList(); - - //lightlist.Sort( - // delegate (Light p1, Light p2) - // { - // return p1.Name.CompareTo(p2.Name); - // } - // ); - - //lightlist.ForEach(q => alllights.Add(q)); - return "success"; } catch(Exception e) diff --git a/HueUWP/Light.cs b/HueUWP/Light.cs index 8f3f4bc..ca1ce12 100644 --- a/HueUWP/Light.cs +++ b/HueUWP/Light.cs @@ -17,6 +17,9 @@ namespace HueUWP public string Name { get; set; } public string Type { get; set; } + public bool HueEnabled; + public bool SaturationEnabled; + private bool _isOn; public bool IsOn