diff --git a/HueUWP/APIHandler.cs b/HueUWP/APIHandler.cs index 9f27ed9..d973a9c 100755 --- a/HueUWP/APIHandler.cs +++ b/HueUWP/APIHandler.cs @@ -58,11 +58,11 @@ namespace HueUWP var json = await nwh.AllLights(); JObject o = JObject.Parse(json); - for (int i = 1; i <= o.Count; i++) + foreach(var i in o) { - var light = o["" + i]; + var light = o["" + i.Key]; var state = light["state"]; - alllights.Add(new Light() { api = this,ID = i, 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"] }); + 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"]); } } catch(Exception e) diff --git a/HueUWP/MainPage.xaml.cs b/HueUWP/MainPage.xaml.cs index f06ae7c..a8caab2 100644 --- a/HueUWP/MainPage.xaml.cs +++ b/HueUWP/MainPage.xaml.cs @@ -42,8 +42,8 @@ namespace HueUWP public MainPage() { this.InitializeComponent(); - LOCAL_SETTINGS.Values["ip"] = "localhost"; - LOCAL_SETTINGS.Values["port"] = 8000; + LOCAL_SETTINGS.Values["ip"] = "145.48.205.190"; + LOCAL_SETTINGS.Values["port"] = 80; NetworkHandler nwh = new NetworkHandler(); api = new APIHandler(nwh); _lightsViewModel.Clear();