When making a call using the hue client to send a light command with specific light ids you do not get a HueResults object back with any actual results.
Ex:
var result = await client.SendCommandAsync(lightCommand, new List{ "3" });
This will result in an empty HueResults object.
I have narrowed down the issue to the SendCommandRawAsync in the HueClient-Lights.cs file. I tried to make a branch to submit a fix but can't figure out how to submit the changes for review. Find the changes below:
To:
HttpClient client = await GetHttpClient().ConfigureAwait(false);
var result = await client.PutAsync(new Uri(ApiBase + string.Format("lights/{0}/state", lightId)), new JsonContent(command)).ConfigureAwait(false);
string jsonResult = await result.Content.ReadAsStringAsync().ConfigureAwait(false);
results.AddRange(DeserializeDefaultHueResult(jsonResult));
And in Q42.HueApi.Tests/LightTests.cs/SendCommandAsync:
Added assertions to verify results are successful:
//Verify that we get back results and that none of them are error.
Assert.IsTrue(result.Count > 0 && result.Any(r => r.Error == null));
Assert.IsTrue(result2.Count > 0 && result2.Any(r => r.Error == null));
Happy to submit this as part of an actual Pull Request if I can figure out how to make a PR into master. I have cloned the repo locally and made a local branch, but when I try to publish the branch to origin I don't have access.
When making a call using the hue client to send a light command with specific light ids you do not get a HueResults object back with any actual results.
Ex: var result = await client.SendCommandAsync(lightCommand, new List{ "3" });
This will result in an empty HueResults object.
I have narrowed down the issue to the SendCommandRawAsync in the HueClient-Lights.cs file. I tried to make a branch to submit a fix but can't figure out how to submit the changes for review. Find the changes below:
In HueClient-Light.cs/SendCommandRawAsync:
Change method from: HttpClient client = await GetHttpClient().ConfigureAwait(false); await client.PutAsync(new Uri(ApiBase + string.Format("lights/{0}/state", lightId)), new JsonContent(command)).ConfigureAwait(false);
To: HttpClient client = await GetHttpClient().ConfigureAwait(false); var result = await client.PutAsync(new Uri(ApiBase + string.Format("lights/{0}/state", lightId)), new JsonContent(command)).ConfigureAwait(false); string jsonResult = await result.Content.ReadAsStringAsync().ConfigureAwait(false); results.AddRange(DeserializeDefaultHueResult(jsonResult));
And in Q42.HueApi.Tests/LightTests.cs/SendCommandAsync: Added assertions to verify results are successful: //Verify that we get back results and that none of them are error. Assert.IsTrue(result.Count > 0 && result.Any(r => r.Error == null)); Assert.IsTrue(result2.Count > 0 && result2.Any(r => r.Error == null));
Happy to submit this as part of an actual Pull Request if I can figure out how to make a PR into master. I have cloned the repo locally and made a local branch, but when I try to publish the branch to origin I don't have access.
Thanks!