Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 7 additions & 13 deletions SharpHue/Lights/LightCollection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Linq;
using System.Net.Http;
using Newtonsoft.Json.Linq;
using System;

namespace SharpHue
{
Expand Down Expand Up @@ -69,20 +70,13 @@ public void Refresh()

JObject lights = JsonClient.RequestSecure(HttpMethod.Get, "/lights") as JObject;

for (int i = 1; i <= Configuration.MAX_LIGHTS; i++)
foreach (KeyValuePair<string, JToken> light in lights)
{
if (lights[i.ToString()] != null)
{
Light l = ((JObject)lights[i.ToString()]).ToObject<Light>();
l.ID = i;
l.RefreshState();
Lights.Add(l);
}
else
{
// Lights are sequential, break if we don't have a light with the specified index.
break;
}
Light l = new Light();
l = light.Value.ToObject<Light>();
l.ID = Convert.ToInt16(light.Key);
Lights.Add(l);
l.RefreshState();
}
}

Expand Down
5 changes: 2 additions & 3 deletions SharpHue/SharpHue.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,8 @@
</PropertyGroup>
<ItemGroup>
<Reference Include="Newtonsoft.Json, Version=4.5.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\Newtonsoft.Json.dll</HintPath>
<Private>False</Private>
<HintPath>..\packages\Newtonsoft.Json.5.0.6\lib\net45\Newtonsoft.Json.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
Expand Down