-
-
Notifications
You must be signed in to change notification settings - Fork 114
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
v1.6.0, added support for CameraMotion, ContactSensor and TamperSensor
- Loading branch information
1 parent
43dd2a3
commit 1994d4d
Showing
14 changed files
with
376 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
using HueApi.Models.Requests; | ||
using Microsoft.Extensions.Configuration; | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
using System; | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
|
||
namespace HueApi.Tests | ||
{ | ||
[TestClass] | ||
public class CameraMotionTests | ||
{ | ||
private readonly LocalHueApi localHueClient; | ||
|
||
public CameraMotionTests() | ||
{ | ||
var builder = new ConfigurationBuilder().AddUserSecrets<CameraMotionTests>(); | ||
var config = builder.Build(); | ||
|
||
localHueClient = new LocalHueApi(config["ip"], key: config["key"]); | ||
} | ||
|
||
[TestMethod] | ||
public async Task Get() | ||
{ | ||
var result = await localHueClient.GetCameraMotionsAsync(); | ||
|
||
Assert.IsNotNull(result); | ||
Assert.IsFalse(result.HasErrors); | ||
} | ||
|
||
[TestMethod] | ||
public async Task GetById() | ||
{ | ||
var all = await localHueClient.GetCameraMotionsAsync(); | ||
var id = all.Data.First().Id; | ||
|
||
var result = await localHueClient.GetCameraMotionAsync(id); | ||
|
||
Assert.IsNotNull(result); | ||
Assert.IsFalse(result.HasErrors); | ||
|
||
Assert.IsTrue(result.Data.Count == 1); | ||
|
||
} | ||
|
||
|
||
[TestMethod] | ||
public async Task PutById() | ||
{ | ||
var all = await localHueClient.GetCameraMotionsAsync(); | ||
var id = all.Data.Last().Id; | ||
|
||
var req = new UpdateSensitivitySensorRequest(); | ||
var result = await localHueClient.UpdateCameraMotionAsync(id, req); | ||
|
||
Assert.IsNotNull(result); | ||
Assert.IsFalse(result.HasErrors); | ||
|
||
Assert.IsTrue(result.Data.Count == 1); | ||
Assert.AreEqual(id, result.Data.First().Rid); | ||
|
||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
using HueApi.Models.Requests; | ||
using Microsoft.Extensions.Configuration; | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
using System; | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
|
||
namespace HueApi.Tests | ||
{ | ||
[TestClass] | ||
public class ContactSensorTests | ||
{ | ||
private readonly LocalHueApi localHueClient; | ||
|
||
public ContactSensorTests() | ||
{ | ||
var builder = new ConfigurationBuilder().AddUserSecrets<ContactSensorTests>(); | ||
var config = builder.Build(); | ||
|
||
localHueClient = new LocalHueApi(config["ip"], key: config["key"]); | ||
} | ||
|
||
[TestMethod] | ||
public async Task Get() | ||
{ | ||
var result = await localHueClient.GetContactSensorsAsync(); | ||
|
||
Assert.IsNotNull(result); | ||
Assert.IsFalse(result.HasErrors); | ||
} | ||
|
||
[TestMethod] | ||
public async Task GetById() | ||
{ | ||
var all = await localHueClient.GetContactSensorsAsync(); | ||
var id = all.Data.First().Id; | ||
|
||
var result = await localHueClient.GetContactSensorAsync(id); | ||
|
||
Assert.IsNotNull(result); | ||
Assert.IsFalse(result.HasErrors); | ||
|
||
Assert.IsTrue(result.Data.Count == 1); | ||
|
||
} | ||
|
||
|
||
[TestMethod] | ||
public async Task PutById() | ||
{ | ||
var all = await localHueClient.GetContactSensorsAsync(); | ||
var id = all.Data.Last().Id; | ||
|
||
var req = new UpdateSensitivitySensorRequest(); | ||
var result = await localHueClient.UpdateContactSensorsAsync(id, req); | ||
|
||
Assert.IsNotNull(result); | ||
Assert.IsFalse(result.HasErrors); | ||
|
||
Assert.IsTrue(result.Data.Count == 1); | ||
Assert.AreEqual(id, result.Data.First().Rid); | ||
|
||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
using HueApi.Models.Requests; | ||
using Microsoft.Extensions.Configuration; | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
using System; | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
|
||
namespace HueApi.Tests | ||
{ | ||
[TestClass] | ||
public class TamperSensorTests | ||
{ | ||
private readonly LocalHueApi localHueClient; | ||
|
||
public TamperSensorTests() | ||
{ | ||
var builder = new ConfigurationBuilder().AddUserSecrets<TamperSensorTests>(); | ||
var config = builder.Build(); | ||
|
||
localHueClient = new LocalHueApi(config["ip"], key: config["key"]); | ||
} | ||
|
||
[TestMethod] | ||
public async Task Get() | ||
{ | ||
var result = await localHueClient.GetTamperSensorsAsync(); | ||
|
||
Assert.IsNotNull(result); | ||
Assert.IsFalse(result.HasErrors); | ||
} | ||
|
||
[TestMethod] | ||
public async Task GetById() | ||
{ | ||
var all = await localHueClient.GetTamperSensorsAsync(); | ||
var id = all.Data.First().Id; | ||
|
||
var result = await localHueClient.GetTamperSensorAsync(id); | ||
|
||
Assert.IsNotNull(result); | ||
Assert.IsFalse(result.HasErrors); | ||
|
||
Assert.IsTrue(result.Data.Count == 1); | ||
|
||
} | ||
|
||
|
||
[TestMethod] | ||
public async Task PutById() | ||
{ | ||
var all = await localHueClient.GetTamperSensorsAsync(); | ||
var id = all.Data.Last().Id; | ||
|
||
var req = new BaseResourceRequest(); | ||
var result = await localHueClient.UpdateTamperSensorAsync(id, req); | ||
|
||
Assert.IsNotNull(result); | ||
Assert.IsFalse(result.HasErrors); | ||
|
||
Assert.IsTrue(result.Data.Count == 1); | ||
Assert.AreEqual(id, result.Data.First().Rid); | ||
|
||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
src/HueApi/Models/Requests/UpdateSensitivitySensorRequest.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
using HueApi.Models.Sensors; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Text.Json.Serialization; | ||
using System.Threading.Tasks; | ||
|
||
namespace HueApi.Models.Requests | ||
{ | ||
public class UpdateSensitivitySensorRequest : UpdateSensorRequest | ||
{ | ||
[JsonPropertyName("sensitivity")] | ||
public Sensitivity? Sensitivity { get; set; } | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Text.Json.Serialization; | ||
using System.Threading.Tasks; | ||
|
||
namespace HueApi.Models.Sensors | ||
{ | ||
public class CameraMotionResource : MotionResource | ||
{ | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
using System.Text.Json.Serialization; | ||
|
||
namespace HueApi.Models.Sensors | ||
{ | ||
public class ContactSensor : HueResource | ||
{ | ||
[JsonPropertyName("enabled")] | ||
public bool Enabled { get; set; } = default!; | ||
|
||
[JsonPropertyName("contact_report")] | ||
public ContactReport? ContactReport { get; set; } | ||
} | ||
|
||
public class ContactReport | ||
{ | ||
[JsonPropertyName("changed")] | ||
public DateTimeOffset Changed { get; set; } | ||
|
||
[JsonPropertyName("state")] | ||
public ContactState State { get; set; } | ||
|
||
} | ||
|
||
[JsonConverter(typeof(JsonStringEnumConverter))] | ||
public enum ContactState | ||
{ | ||
contact, no_contact | ||
} | ||
} |
Oops, something went wrong.