diff --git a/src/HueApi.Tests/LightTests.cs b/src/HueApi.Tests/LightTests.cs index 2dfb85d..9634fe0 100644 --- a/src/HueApi.Tests/LightTests.cs +++ b/src/HueApi.Tests/LightTests.cs @@ -5,6 +5,7 @@ using Microsoft.Extensions.Configuration; using Microsoft.VisualStudio.TestTools.UnitTesting; using System; +using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; @@ -36,7 +37,7 @@ public async Task Get() public async Task GetById() { var all = await localHueClient.GetLightsAsync(); - var id = all.Data.First().Id; + var id = all.Data.Last().Id; var result = await localHueClient.GetLightAsync(id); @@ -56,13 +57,24 @@ public async Task PutById() UpdateLight req = new UpdateLight() { - Alert = new UpdateAlert() + Signaling = new SignalingUpdate + { + Signal = Signal.alternating, + Duration = 60000, + Colors = new List + { + new Color { Xy = new XyPosition { X = 0.456, Y = 0.123, }}, + new Color { Xy = new XyPosition { X = 0.333, Y = 0.712, }} + } + } }; var result = await localHueClient.UpdateLightAsync(id, req); Assert.IsNotNull(result); Assert.IsFalse(result.HasErrors); + var resultRead = await localHueClient.GetLightAsync(id); + Assert.IsTrue(result.Data.Count == 1); Assert.AreEqual(id, result.Data.First().Rid); diff --git a/src/HueApi/HueApi.csproj b/src/HueApi/HueApi.csproj index 7565ff2..6b199d8 100644 --- a/src/HueApi/HueApi.csproj +++ b/src/HueApi/HueApi.csproj @@ -6,7 +6,7 @@ enable enable nullable - 1.5.0 + 1.5.1 Michiel Post For Clip v2 API. Open source library for interaction with the Philips Hue Bridge. Allows you to control your lights from C#. https://github.com/michielpost/Q42.HueApi diff --git a/src/HueApi/Models/Device.cs b/src/HueApi/Models/Device.cs index bd17485..831f665 100644 --- a/src/HueApi/Models/Device.cs +++ b/src/HueApi/Models/Device.cs @@ -11,25 +11,28 @@ namespace HueApi.Models public class ProductData { [JsonPropertyName("certified")] - public bool Certified { get; set; } + public bool? Certified { get; set; } [JsonPropertyName("manufacturer_name")] - public string ManufacturerName { get; set; } = default!; + public string? ManufacturerName { get; set; } [JsonPropertyName("model_id")] - public string ModelId { get; set; } = default!; + public string? ModelId { get; set; } [JsonPropertyName("product_archetype")] - public string ProductArchetype { get; set; } = default!; + public string? ProductArchetype { get; set; } [JsonPropertyName("product_name")] - public string ProductName { get; set; } = default!; + public string? ProductName { get; set; } [JsonPropertyName("software_version")] - public string SoftwareVersion { get; set; } = default!; + public string? SoftwareVersion { get; set; } [JsonPropertyName("hardware_platform_type")] - public string HardwarePlatformType { get; set; } = default!; + public string? HardwarePlatformType { get; set; } + + [JsonPropertyName("function")] + public string? Function { get; set; } } public class Device : HueResource diff --git a/src/HueApi/Models/GroupedLight.cs b/src/HueApi/Models/GroupedLight.cs index e86db0f..98f89a3 100644 --- a/src/HueApi/Models/GroupedLight.cs +++ b/src/HueApi/Models/GroupedLight.cs @@ -9,10 +9,16 @@ namespace HueApi.Models { public class GroupedLight : HueResource { + [JsonPropertyName("on")] + public On On { get; set; } = default!; + + [JsonPropertyName("dimming")] + public Dimming? Dimming { get; set; } + [JsonPropertyName("alert")] public Alert? Alert { get; set; } - [JsonPropertyName("on")] - public On? On { get; set; } + [JsonPropertyName("signaling")] + public Signaling? Signaling { get; set; } } } diff --git a/src/HueApi/Models/Light.cs b/src/HueApi/Models/Light.cs index 184fc93..a8855ba 100644 --- a/src/HueApi/Models/Light.cs +++ b/src/HueApi/Models/Light.cs @@ -33,6 +33,9 @@ public class Light : HueResource [JsonPropertyName("alert")] public Alert? Alert { get; set; } + [JsonPropertyName("product_data")] + public ProductData? ProductData { get; set; } + [JsonPropertyName("signaling")] public Signaling? Signaling { get; set; } @@ -61,6 +64,9 @@ public class Alert public class Signaling { + [JsonPropertyName("signal_values")] + public List? SignalValues { get; set; } + [JsonPropertyName("status")] public SignalingStatus? Status { get; set; } } @@ -78,6 +84,25 @@ public class SignalingStatus /// [JsonPropertyName("estimated_end")] public DateTimeOffset? EstimatedEnd { get; set; } + + [JsonPropertyName("colors")] + public List? Colors { get; set; } + } + + public class SignalingUpdate + { + [JsonPropertyName("signal")] + public Signal Signal { get; set; } + + [JsonPropertyName("duration")] + public int Duration { get; set; } + + /// + /// List of colors to apply to the signal (not supported by all signals) + /// + [JsonPropertyName("colors")] + public List? Colors { get; set; } + } public class Dynamics @@ -297,6 +322,6 @@ public enum PowerUpOnMode [JsonConverter(typeof(JsonStringEnumConverter))] public enum Signal { - no_signal, on_off + no_signal, on_off, on_off_color, alternating } } diff --git a/src/HueApi/Models/Requests/UpdateGroupedLight.cs b/src/HueApi/Models/Requests/UpdateGroupedLight.cs index c07727c..16db5d7 100644 --- a/src/HueApi/Models/Requests/UpdateGroupedLight.cs +++ b/src/HueApi/Models/Requests/UpdateGroupedLight.cs @@ -31,6 +31,9 @@ public class UpdateGroupedLight : BaseResourceRequest, IUpdateColor, IUpdateColo [JsonPropertyName("alert")] public UpdateAlert? Alert { get; set; } + [JsonPropertyName("signaling")] + public SignalingUpdate? Signaling { get; set; } + [JsonPropertyName("dynamics")] public Dynamics? Dynamics { get; set; } diff --git a/src/HueApi/Models/Requests/UpdateLight.cs b/src/HueApi/Models/Requests/UpdateLight.cs index a88c321..943203d 100644 --- a/src/HueApi/Models/Requests/UpdateLight.cs +++ b/src/HueApi/Models/Requests/UpdateLight.cs @@ -34,6 +34,9 @@ public class UpdateLight : BaseResourceRequest, IUpdateColor, IUpdateColorTemper [JsonPropertyName("alert")] public UpdateAlert? Alert { get; set; } + [JsonPropertyName("signaling")] + public SignalingUpdate? Signaling { get; set; } + [JsonPropertyName("gradient")] public Gradient? Gradient { get; set; }