From 21745a65e8253334bd134c8f412ba98ee10a07f9 Mon Sep 17 00:00:00 2001 From: michielpost Date: Tue, 16 Feb 2021 10:01:22 +0100 Subject: [PATCH 1/2] Removing DataContract and DataMember --- src/Q42.HueApi/Models/Bridge/Bridge.cs | 2 - src/Q42.HueApi/Models/Bridge/BridgeConfig.cs | 58 +++++++------- .../Models/Bridge/BridgeConfigUpdate.cs | 30 ++++---- .../Models/Bridge/InternetServices.cs | 12 ++- src/Q42.HueApi/Models/Bridge/PortalState.cs | 13 ++-- .../Models/Bridge/SoftwareUpdate.cs | 26 +++---- .../Models/Bridge/SoftwareUpdate2.cs | 23 +++--- .../Models/Groups/CreateGroupRequest.cs | 9 +-- src/Q42.HueApi/Models/Groups/Group.cs | 49 +++++------- .../Models/Groups/UpdateGroupRequest.cs | 11 +-- .../Models/InternalBridgeCommand.cs | 12 +-- src/Q42.HueApi/Models/Light.cs | 77 ++++++++----------- src/Q42.HueApi/Models/LightCommand.cs | 30 ++++---- src/Q42.HueApi/Models/LightUpdate.cs | 8 +- src/Q42.HueApi/Models/ResourceLink.cs | 21 ++--- src/Q42.HueApi/Models/Rule.cs | 27 +++---- src/Q42.HueApi/Models/Scene.cs | 39 ++++------ src/Q42.HueApi/Models/SceneCommand.cs | 9 +-- src/Q42.HueApi/Models/Schedule/Schedule.cs | 17 ++-- .../Models/Sensors/GeneralSensor.cs | 4 - .../Models/Sensors/ZigBee/ZGPSwitch.cs | 7 -- .../Models/Sensors/ZigBee/ZLLPresence.cs | 7 -- .../Models/Sensors/ZigBee/ZLLSwitch.cs | 7 -- src/Q42.HueApi/Models/State.cs | 26 +++---- src/Q42.HueApi/Models/WhiteList.cs | 8 +- 25 files changed, 212 insertions(+), 320 deletions(-) diff --git a/src/Q42.HueApi/Models/Bridge/Bridge.cs b/src/Q42.HueApi/Models/Bridge/Bridge.cs index 9addd7c8..38707c46 100644 --- a/src/Q42.HueApi/Models/Bridge/Bridge.cs +++ b/src/Q42.HueApi/Models/Bridge/Bridge.cs @@ -1,10 +1,8 @@ -using Q42.HueApi.Models; using Q42.HueApi.Models.Groups; using System; using System.Collections.Generic; using System.Linq; using System.Text; -using System.Threading.Tasks; namespace Q42.HueApi { diff --git a/src/Q42.HueApi/Models/Bridge/BridgeConfig.cs b/src/Q42.HueApi/Models/Bridge/BridgeConfig.cs index ee8a7ba3..ae1c98c2 100644 --- a/src/Q42.HueApi/Models/Bridge/BridgeConfig.cs +++ b/src/Q42.HueApi/Models/Bridge/BridgeConfig.cs @@ -1,15 +1,11 @@ -using System.Runtime.Serialization; using Newtonsoft.Json; -using Newtonsoft.Json.Converters; using System.Collections.Generic; -using Q42.HueApi.Models; using System; using Q42.HueApi.Models.Bridge; using Q42.HueApi.Converters; namespace Q42.HueApi { - [DataContract] public class BridgeConfig { @@ -18,103 +14,103 @@ public BridgeConfig() WhiteList = new Dictionary(); } - [DataMember(Name = "name")] + [JsonProperty("name")] public string Name { get; set; } - [DataMember(Name = "mac")] + [JsonProperty("mac")] public string MacAddress { get; set; } - [DataMember(Name = "dhcp")] + [JsonProperty("dhcp")] public bool Dhcp { get; set; } - [DataMember(Name = "ipaddress")] + [JsonProperty("ipaddress")] public string IpAddress { get; set; } - [DataMember(Name = "netmask")] + [JsonProperty("netmask")] public string NetMask { get; set; } - [DataMember(Name = "gateway")] + [JsonProperty("gateway")] public string Gateway { get; set; } - [DataMember(Name = "UTC")] + [JsonProperty("UTC")] [JsonConverter(typeof(NullableDateTimeConverter))] public DateTime? Utc { get; set; } - [DataMember(Name = "swversion")] + [JsonProperty("swversion")] public string SoftwareVersion { get; set; } [Obsolete] - [DataMember(Name = "swupdate")] + [JsonProperty("swupdate")] public SoftwareUpdate SoftwareUpdate { get; set; } - [DataMember(Name = "swupdate2")] + [JsonProperty("swupdate2")] public SoftwareUpdate2 SoftwareUpdate2 { get; set; } - [DataMember(Name = "whitelist")] + [JsonProperty("whitelist")] public IDictionary WhiteList { get; set; } - [DataMember(Name = "linkbutton")] + [JsonProperty("linkbutton")] public bool LinkButton { get; set; } - [DataMember(Name = "portalservices")] + [JsonProperty("portalservices")] public bool PortalServices { get; set; } - [DataMember(Name = "portalconnection")] + [JsonProperty("portalconnection")] public string PortalConnection { get; set; } - [DataMember(Name = "apiversion")] + [JsonProperty("apiversion")] public string ApiVersion { get; set; } - [DataMember(Name = "localtime")] + [JsonProperty("localtime")] [JsonConverter(typeof(NullableDateTimeConverter))] public DateTime? LocalTime { get; set; } - [DataMember(Name = "timezone")] + [JsonProperty("timezone")] public string TimeZone { get; set; } - [DataMember(Name = "portalstate")] + [JsonProperty("portalstate")] public PortalState PortalState { get; set; } - [DataMember(Name = "zigbeechannel")] + [JsonProperty("zigbeechannel")] public int ZigbeeChannel { get; set; } /// /// Perform a touchlink action if set to true, setting to false is ignored. When set to true a touchlink procedure starts which adds the closet lamp (within range) to the ZigBee network. You can then search for new lights and lamp will show up in the bridge. /// - [DataMember(Name = "touchlink")] + [JsonProperty("touchlink")] public bool TouchLink { get; set; } /// /// Indicates if bridge settings are factory new. /// - [DataMember(Name = "factorynew")] + [JsonProperty("factorynew")] public bool FactoryNew { get; set; } /// /// If a bridge backup file has been restored on this bridge from a bridge with a different bridgeid, it will indicate that bridge id, otherwise it will be null. /// - [DataMember(Name = "replacesbridgeid")] + [JsonProperty("replacesbridgeid")] public string ReplacesBridgeId { get; set; } /// /// This parameter uniquely identifies the hardware model of the bridge (BSB001, BSB002). /// - [DataMember(Name = "modelid")] + [JsonProperty("modelid")] public string ModelId { get; set; } /// /// The unique bridge id. This is currently generated from the bridge Ethernet mac address. /// - [DataMember(Name = "bridgeid")] + [JsonProperty("bridgeid")] public string BridgeId { get; set; } - [DataMember(Name = "datastoreversion")] + [JsonProperty("datastoreversion")] public string DataStoreVersion { get; set; } - [DataMember(Name = "starterkitid")] + [JsonProperty("starterkitid")] public string StarterKitId { get; set; } - [DataMember(Name = "internetservices")] + [JsonProperty("internetservices")] public InternetServices InternetServices { get; set; } } diff --git a/src/Q42.HueApi/Models/Bridge/BridgeConfigUpdate.cs b/src/Q42.HueApi/Models/Bridge/BridgeConfigUpdate.cs index 0a25cf59..9f4a2ae8 100644 --- a/src/Q42.HueApi/Models/Bridge/BridgeConfigUpdate.cs +++ b/src/Q42.HueApi/Models/Bridge/BridgeConfigUpdate.cs @@ -1,7 +1,4 @@ -using System.Runtime.Serialization; using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using System.Collections.Generic; using System; namespace Q42.HueApi @@ -9,51 +6,50 @@ namespace Q42.HueApi /// /// Allowed properties to update the BridgeConfig /// - [DataContract] public class BridgeConfigUpdate { - [DataMember(Name = "name")] + [JsonProperty("name")] public string Name { get; set; } - [DataMember(Name = "dhcp")] + [JsonProperty("dhcp")] public bool? Dhcp { get; set; } - [DataMember(Name = "ipaddress")] + [JsonProperty("ipaddress")] public string IpAddress { get; set; } - [DataMember(Name = "netmask")] + [JsonProperty("netmask")] public string NetMask { get; set; } - [DataMember(Name = "gateway")] + [JsonProperty("gateway")] public string Gateway { get; set; } [Obsolete] - [DataMember(Name = "swupdate")] + [JsonProperty("swupdate")] public SoftwareUpdate SoftwareUpdate { get; set; } - [DataMember(Name = "swupdate2")] + [JsonProperty("swupdate2")] public SoftwareUpdate2 SoftwareUpdate2 { get; set; } - [DataMember(Name = "linkbutton")] + [JsonProperty("linkbutton")] public bool? LinkButton { get; set; } - [DataMember(Name = "portalservices")] + [JsonProperty("portalservices")] public bool? PortalServices { get; set; } - [DataMember(Name = "timezone")] + [JsonProperty("timezone")] public string TimeZone { get; set; } /// /// As of 1.9. If set to true performs a touchlink action. /// - [DataMember(Name = "touchlink")] + [JsonProperty("touchlink")] public bool? TouchLink { get; set; } /// /// The current wireless frequency channel used by the bridge. It can take values of 11, 15, 20,25 or 0 if undefined (factory new). /// - [DataMember(Name = "zigbeechannel")] + [JsonProperty("zigbeechannel")] public int? ZigbeeChannel { get; set; } } -} \ No newline at end of file +} diff --git a/src/Q42.HueApi/Models/Bridge/InternetServices.cs b/src/Q42.HueApi/Models/Bridge/InternetServices.cs index 21166170..9e704577 100644 --- a/src/Q42.HueApi/Models/Bridge/InternetServices.cs +++ b/src/Q42.HueApi/Models/Bridge/InternetServices.cs @@ -1,13 +1,11 @@ -using Newtonsoft.Json; +using Newtonsoft.Json; using Newtonsoft.Json.Converters; using System; -using System.Collections.Generic; using System.Runtime.Serialization; using System.Text; namespace Q42.HueApi.Models.Bridge { - [DataContract] public class InternetServices { /// @@ -15,7 +13,7 @@ public class InternetServices /// Disconnected: If remoteaccess is unavailable, reasons can be portalservices are false or no remote connection is available. /// [JsonConverter(typeof(StringEnumConverter))] - [DataMember(Name = "remoteaccess")] + [JsonProperty("remoteaccess")] public InternetServicesState RemoteAccess { get; set; } /// @@ -23,7 +21,7 @@ public class InternetServices /// Disconnected: Bridge cannot reach the Internet. /// [JsonConverter(typeof(StringEnumConverter))] - [DataMember(Name = "internet")] + [JsonProperty("internet")] public InternetServicesState Internet { get; set; } /// @@ -31,7 +29,7 @@ public class InternetServices /// Disconnected: Internet time service was not reachable for 48hrs. /// [JsonConverter(typeof(StringEnumConverter))] - [DataMember(Name = "time")] + [JsonProperty("time")] public InternetServicesState Time { get; set; } /// @@ -39,7 +37,7 @@ public class InternetServices /// Disconnected: swupdate server was not reachable in the last 24 hrs. /// [JsonConverter(typeof(StringEnumConverter))] - [DataMember(Name = "swupdate")] + [JsonProperty("swupdate")] public InternetServicesState SWUpdate { get; set; } } diff --git a/src/Q42.HueApi/Models/Bridge/PortalState.cs b/src/Q42.HueApi/Models/Bridge/PortalState.cs index 572c8d23..a00d5f1c 100644 --- a/src/Q42.HueApi/Models/Bridge/PortalState.cs +++ b/src/Q42.HueApi/Models/Bridge/PortalState.cs @@ -1,20 +1,19 @@ -using System.Runtime.Serialization; +using Newtonsoft.Json; namespace Q42.HueApi { - [DataContract] public class PortalState { - [DataMember(Name = "signedon")] + [JsonProperty("signedon")] public bool SignedOn { get; set; } - [DataMember(Name = "incoming")] + [JsonProperty("incoming")] public bool Incoming { get; set; } - [DataMember(Name = "outgoing")] + [JsonProperty("outgoing")] public bool Outgoing { get; set; } - [DataMember(Name = "communication")] + [JsonProperty("communication")] public string Communication { get; set; } } -} \ No newline at end of file +} diff --git a/src/Q42.HueApi/Models/Bridge/SoftwareUpdate.cs b/src/Q42.HueApi/Models/Bridge/SoftwareUpdate.cs index 96be879e..299cba05 100644 --- a/src/Q42.HueApi/Models/Bridge/SoftwareUpdate.cs +++ b/src/Q42.HueApi/Models/Bridge/SoftwareUpdate.cs @@ -1,11 +1,10 @@ -using System; +using Newtonsoft.Json; +using System; using System.Collections.Generic; -using System.Runtime.Serialization; namespace Q42.HueApi { [Obsolete] - [DataContract] public class SoftwareUpdate { /// @@ -15,41 +14,40 @@ public class SoftwareUpdate /// 3 means apply/applying the update. /// http://www.everyhue.com/vanilla/discussion/484/firmware-update-triggering /// - [DataMember (Name = "updatestate")] + [JsonProperty("updatestate")] public int? UpdateState { get; set; } - [DataMember (Name = "url")] + [JsonProperty("url")] public string Url { get; set; } - [DataMember (Name = "text")] + [JsonProperty("text")] public string Text { get; set; } - [DataMember (Name = "notify")] + [JsonProperty("notify")] public bool? Notify { get; set; } /// /// Setting this flag to true lets the bridge search for software updates in the portal. After the search attempt, this flag is set back to false. Requires portal connection to update server /// http://www.developers.meethue.com/documentation/software-update /// - [DataMember(Name = "checkforupdate")] + [JsonProperty("checkforupdate")] public bool CheckForUpdate { get; set; } - [DataMember(Name = "devicetypes")] + [JsonProperty("devicetypes")] public SoftwareUpdateDevices DeviceTypes { get; set; } } [Obsolete] - [DataContract] public class SoftwareUpdateDevices { - [DataMember(Name = "bridge")] + [JsonProperty("bridge")] public bool Bridge { get; set; } - [DataMember(Name = "lights")] + [JsonProperty("lights")] public IReadOnlyCollection Lights { get; set; } - [DataMember(Name = "sensors")] + [JsonProperty("sensors")] public IReadOnlyCollection Sensors { get; set; } } -} \ No newline at end of file +} diff --git a/src/Q42.HueApi/Models/Bridge/SoftwareUpdate2.cs b/src/Q42.HueApi/Models/Bridge/SoftwareUpdate2.cs index 51cf5bff..6debc41d 100644 --- a/src/Q42.HueApi/Models/Bridge/SoftwareUpdate2.cs +++ b/src/Q42.HueApi/Models/Bridge/SoftwareUpdate2.cs @@ -7,70 +7,67 @@ namespace Q42.HueApi { - [DataContract] public class SoftwareUpdate2 { /// /// Setting this flag to true lets the bridge search for software updates in the portal. After the search attempt, this flag is set back to false. Requires portal connection to update server /// http://www.developers.meethue.com/documentation/software-update /// - [DataMember(Name = "checkforupdate")] + [JsonProperty("checkforupdate")] public bool CheckForUpdate { get; set; } [JsonConverter(typeof(StringEnumConverter))] - [DataMember(Name = "state")] + [JsonProperty("state")] public SoftwareUpdateState State { get; set; } /// /// Writing “true” triggers installation of software updates when in state anyreadytoinstall or allreadytoinstall. /// - [DataMember(Name = "install")] + [JsonProperty("install")] public bool? Install { get; set; } /// /// Timestamp of last change in system configuration /// - [DataMember(Name = "lastchange")] + [JsonProperty("lastchange")] [JsonConverter(typeof(NullableDateTimeConverter))] public DateTimeOffset? LastChange { get; set; } - [DataMember(Name = "autoinstall")] + [JsonProperty("autoinstall")] public SoftwareUpdateAutoInstall AutoInstall { get; set; } - [DataMember(Name = "bridge")] + [JsonProperty("bridge")] public SoftwareUpdateBridge Bridge { get; set; } } - [DataContract] public class SoftwareUpdateBridge { /// /// Time of last software update. /// - [DataMember(Name = "lastinstall")] + [JsonProperty("lastinstall")] [JsonConverter(typeof(NullableDateTimeConverter))] public DateTimeOffset? LastInstall { get; set; } [JsonConverter(typeof(StringEnumConverter))] - [DataMember(Name = "state")] + [JsonProperty("state")] public SoftwareUpdateState State { get; set; } } - [DataContract] public class SoftwareUpdateAutoInstall { /// /// Indicates if automatic update is activated. Default is false /// - [DataMember(Name = "on")] + [JsonProperty("on")] public bool? On { get; set; } /// /// T[hh]:[mm]:[ss] Local time of day. /// The bridge auto. updates for bridge and zigbee devices. The installation time will be randomized between updatetime and updatetime+T01:00:00. Default is T14:00:00. /// - [DataMember(Name = "updatetime")] + [JsonProperty("updatetime")] public string UpdateTime { get; set; } } diff --git a/src/Q42.HueApi/Models/Groups/CreateGroupRequest.cs b/src/Q42.HueApi/Models/Groups/CreateGroupRequest.cs index 793511d1..85880905 100644 --- a/src/Q42.HueApi/Models/Groups/CreateGroupRequest.cs +++ b/src/Q42.HueApi/Models/Groups/CreateGroupRequest.cs @@ -1,15 +1,8 @@ using Newtonsoft.Json; using Newtonsoft.Json.Converters; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Runtime.Serialization; -using System.Text; -using System.Threading.Tasks; namespace Q42.HueApi.Models.Groups { - [DataContract] internal class CreateGroupRequest : UpdateGroupRequest { @@ -17,7 +10,7 @@ internal class CreateGroupRequest : UpdateGroupRequest /// Luminaire / Lightsource / LightGroup /// [JsonConverter(typeof(StringEnumConverter))] - [DataMember(Name = "type")] + [JsonProperty("type")] public GroupType Type { get; set; } } diff --git a/src/Q42.HueApi/Models/Groups/Group.cs b/src/Q42.HueApi/Models/Groups/Group.cs index 3055b596..2f1f296f 100644 --- a/src/Q42.HueApi/Models/Groups/Group.cs +++ b/src/Q42.HueApi/Models/Groups/Group.cs @@ -3,73 +3,68 @@ using Q42.HueApi.Converters; using System; using System.Collections.Generic; -using System.Diagnostics; -using System.Linq; using System.Runtime.Serialization; -using System.Text; -using System.Threading.Tasks; namespace Q42.HueApi.Models.Groups { - [DataContract] public class Group { public string Id { get; set; } - [DataMember(Name = "name")] + [JsonProperty("name")] public string Name { get; set; } /// /// Luminaire / Lightsource / LightGroup /// [JsonConverter(typeof(StringNullableEnumConverter))] - [DataMember(Name = "type")] + [JsonProperty("type")] public GroupType? Type { get; set; } /// /// Category of the Room type. Default is "Other". /// [JsonConverter(typeof(StringNullableEnumConverter))] - [DataMember(Name = "class")] + [JsonProperty("class")] public RoomClass? Class { get; set; } /// /// As of 1.4. Uniquely identifies the hardware model of the luminaire. Only present for automatically created Luminaires. /// - [DataMember(Name = "modelid")] + [JsonProperty("modelid")] public string ModelId { get; set; } /// /// The IDs of the lights that are in the group. /// - [DataMember(Name = "lights")] + [JsonProperty("lights")] public List Lights { get; set; } /// /// The light state of one of the lamps in the group. /// - [DataMember(Name = "action")] + [JsonProperty("action")] public State Action { get; set; } - [DataMember(Name = "state")] + [JsonProperty("state")] public GroupState State { get; set; } - [DataMember(Name = "locations")] + [JsonProperty("locations")] public Dictionary Locations { get; set; } - [DataMember(Name = "recycle")] + [JsonProperty("recycle")] public bool? Recycle { get; set; } - [DataMember(Name = "stream")] + [JsonProperty("stream")] public Stream Stream { get; set; } - [DataMember(Name = "sensors")] + [JsonProperty("sensors")] public List Sensors { get; set; } - [DataMember(Name = "presence")] + [JsonProperty("presence")] public GroupPresence Presence { get; set; } - [DataMember(Name = "lightlevel")] + [JsonProperty("lightlevel")] public GroupLightLevel LightLevel { get; set; } /// @@ -84,7 +79,7 @@ public override string ToString() public class GroupPresence { - [DataMember(Name = "State")] + [JsonProperty("State")] public State State { get; set; } [JsonProperty("lastupdated")] @@ -100,7 +95,7 @@ public class GroupPresence public class GroupLightLevel { - [DataMember(Name = "State")] + [JsonProperty("State")] public SensorState State { get; set; } [JsonProperty("lastupdated")] @@ -198,13 +193,12 @@ public double Angle(double x, double y) } - [DataContract] public class GroupState { - [DataMember(Name = "any_on")] + [JsonProperty("any_on")] public bool? AnyOn { get; set; } - [DataMember(Name = "all_on")] + [JsonProperty("all_on")] public bool? AllOn { get; set; } } @@ -315,16 +309,15 @@ public enum RoomClass Pool } - [DataContract] public class Stream { - [DataMember(Name = "proxymode")] + [JsonProperty("proxymode")] public string ProxyMode { get; set; } - [DataMember(Name = "proxynode")] + [JsonProperty("proxynode")] public string ProxyNode { get; set; } - [DataMember(Name = "active")] + [JsonProperty("active")] public bool Active { get; set; } - [DataMember(Name = "owner")] + [JsonProperty("owner")] public string Owner { get; set; } } diff --git a/src/Q42.HueApi/Models/Groups/UpdateGroupRequest.cs b/src/Q42.HueApi/Models/Groups/UpdateGroupRequest.cs index 3a859613..3e592c29 100644 --- a/src/Q42.HueApi/Models/Groups/UpdateGroupRequest.cs +++ b/src/Q42.HueApi/Models/Groups/UpdateGroupRequest.cs @@ -2,30 +2,25 @@ using Newtonsoft.Json.Converters; using System; using System.Collections.Generic; -using System.Linq; -using System.Runtime.Serialization; -using System.Text; -using System.Threading.Tasks; namespace Q42.HueApi.Models.Groups { - [DataContract] internal class UpdateGroupRequest { - [DataMember(Name = "name")] + [JsonProperty("name")] public string Name { get; set; } /// /// The IDs of the lights that are in the group. /// - [DataMember(Name = "lights")] + [JsonProperty("lights")] public IEnumerable Lights { get; set; } /// /// Category of the Room type. Default is "Other". /// [JsonConverter(typeof(StringEnumConverter))] - [DataMember(Name = "class")] + [JsonProperty("class")] public RoomClass? Class { get; set; } } } diff --git a/src/Q42.HueApi/Models/InternalBridgeCommand.cs b/src/Q42.HueApi/Models/InternalBridgeCommand.cs index 5e8f9ff7..b18867fe 100644 --- a/src/Q42.HueApi/Models/InternalBridgeCommand.cs +++ b/src/Q42.HueApi/Models/InternalBridgeCommand.cs @@ -2,28 +2,22 @@ using Newtonsoft.Json.Converters; using Q42.HueApi.Converters; using Q42.HueApi.Interfaces; -using System; -using System.Collections.Generic; -using System.Linq; using System.Net.Http; using System.Runtime.Serialization; -using System.Text; -using System.Threading.Tasks; namespace Q42.HueApi.Models { - [DataContract] public class InternalBridgeCommand { - [DataMember(Name = "address")] + [JsonProperty("address")] public string Address { get; set; } [JsonConverter(typeof(HttpMethodConverter))] - [DataMember(Name = "method")] + [JsonProperty("method")] public HttpMethod Method { get; set; } [JsonConverter(typeof(CommandBodyConverter))] - [DataMember(Name = "body")] + [JsonProperty("body")] public ICommandBody Body { get; set; } [OnDeserialized] diff --git a/src/Q42.HueApi/Models/Light.cs b/src/Q42.HueApi/Models/Light.cs index 57a3fd88..696b1689 100644 --- a/src/Q42.HueApi/Models/Light.cs +++ b/src/Q42.HueApi/Models/Light.cs @@ -2,59 +2,57 @@ using Newtonsoft.Json.Converters; using Q42.HueApi.Models.Gamut; using System; -using System.Collections.Generic; using System.Runtime.Serialization; namespace Q42.HueApi { - [DataContract] public class Light { public string Id { get; set; } - [DataMember(Name = "state")] + [JsonProperty("state")] public State State { get; set; } - [DataMember(Name = "type")] + [JsonProperty("type")] public string Type { get; set; } - [DataMember(Name = "name")] + [JsonProperty("name")] public string Name { get; set; } - [DataMember(Name = "modelid")] + [JsonProperty("modelid")] public string ModelId { get; set; } - [DataMember(Name = "productid")] + [JsonProperty("productid")] public string ProductId { get; set; } - [DataMember(Name = "swconfigid")] + [JsonProperty("swconfigid")] public string SwConfigId { get; set; } /// /// Unique id of the device. The MAC address of the device with a unique endpoint id in the form: AA:BB:CC:DD:EE:FF:00:11-XX /// - [DataMember(Name = "uniqueid")] + [JsonProperty("uniqueid")] public string UniqueId { get; set; } /// /// As of 1.9. Unique ID of the luminaire the light is a part of in the format: AA:BB:CC:DD-XX-YY. AA:BB:, ... represents the hex of the luminaireid, XX the lightsource position (incremental but may contain gaps) and YY the lightpoint position (index of light in luminaire group). A gap in the lightpoint position indicates an incomplete luminaire (light search required to discover missing light points in this case). /// - [DataMember(Name = "luminaireuniqueid")] + [JsonProperty("luminaireuniqueid")] public string LuminaireUniqueId { get; set; } - [DataMember(Name = "manufacturername")] + [JsonProperty("manufacturername")] public string ManufacturerName { get; set; } - [DataMember(Name = "swversion")] + [JsonProperty("swversion")] public string SoftwareVersion { get; set; } - [DataMember(Name = "capabilities")] + [JsonProperty("capabilities")] public LightCapabilities Capabilities { get; set; } - [DataMember(Name = "config")] + [JsonProperty("config")] public LightConfig Config { get; set; } - [DataMember(Name = "swupdate")] + [JsonProperty("swupdate")] public SwUpdate SwUpdate { get; set; } /// @@ -67,99 +65,92 @@ public override string ToString() } } - [DataContract] public class SwUpdate { - [DataMember(Name = "state")] + [JsonProperty("state")] public string State { get; set; } - [DataMember(Name = "lastinstall")] + [JsonProperty("lastinstall")] public DateTime? Lastinstall { get; set; } } - [DataContract] public class StreamingLightCapabilities { - [DataMember(Name = "renderer")] + [JsonProperty("renderer")] public bool Renderer { get; set; } - [DataMember(Name = "proxy")] + [JsonProperty("proxy")] public bool Proxy { get; set; } } - [DataContract] public class LightCapabilities { - [DataMember(Name = "certified")] + [JsonProperty("certified")] public bool Certified { get; set; } - [DataMember(Name = "control")] + [JsonProperty("control")] public Control Control { get; set; } - [DataMember(Name = "streaming")] + [JsonProperty("streaming")] public StreamingLightCapabilities Streaming { get; set; } } - [DataContract] public class Control { - [DataMember(Name = "mindimlevel")] + [JsonProperty("mindimlevel")] public int? MinDimLevel { get; set; } - [DataMember(Name = "maxlumen")] + [JsonProperty("maxlumen")] public int? MaxLumen { get; set; } /// /// A, B or C /// - [DataMember(Name = "colorgamuttype")] + [JsonProperty("colorgamuttype")] public string ColorGamutType { get; set; } - [DataMember(Name = "colorgamut")] + [JsonProperty("colorgamut")] public CIE1931Gamut? ColorGamut { get; set; } - [DataMember(Name = "ct")] + [JsonProperty("ct")] public ColorTemperature ColorTemperature { get; set; } } - [DataContract] public class ColorTemperature { - [DataMember(Name = "min")] + [JsonProperty("min")] public int Min { get; set; } - [DataMember(Name = "max")] + [JsonProperty("max")] public int Max { get; set; } } - [DataContract] public class LightConfig { - [DataMember(Name = "archetype")] + [JsonProperty("archetype")] public string ArcheType { get; set; } - [DataMember(Name = "function")] + [JsonProperty("function")] public string Function { get; set; } - [DataMember(Name = "direction")] + [JsonProperty("direction")] public string Direction { get; set; } - [DataMember(Name = "startup")] + [JsonProperty("startup")] public LightStartup Startup { get; set; } } - [DataContract] public class LightStartup { - [DataMember(Name = "mode")] + [JsonProperty("mode")] [JsonConverter(typeof(StringEnumConverter))] public StartupMode? Mode { get; set; } - [DataMember(Name = "configured")] + [JsonProperty("configured")] public bool? Configured { get; set; } /// /// Only bri, xy, ct properties are used /// - [DataMember(Name = "customsettings")] + [JsonProperty("customsettings")] public LightCommand CustomSettings { get; set; } } diff --git a/src/Q42.HueApi/Models/LightCommand.cs b/src/Q42.HueApi/Models/LightCommand.cs index 27891c9d..4e89531b 100644 --- a/src/Q42.HueApi/Models/LightCommand.cs +++ b/src/Q42.HueApi/Models/LightCommand.cs @@ -1,5 +1,4 @@ using System; -using System.Globalization; using System.Runtime.Serialization; using Newtonsoft.Json; using Newtonsoft.Json.Converters; @@ -12,63 +11,62 @@ namespace Q42.HueApi /// /// Compose a light command to send to a light /// - [DataContract] public class LightCommand : ICommandBody { /// /// Gets or sets the colors based on CIE 1931 Color coordinates. /// - [DataMember (Name = "xy")] + [JsonProperty("xy")] public double[] ColorCoordinates { get; set; } /// /// Gets or sets the brightness 0-255. /// - [DataMember (Name = "bri")] + [JsonProperty("bri")] public byte? Brightness { get; set; } /// /// Gets or sets the hue for Hue and mode. /// - [DataMember (Name = "hue")] + [JsonProperty("hue")] public int? Hue { get; set; } /// /// Gets or sets the saturation for and Saturation mode. /// - [DataMember (Name = "sat")] + [JsonProperty("sat")] public int? Saturation { get; set; } /// /// Gets or sets the Color Temperature /// - [DataMember (Name = "ct")] + [JsonProperty("ct")] public int? ColorTemperature { get; set; } /// /// Gets or sets whether the light is on. /// - [DataMember (Name = "on")] + [JsonProperty("on")] public bool? On { get; set; } /// /// Gets or sets the current effect for the light. /// [JsonConverter(typeof(StringEnumConverter))] - [DataMember (Name = "effect")] + [JsonProperty("effect")] public Effect? Effect { get; set; } /// /// Gets or sets the current alert for the light. /// [JsonConverter(typeof(StringEnumConverter))] - [DataMember (Name = "alert")] + [JsonProperty("alert")] public Alert? Alert { get; set; } /// /// Gets or sets the transition time for the light. /// - [DataMember (Name = "transitiontime")] + [JsonProperty("transitiontime")] [JsonConverter (typeof(TransitionTimeConverter))] public TimeSpan? TransitionTime { get; set; } @@ -76,35 +74,35 @@ public class LightCommand : ICommandBody /// -254 to 254 /// As of 1.7. Increments or decrements the value of the brightness. bri_inc is ignored if the bri attribute is provided. Any ongoing bri transition is stopped. Setting a value of 0 also stops any ongoing transition. The bridge will return the bri value after the increment is performed. /// - [DataMember(Name = "bri_inc")] + [JsonProperty("bri_inc")] public int? BrightnessIncrement { get; set; } /// /// -254 to 254 /// As of 1.7. Increments or decrements the value of the sat. sat_inc is ignored if the sat attribute is provided. Any ongoing sat transition is stopped. Setting a value of 0 also stops any ongoing transition. The bridge will return the sat value after the increment is performed. /// - [DataMember(Name = "sat_inc")] + [JsonProperty("sat_inc")] public int? SaturationIncrement { get; set; } /// /// -65534 to 65534 /// As of 1.7. Increments or decrements the value of the hue. hue_inc is ignored if the hue attribute is provided. Any ongoing color transition is stopped. Setting a value of 0 also stops any ongoing transition. The bridge will return the hue value after the increment is performed. /// - [DataMember(Name = "hue_inc")] + [JsonProperty("hue_inc")] public int? HueIncrement { get; set; } /// /// -65534 to 65534 /// As of 1.7. Increments or decrements the value of the ct. ct_inc is ignored if the ct attribute is provided. Any ongoing color transition is stopped. Setting a value of 0 also stops any ongoing transition. The bridge will return the ct value after the increment is performed. /// - [DataMember(Name = "ct_inc")] + [JsonProperty("ct_inc")] public int? ColorTemperatureIncrement { get; set; } /// /// -0.5 to 0.5 /// As of 1.7. Increments or decrements the value of the xy. xy_inc is ignored if the xy attribute is provided. Any ongoing color transition is stopped. Will stop at it's gamut boundaries. Setting a value of 0 also stops any ongoing transition. The bridge will return the xy value after the increment is performed. /// - [DataMember(Name = "xy_inc")] + [JsonProperty("xy_inc")] public double[]? ColorCoordinatesIncrement { get; set; } } diff --git a/src/Q42.HueApi/Models/LightUpdate.cs b/src/Q42.HueApi/Models/LightUpdate.cs index 019f1872..144f045f 100644 --- a/src/Q42.HueApi/Models/LightUpdate.cs +++ b/src/Q42.HueApi/Models/LightUpdate.cs @@ -1,14 +1,10 @@ -using System; -using System.Collections.Generic; -using System.Runtime.Serialization; -using System.Text; +using Newtonsoft.Json; namespace Q42.HueApi.Models { - [DataContract] public class LightConfigUpdate { - [DataMember(Name = "startup")] + [JsonProperty("startup")] public LightStartup Startup { get; set; } } diff --git a/src/Q42.HueApi/Models/ResourceLink.cs b/src/Q42.HueApi/Models/ResourceLink.cs index 4a5570fa..051c0e11 100644 --- a/src/Q42.HueApi/Models/ResourceLink.cs +++ b/src/Q42.HueApi/Models/ResourceLink.cs @@ -1,13 +1,8 @@ -using System; +using Newtonsoft.Json; using System.Collections.Generic; -using System.Linq; -using System.Runtime.Serialization; -using System.Text; -using System.Threading.Tasks; namespace Q42.HueApi.Models { - [DataContract] public class ResourceLink { public ResourceLink() @@ -20,44 +15,44 @@ public ResourceLink() /// /// Human readable name for this resourcelink /// - [DataMember(Name = "name")] + [JsonProperty("name")] public string Name { get; set; } /// /// Human readable description of what this resourcelink does. If not specified it's set to "". /// - [DataMember(Name = "description")] + [JsonProperty("description")] public string Description { get; set; } /// /// Not writeable and there is only 1 type: "Link" /// - [DataMember(Name = "type")] + [JsonProperty("type")] public string Type { get; set; } /// /// Class of resourcelink given by application. The resourcelink class can be used to identify resourcelink with the same purpose, like classid 1 for wake-up, 2 for going to sleep, etc. (best practice use range 1 - 10000) /// - [DataMember(Name = "classid")] + [JsonProperty("classid")] public int ClassId { get; set; } /// /// Not writeable, this respresents the owner (username) of the creator of the resourcelink /// - [DataMember(Name = "owner")] + [JsonProperty("owner")] public string Owner { get; set; } /// /// When true: Resource is automatically deleted when not referenced anymore in any resource link. Only on creation of resourcelink. "false" when omitted. /// - [DataMember(Name = "recycle")] + [JsonProperty("recycle")] public bool? Recycle { get; set; } /// /// References to resources which are used by this resourcelink resource. In case the referenced resource was created with "recycle":true and no other references are present, the resourcelink resource will be automatically deleted when removed when empty. /// Allowed resources paths(given as ASCII String with pattern: "//": /// - [DataMember(Name = "links")] + [JsonProperty("links")] public List Links { get; set; } } diff --git a/src/Q42.HueApi/Models/Rule.cs b/src/Q42.HueApi/Models/Rule.cs index d8882d2f..586f25e9 100644 --- a/src/Q42.HueApi/Models/Rule.cs +++ b/src/Q42.HueApi/Models/Rule.cs @@ -3,56 +3,51 @@ using Q42.HueApi.Converters; using System; using System.Collections.Generic; -using System.Linq; using System.Runtime.Serialization; -using System.Text; -using System.Threading.Tasks; namespace Q42.HueApi.Models { - [DataContract] public class Rule { public string Id { get; set; } - [DataMember(Name = "Name")] + [JsonProperty("Name")] public string Name { get; set; } - [DataMember(Name = "Lasttriggered")] + [JsonProperty("Lasttriggered")] [JsonConverter(typeof(NullableDateTimeConverter))] public DateTime? LastTriggered { get; set; } //Can be "none", so don't convert to DateTime - [DataMember(Name = "creationtime")] + [JsonProperty("creationtime")] [JsonConverter(typeof(NullableDateTimeConverter))] public DateTime? CreationTime { get; set; } - [DataMember(Name = "timestriggered")] + [JsonProperty("timestriggered")] public int TimesTriggered { get; set; } - [DataMember(Name = "owner")] + [JsonProperty("owner")] public string Owner { get; set; } - [DataMember(Name = "status")] + [JsonProperty("status")] public string Status { get; set; } - [DataMember(Name = "conditions")] + [JsonProperty("conditions")] public List Conditions { get; set; } - [DataMember(Name = "actions")] + [JsonProperty("actions")] public List Actions { get; set; } } - [DataContract] public class RuleCondition { - [DataMember(Name = "address")] + [JsonProperty("address")] public string Address { get; set; } [JsonConverter(typeof(StringEnumConverter))] - [DataMember(Name = "operator")] + [JsonProperty("operator")] public RuleOperator Operator { get; set; } - [DataMember(Name = "value")] + [JsonProperty("value")] public string Value { get; set; } } diff --git a/src/Q42.HueApi/Models/Scene.cs b/src/Q42.HueApi/Models/Scene.cs index 6f80e06d..0d17572f 100644 --- a/src/Q42.HueApi/Models/Scene.cs +++ b/src/Q42.HueApi/Models/Scene.cs @@ -3,89 +3,85 @@ using Q42.HueApi.Converters; using System; using System.Collections.Generic; -using System.Linq; using System.Runtime.Serialization; -using System.Text; -using System.Threading.Tasks; namespace Q42.HueApi.Models { - [DataContract] public class Scene { public string Id { get; set; } - [DataMember(Name = "name")] + [JsonProperty("name")] public string Name { get; set; } - [DataMember(Name = "lights")] + [JsonProperty("lights")] public IEnumerable Lights { get; set; } /// /// Whitelist user that created or modified the content of the scene. Note that changing name does not change the owner. /// - [DataMember(Name = "owner")] + [JsonProperty("owner")] public string Owner { get; set; } /// /// App specific data linked to the scene. Each individual application should take responsibility for the data written in this field. /// - [DataMember(Name = "appdata")] + [JsonProperty("appdata")] public SceneAppData? AppData { get; set; } /// /// Only available on a GET of an individual scene resource (/api//scenes/). Not available for scenes created via a PUT in version 1. . Reserved for future use. /// - [DataMember(Name = "picture")] + [JsonProperty("picture")] public string? Picture { get; set; } /// /// Indicates whether the scene can be automatically deleted by the bridge. Only available by POSTSet to 'false' when omitted. Legacy scenes created by PUT are defaulted to true. When set to 'false' the bridge keeps the scene until deleted by an application. /// - [DataMember(Name = "recycle")] + [JsonProperty("recycle")] public bool? Recycle { get; set; } /// /// Indicates that the scene is locked by a rule or a schedule and cannot be deleted until all resources requiring or that reference the scene are deleted. /// - [DataMember(Name = "locked")] + [JsonProperty("locked")] public bool? Locked { get; set; } - [DataMember(Name = "version")] + [JsonProperty("version")] public int? Version { get; set; } - [DataMember(Name = "lastupdated")] + [JsonProperty("lastupdated")] [JsonConverter(typeof(NullableDateTimeConverter))] public DateTime? LastUpdated { get; set; } - [DataMember(Name = "storelightstate")] + [JsonProperty("storelightstate")] public bool? StoreLightState { get; set; } - [DataMember(Name = "transitiontime")] + [JsonProperty("transitiontime")] [JsonConverter(typeof(TransitionTimeConverter))] public TimeSpan? TransitionTime { get; set; } - [DataMember(Name = "lightstates")] + [JsonProperty("lightstates")] public Dictionary LightStates { get; set; } /// /// null defaults to LightScene /// - [DataMember(Name = "type")] + [JsonProperty("type")] [JsonConverter(typeof(StringEnumConverter))] public SceneType? Type { get; set; } /// /// When using SceneType.GroupScene: group ID that a scene is linked to. /// - [DataMember(Name = "group")] + [JsonProperty("group")] public string? Group { get; set; } /// /// 1.36 Unique ID for an image representing the scene. Only available for scenes create from Signify images by Hue application. /// - [DataMember(Name = "image")] + [JsonProperty("image")] public string? Image { get; set; } /// @@ -99,12 +95,11 @@ public override string ToString() } - [DataContract] public class SceneAppData { - [DataMember(Name = "version")] + [JsonProperty("version")] public int? Version { get; set; } - [DataMember(Name = "data")] + [JsonProperty("data")] public string Data { get; set; } } diff --git a/src/Q42.HueApi/Models/SceneCommand.cs b/src/Q42.HueApi/Models/SceneCommand.cs index f7a089d8..758196e8 100644 --- a/src/Q42.HueApi/Models/SceneCommand.cs +++ b/src/Q42.HueApi/Models/SceneCommand.cs @@ -1,8 +1,4 @@ -using System; -using System.Globalization; -using System.Runtime.Serialization; using Newtonsoft.Json; -using Newtonsoft.Json.Converters; using Q42.HueApi.Interfaces; namespace Q42.HueApi @@ -11,7 +7,6 @@ namespace Q42.HueApi /// /// Send a SceneID as command /// - [DataContract] public class SceneCommand : ICommandBody { public SceneCommand() @@ -27,10 +22,10 @@ public SceneCommand(string sceneId) /// /// Scene ID to activate /// - [DataMember(Name = "scene")] + [JsonProperty("scene")] public string Scene { get; set; } - [DataMember(Name = "storelightstate")] + [JsonProperty("storelightstate")] public bool? StoreLightState { get; set; } } diff --git a/src/Q42.HueApi/Models/Schedule/Schedule.cs b/src/Q42.HueApi/Models/Schedule/Schedule.cs index 70a29fc9..e080684e 100644 --- a/src/Q42.HueApi/Models/Schedule/Schedule.cs +++ b/src/Q42.HueApi/Models/Schedule/Schedule.cs @@ -6,32 +6,31 @@ namespace Q42.HueApi.Models { - [DataContract] public class Schedule { public string Id { get; set; } - [DataMember(Name = "name")] + [JsonProperty("name")] public string Name { get; set; } - [DataMember(Name = "description")] + [JsonProperty("description")] public string Description { get; set; } - [DataMember(Name = "command")] + [JsonProperty("command")] public InternalBridgeCommand Command { get; set; } - [DataMember(Name = "localtime")] + [JsonProperty("localtime")] [JsonConverter(typeof(HueDateTimeConverter))] public HueDateTime LocalTime { get; set; } - [DataMember(Name = "created")] + [JsonProperty("created")] [JsonConverter(typeof(NullableDateTimeConverter))] public DateTime? Created { get; set; } /// /// UTC time that the timer was started. Only provided for timers. /// - [DataMember(Name = "starttime")] + [JsonProperty("starttime")] [JsonConverter(typeof(NullableDateTimeConverter))] public DateTime? StartTime { get; set; } @@ -40,14 +39,14 @@ public class Schedule /// "disabled" Schedule is disabled by user. /// Application is only allowed to set “enabled” or “disabled”. Disabled causes a timer to reset when activated (i.e. stop & reset). “enabled” when not provided on creation. /// - [DataMember(Name = "status")] + [JsonProperty("status")] [JsonConverter(typeof(StringEnumConverter))] public ScheduleStatus? Status { get; set; } /// /// If set to true, the schedule will be removed automatically if expired, if set to false it will be disabled. Default is true /// - [DataMember(Name = "autodelete")] + [JsonProperty("autodelete")] public bool? AutoDelete { get; set; } } diff --git a/src/Q42.HueApi/Models/Sensors/GeneralSensor.cs b/src/Q42.HueApi/Models/Sensors/GeneralSensor.cs index 921b74d9..f9334051 100644 --- a/src/Q42.HueApi/Models/Sensors/GeneralSensor.cs +++ b/src/Q42.HueApi/Models/Sensors/GeneralSensor.cs @@ -1,9 +1,5 @@ using System; using System.Collections.Generic; -using System.Linq; -using System.Runtime.Serialization; -using System.Text; -using System.Threading.Tasks; namespace Q42.HueApi.Models.Sensors { diff --git a/src/Q42.HueApi/Models/Sensors/ZigBee/ZGPSwitch.cs b/src/Q42.HueApi/Models/Sensors/ZigBee/ZGPSwitch.cs index 65b242c1..76d5902b 100644 --- a/src/Q42.HueApi/Models/Sensors/ZigBee/ZGPSwitch.cs +++ b/src/Q42.HueApi/Models/Sensors/ZigBee/ZGPSwitch.cs @@ -1,10 +1,3 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Runtime.Serialization; -using System.Text; -using System.Threading.Tasks; - namespace Q42.HueApi.Models.Sensors.ZigBee { /// diff --git a/src/Q42.HueApi/Models/Sensors/ZigBee/ZLLPresence.cs b/src/Q42.HueApi/Models/Sensors/ZigBee/ZLLPresence.cs index ca558ac8..6c385539 100644 --- a/src/Q42.HueApi/Models/Sensors/ZigBee/ZLLPresence.cs +++ b/src/Q42.HueApi/Models/Sensors/ZigBee/ZLLPresence.cs @@ -1,10 +1,3 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Runtime.Serialization; -using System.Text; -using System.Threading.Tasks; - namespace Q42.HueApi.Models.Sensors.ZigBee { /// diff --git a/src/Q42.HueApi/Models/Sensors/ZigBee/ZLLSwitch.cs b/src/Q42.HueApi/Models/Sensors/ZigBee/ZLLSwitch.cs index 18b3bd73..4f158465 100644 --- a/src/Q42.HueApi/Models/Sensors/ZigBee/ZLLSwitch.cs +++ b/src/Q42.HueApi/Models/Sensors/ZigBee/ZLLSwitch.cs @@ -1,10 +1,3 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Runtime.Serialization; -using System.Text; -using System.Threading.Tasks; - namespace Q42.HueApi.Models.Sensors.ZigBee { /// diff --git a/src/Q42.HueApi/Models/State.cs b/src/Q42.HueApi/Models/State.cs index 4afabe83..46d92bd4 100644 --- a/src/Q42.HueApi/Models/State.cs +++ b/src/Q42.HueApi/Models/State.cs @@ -2,50 +2,48 @@ using Newtonsoft.Json.Converters; using Q42.HueApi.Converters; using System; -using System.Runtime.Serialization; namespace Q42.HueApi { - [DataContract] public class State { - [DataMember(Name = "on")] + [JsonProperty("on")] public bool On { get; set; } - [DataMember(Name = "bri")] + [JsonProperty("bri")] public byte Brightness { get; set; } - [DataMember(Name = "hue")] + [JsonProperty("hue")] public int? Hue { get; set; } - [DataMember(Name = "sat")] + [JsonProperty("sat")] public int? Saturation { get; set; } - [DataMember(Name = "xy")] + [JsonProperty("xy")] public double[] ColorCoordinates { get; set; } - [DataMember(Name = "ct")] + [JsonProperty("ct")] public int? ColorTemperature { get; set; } [JsonConverter(typeof(StringEnumConverter))] - [DataMember(Name = "alert")] + [JsonProperty("alert")] public Alert? Alert { get; set; } [JsonConverter(typeof(StringEnumConverter))] - [DataMember(Name = "effect")] + [JsonProperty("effect")] public Effect? Effect { get; set; } - [DataMember(Name = "colormode")] + [JsonProperty("colormode")] public string ColorMode { get; set; } - [DataMember(Name = "reachable")] + [JsonProperty("reachable")] public bool? IsReachable { get; set; } - [DataMember(Name = "transitiontime")] + [JsonProperty("transitiontime")] [JsonConverter(typeof(TransitionTimeConverter))] public TimeSpan? TransitionTime { get; set; } - [DataMember(Name = "mode")] + [JsonProperty("mode")] public string Mode { get; set; } diff --git a/src/Q42.HueApi/Models/WhiteList.cs b/src/Q42.HueApi/Models/WhiteList.cs index ab3a4319..9cef2401 100755 --- a/src/Q42.HueApi/Models/WhiteList.cs +++ b/src/Q42.HueApi/Models/WhiteList.cs @@ -1,24 +1,22 @@ using Newtonsoft.Json; using Q42.HueApi.Converters; using System; -using System.Runtime.Serialization; namespace Q42.HueApi { - [DataContract] public class WhiteList { public string Id { get; set; } - [DataMember(Name = "last use date")] + [JsonProperty("last use date")] [JsonConverter(typeof(NullableDateTimeConverter))] public DateTime? LastUsedDate { get; set; } - [DataMember(Name = "create date")] + [JsonProperty("create date")] [JsonConverter(typeof(NullableDateTimeConverter))] public DateTime? CreateDate { get; set; } - [DataMember(Name = "name")] + [JsonProperty("name")] public string Name { get; set; } } From 51e21d67cdb1163aef7a7f2a2ee73e65ecbe4f1f Mon Sep 17 00:00:00 2001 From: michielpost Date: Tue, 16 Feb 2021 10:43:59 +0100 Subject: [PATCH 2/2] Added StringEnumConverter on all enums --- src/Q42.HueApi/Models/Bridge/InternetServices.cs | 1 + src/Q42.HueApi/Models/Bridge/SoftwareUpdate2.cs | 1 + src/Q42.HueApi/Models/Groups/Group.cs | 7 ++++--- src/Q42.HueApi/Models/Light.cs | 1 + src/Q42.HueApi/Models/LightCommand.cs | 2 ++ src/Q42.HueApi/Models/Rule.cs | 1 + src/Q42.HueApi/Models/Scene.cs | 1 + src/Q42.HueApi/Models/Schedule/Schedule.cs | 1 + 8 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/Q42.HueApi/Models/Bridge/InternetServices.cs b/src/Q42.HueApi/Models/Bridge/InternetServices.cs index 9e704577..23d67bf0 100644 --- a/src/Q42.HueApi/Models/Bridge/InternetServices.cs +++ b/src/Q42.HueApi/Models/Bridge/InternetServices.cs @@ -44,6 +44,7 @@ public class InternetServices /// /// Possible InternetServices States /// + [JsonConverter(typeof(StringEnumConverter))] public enum InternetServicesState { [EnumMember(Value = "connected")] diff --git a/src/Q42.HueApi/Models/Bridge/SoftwareUpdate2.cs b/src/Q42.HueApi/Models/Bridge/SoftwareUpdate2.cs index 6debc41d..69a9311b 100644 --- a/src/Q42.HueApi/Models/Bridge/SoftwareUpdate2.cs +++ b/src/Q42.HueApi/Models/Bridge/SoftwareUpdate2.cs @@ -74,6 +74,7 @@ public class SoftwareUpdateAutoInstall /// /// Possible SoftwareUpdate States /// + [JsonConverter(typeof(StringEnumConverter))] public enum SoftwareUpdateState { [EnumMember(Value = "unknown")] diff --git a/src/Q42.HueApi/Models/Groups/Group.cs b/src/Q42.HueApi/Models/Groups/Group.cs index 2f1f296f..dfff804f 100644 --- a/src/Q42.HueApi/Models/Groups/Group.cs +++ b/src/Q42.HueApi/Models/Groups/Group.cs @@ -205,9 +205,9 @@ public class GroupState /// /// Possible group types /// - public enum GroupType + [JsonConverter(typeof(StringEnumConverter))] + public enum GroupType { - [EnumMember(Value = "LightGroup")] LightGroup, [EnumMember(Value = "Room")] @@ -225,7 +225,8 @@ public enum GroupType /// /// Possible room types /// - public enum RoomClass + [JsonConverter(typeof(StringEnumConverter))] + public enum RoomClass { [EnumMember(Value = "Other")] Other, diff --git a/src/Q42.HueApi/Models/Light.cs b/src/Q42.HueApi/Models/Light.cs index 696b1689..c5d36be6 100644 --- a/src/Q42.HueApi/Models/Light.cs +++ b/src/Q42.HueApi/Models/Light.cs @@ -157,6 +157,7 @@ public class LightStartup /// /// Defined on https://developers.meethue.com/develop/hue-api/supported-devices/ /// + [JsonConverter(typeof(StringEnumConverter))] public enum StartupMode { [EnumMember(Value = "safety")] diff --git a/src/Q42.HueApi/Models/LightCommand.cs b/src/Q42.HueApi/Models/LightCommand.cs index 4e89531b..fcc06b93 100644 --- a/src/Q42.HueApi/Models/LightCommand.cs +++ b/src/Q42.HueApi/Models/LightCommand.cs @@ -110,6 +110,7 @@ public class LightCommand : ICommandBody /// /// Possible light alerts /// + [JsonConverter(typeof(StringEnumConverter))] public enum Alert { /// @@ -134,6 +135,7 @@ public enum Alert /// /// Possible light effects /// + [JsonConverter(typeof(StringEnumConverter))] public enum Effect { /// diff --git a/src/Q42.HueApi/Models/Rule.cs b/src/Q42.HueApi/Models/Rule.cs index 586f25e9..c957c108 100644 --- a/src/Q42.HueApi/Models/Rule.cs +++ b/src/Q42.HueApi/Models/Rule.cs @@ -54,6 +54,7 @@ public class RuleCondition /// /// Possible light alerts /// + [JsonConverter(typeof(StringEnumConverter))] public enum RuleOperator { /// diff --git a/src/Q42.HueApi/Models/Scene.cs b/src/Q42.HueApi/Models/Scene.cs index 0d17572f..89ecc214 100644 --- a/src/Q42.HueApi/Models/Scene.cs +++ b/src/Q42.HueApi/Models/Scene.cs @@ -103,6 +103,7 @@ public class SceneAppData public string Data { get; set; } } + [JsonConverter(typeof(StringEnumConverter))] public enum SceneType { [EnumMember(Value = "LightScene")] diff --git a/src/Q42.HueApi/Models/Schedule/Schedule.cs b/src/Q42.HueApi/Models/Schedule/Schedule.cs index e080684e..e636b103 100644 --- a/src/Q42.HueApi/Models/Schedule/Schedule.cs +++ b/src/Q42.HueApi/Models/Schedule/Schedule.cs @@ -51,6 +51,7 @@ public class Schedule } + [JsonConverter(typeof(StringEnumConverter))] public enum ScheduleStatus { [EnumMember(Value = "enabled")]