From 368de74820c090071e262af94f791d2c92c3e262 Mon Sep 17 00:00:00 2001 From: Markus Bender Date: Mon, 26 Feb 2024 04:47:47 +0100 Subject: [PATCH] Removed Example Console Project Removed Old Api Classes Added new Http Api Service and Classes TODO Dynamic Effect Methods --- GoveeCSharpConnector.sln | 6 - GoveeCSharpConnector.sln.DotSettings | 3 +- ...oveeApiService.cs => IGoveeHttpService.cs} | 55 ++--- GoveeCSharpConnector/Objects/ApiResponse.cs | 7 - GoveeCSharpConnector/Objects/Data.cs | 8 - .../Objects/GoveeApiCommand.cs | 14 -- .../Objects/GoveeApiDevice.cs | 17 -- GoveeCSharpConnector/Objects/GoveeApiState.cs | 16 -- .../Objects/GoveeHttpDevice.cs | 14 ++ .../Objects/GoveeHttpState.cs | 16 ++ GoveeCSharpConnector/Objects/GoveeResponse.cs | 6 - .../Objects/Misc/ApiResponse.cs | 13 ++ .../Objects/Misc/Capability.cs | 13 ++ GoveeCSharpConnector/Objects/Misc/Field.cs | 21 ++ GoveeCSharpConnector/Objects/Misc/Option.cs | 11 + .../Objects/Misc/Parameters.cs | 17 ++ GoveeCSharpConnector/Objects/Misc/Payload.cs | 13 ++ .../Objects/{ => Misc}/Properties.cs | 8 +- GoveeCSharpConnector/Objects/Misc/Range.cs | 13 ++ .../Objects/Misc/ServiceResponse.cs | 8 + GoveeCSharpConnector/Objects/Misc/State.cs | 9 + .../Services/GoveeApiService.cs | 86 ------- .../Services/GoveeHttpService.cs | 214 ++++++++++++++++++ 23 files changed, 388 insertions(+), 200 deletions(-) rename GoveeCSharpConnector/Interfaces/{IGoveeApiService.cs => IGoveeHttpService.cs} (59%) delete mode 100644 GoveeCSharpConnector/Objects/ApiResponse.cs delete mode 100644 GoveeCSharpConnector/Objects/Data.cs delete mode 100644 GoveeCSharpConnector/Objects/GoveeApiCommand.cs delete mode 100644 GoveeCSharpConnector/Objects/GoveeApiDevice.cs delete mode 100644 GoveeCSharpConnector/Objects/GoveeApiState.cs create mode 100644 GoveeCSharpConnector/Objects/GoveeHttpDevice.cs create mode 100644 GoveeCSharpConnector/Objects/GoveeHttpState.cs delete mode 100644 GoveeCSharpConnector/Objects/GoveeResponse.cs create mode 100644 GoveeCSharpConnector/Objects/Misc/ApiResponse.cs create mode 100644 GoveeCSharpConnector/Objects/Misc/Capability.cs create mode 100644 GoveeCSharpConnector/Objects/Misc/Field.cs create mode 100644 GoveeCSharpConnector/Objects/Misc/Option.cs create mode 100644 GoveeCSharpConnector/Objects/Misc/Parameters.cs create mode 100644 GoveeCSharpConnector/Objects/Misc/Payload.cs rename GoveeCSharpConnector/Objects/{ => Misc}/Properties.cs (50%) create mode 100644 GoveeCSharpConnector/Objects/Misc/Range.cs create mode 100644 GoveeCSharpConnector/Objects/Misc/ServiceResponse.cs create mode 100644 GoveeCSharpConnector/Objects/Misc/State.cs delete mode 100644 GoveeCSharpConnector/Services/GoveeApiService.cs create mode 100644 GoveeCSharpConnector/Services/GoveeHttpService.cs diff --git a/GoveeCSharpConnector.sln b/GoveeCSharpConnector.sln index a2ab44f..1f1ef23 100644 --- a/GoveeCSharpConnector.sln +++ b/GoveeCSharpConnector.sln @@ -2,8 +2,6 @@ Microsoft Visual Studio Solution File, Format Version 12.00 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GoveeCSharpConnector", "GoveeCSharpConnector\GoveeCSharpConnector.csproj", "{EDF67B3A-9EBF-4C76-92E2-0AACD6B8081B}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GoveeCsharpConnector.Example", "GoveeCsharpConnector.Example\GoveeCsharpConnector.Example.csproj", "{E487B84B-F619-430A-A0D3-80D44FE9EE3F}" -EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -14,9 +12,5 @@ Global {EDF67B3A-9EBF-4C76-92E2-0AACD6B8081B}.Debug|Any CPU.Build.0 = Debug|Any CPU {EDF67B3A-9EBF-4C76-92E2-0AACD6B8081B}.Release|Any CPU.ActiveCfg = Release|Any CPU {EDF67B3A-9EBF-4C76-92E2-0AACD6B8081B}.Release|Any CPU.Build.0 = Release|Any CPU - {E487B84B-F619-430A-A0D3-80D44FE9EE3F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {E487B84B-F619-430A-A0D3-80D44FE9EE3F}.Debug|Any CPU.Build.0 = Debug|Any CPU - {E487B84B-F619-430A-A0D3-80D44FE9EE3F}.Release|Any CPU.ActiveCfg = Release|Any CPU - {E487B84B-F619-430A-A0D3-80D44FE9EE3F}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection EndGlobal diff --git a/GoveeCSharpConnector.sln.DotSettings b/GoveeCSharpConnector.sln.DotSettings index da83716..78725b5 100644 --- a/GoveeCSharpConnector.sln.DotSettings +++ b/GoveeCSharpConnector.sln.DotSettings @@ -1,2 +1,3 @@  - True \ No newline at end of file + True + True \ No newline at end of file diff --git a/GoveeCSharpConnector/Interfaces/IGoveeApiService.cs b/GoveeCSharpConnector/Interfaces/IGoveeHttpService.cs similarity index 59% rename from GoveeCSharpConnector/Interfaces/IGoveeApiService.cs rename to GoveeCSharpConnector/Interfaces/IGoveeHttpService.cs index e2c682c..8f2f108 100644 --- a/GoveeCSharpConnector/Interfaces/IGoveeApiService.cs +++ b/GoveeCSharpConnector/Interfaces/IGoveeHttpService.cs @@ -1,48 +1,37 @@ using GoveeCSharpConnector.Objects; +using GoveeCSharpConnector.Objects.Misc; namespace GoveeCSharpConnector.Interfaces; - [Obsolete("New Api Reference: https://developer.govee.com/reference/" ,true)] -public interface IGoveeApiService +public interface IGoveeHttpService { /// /// Sets the required Api Key for the Govee Api. /// Request Api Key in the Mobile Phone App. /// /// Api Key as String - [Obsolete("New Api Reference: https://developer.govee.com/reference/" ,true)] - void SetApiKey(string apiKey); - /// /// Returns current set Govee Api Key /// /// Govee Api Key as String string GetApiKey(); - /// /// Removes the Set Api Key and resets the HTTP Header /// void RemoveApiKey(); - /// /// Requests all Devices registered to Api Key Govee Account /// - /// List of GoveeApiDevices - [Obsolete("New Api Reference: https://developer.govee.com/reference/" ,true)] - - Task> GetDevices(); - + /// List of GoveeHttpDevices + Task>> GetDevices(); /// /// Requests the State of a single Govee Device /// /// Device Id Guid as string /// Device Model Number as string - /// GoveeApiStat Object - [Obsolete("New Api Reference: https://developer.govee.com/reference/" ,true)] - - Task GetDeviceState(string deviceId, string deviceModel); - + /// GoveeHttpState Object + Task> GetDeviceState(string deviceId, string deviceModel); /// /// Sets the On/Off state of a single Govee Device /// @@ -50,21 +39,7 @@ public interface IGoveeApiService /// Device Model Number as string /// /// - [Obsolete("New Api Reference: https://developer.govee.com/reference/" ,true)] - - Task ToggleState(string deviceId, string deviceModel, bool on); - - /// - /// Sets the Brightness in Percent of a single Govee Device - /// - /// Device Id Guid as string - /// Device Model Number as string - /// Brightness in Percent as Int - /// - [Obsolete("New Api Reference: https://developer.govee.com/reference/" ,true)] - - Task SetBrightness(string deviceId, string deviceModel, int value); - + Task> SetOnOff(string deviceId, string deviceModel, bool on); /// /// Sets a Rgb Color of a single Govee Device /// @@ -72,10 +47,7 @@ public interface IGoveeApiService /// Device Model Number as string /// Rgb Color /// - [Obsolete("New Api Reference: https://developer.govee.com/reference/" ,true)] - - Task SetColor(string deviceId, string deviceModel, RgbColor color); - + Task> SetColor(string deviceId, string deviceModel, RgbColor color); /// /// Sets the Color Temperature of a single Govee Device /// @@ -83,7 +55,14 @@ public interface IGoveeApiService /// Device Model Number as string /// Color Temp in Kelvin as Int /// - [Obsolete("New Api Reference: https://developer.govee.com/reference/" ,true)] + Task> SetColorTemp(string deviceId, string deviceModel, int value); + /// + /// Sets the Brightness of a single Govee Device + /// + /// Device Id Guid as string + /// Device Model Number as string + /// Value 1-100 + /// + Task> SetBrightness(string deviceId, string deviceModel, int value); - Task SetColorTemp(string deviceId, string deviceModel, int value); } \ No newline at end of file diff --git a/GoveeCSharpConnector/Objects/ApiResponse.cs b/GoveeCSharpConnector/Objects/ApiResponse.cs deleted file mode 100644 index 5639aab..0000000 --- a/GoveeCSharpConnector/Objects/ApiResponse.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace GoveeCSharpConnector.Objects; - -public class ApiResponse -{ - public string? Message { get; set; } - public int Code { get; set; } -} \ No newline at end of file diff --git a/GoveeCSharpConnector/Objects/Data.cs b/GoveeCSharpConnector/Objects/Data.cs deleted file mode 100644 index 044a900..0000000 --- a/GoveeCSharpConnector/Objects/Data.cs +++ /dev/null @@ -1,8 +0,0 @@ -using System.Collections.Generic; - -namespace GoveeCSharpConnector.Objects; - -public class Data -{ - public List Devices { get; set; } -} \ No newline at end of file diff --git a/GoveeCSharpConnector/Objects/GoveeApiCommand.cs b/GoveeCSharpConnector/Objects/GoveeApiCommand.cs deleted file mode 100644 index d364ccd..0000000 --- a/GoveeCSharpConnector/Objects/GoveeApiCommand.cs +++ /dev/null @@ -1,14 +0,0 @@ -namespace GoveeCSharpConnector.Objects; - -public class GoveeApiCommand -{ - public string Device { get; set; } - public string Model { get; set; } - public Command Cmd { get; set; } -} - -public class Command -{ - public string Name { get; set; } - public object Value { get; set; } -} \ No newline at end of file diff --git a/GoveeCSharpConnector/Objects/GoveeApiDevice.cs b/GoveeCSharpConnector/Objects/GoveeApiDevice.cs deleted file mode 100644 index 19e2c24..0000000 --- a/GoveeCSharpConnector/Objects/GoveeApiDevice.cs +++ /dev/null @@ -1,17 +0,0 @@ -using System.Collections.Generic; -using System.Text.Json.Serialization; - -namespace GoveeCSharpConnector.Objects; - -public class GoveeApiDevice -{ - [JsonPropertyName("device")] - public string DeviceId { get; set; } - public string Model { get; set; } - public string DeviceName { get; set; } - public bool Controllable { get; set; } - public bool Retrievable { get; set; } - [JsonPropertyName("supportCmds")] - public List SupportedCommands { get; set; } - public Properties Properties { get; set; } -} \ No newline at end of file diff --git a/GoveeCSharpConnector/Objects/GoveeApiState.cs b/GoveeCSharpConnector/Objects/GoveeApiState.cs deleted file mode 100644 index 586439e..0000000 --- a/GoveeCSharpConnector/Objects/GoveeApiState.cs +++ /dev/null @@ -1,16 +0,0 @@ -using System.Text.Json.Serialization; - -namespace GoveeCSharpConnector.Objects; - -public class GoveeApiState -{ - [JsonPropertyName("device")] - public string DeviceId { get; set; } - - public string Model { get; set; } - - public string Name { get; set; } - - [JsonIgnore] - public Properties Properties { get; set; } -} \ No newline at end of file diff --git a/GoveeCSharpConnector/Objects/GoveeHttpDevice.cs b/GoveeCSharpConnector/Objects/GoveeHttpDevice.cs new file mode 100644 index 0000000..f84e402 --- /dev/null +++ b/GoveeCSharpConnector/Objects/GoveeHttpDevice.cs @@ -0,0 +1,14 @@ +using System.Text.Json.Serialization; +using GoveeCSharpConnector.Objects.Misc; + +namespace GoveeCSharpConnector.Objects; + +public class GoveeHttpDevice +{ + [JsonPropertyName("sku")] + public string Model { get; set; } + [JsonPropertyName("device")] + public string Device { get; set; } + [JsonPropertyName("capabilities")] + public List Capabilities { get; set; } +} \ No newline at end of file diff --git a/GoveeCSharpConnector/Objects/GoveeHttpState.cs b/GoveeCSharpConnector/Objects/GoveeHttpState.cs new file mode 100644 index 0000000..b388391 --- /dev/null +++ b/GoveeCSharpConnector/Objects/GoveeHttpState.cs @@ -0,0 +1,16 @@ +using System.Text.Json.Serialization; +using GoveeCSharpConnector.Objects.Misc; + +namespace GoveeCSharpConnector.Objects; + +public class GoveeHttpState +{ + [JsonPropertyName("requestId")] + public string RequestId { get; set; } + [JsonPropertyName("msg")] + public string Msg { get; set; } + [JsonPropertyName("code")] + public long Code { get; set; } + [JsonPropertyName("payload")] + public Payload Payload { get; set; } +} \ No newline at end of file diff --git a/GoveeCSharpConnector/Objects/GoveeResponse.cs b/GoveeCSharpConnector/Objects/GoveeResponse.cs deleted file mode 100644 index e9ad04f..0000000 --- a/GoveeCSharpConnector/Objects/GoveeResponse.cs +++ /dev/null @@ -1,6 +0,0 @@ -namespace GoveeCSharpConnector.Objects; - -public class GoveeResponse : ApiResponse -{ - public Data Data { get; set; } -} \ No newline at end of file diff --git a/GoveeCSharpConnector/Objects/Misc/ApiResponse.cs b/GoveeCSharpConnector/Objects/Misc/ApiResponse.cs new file mode 100644 index 0000000..f7c4d67 --- /dev/null +++ b/GoveeCSharpConnector/Objects/Misc/ApiResponse.cs @@ -0,0 +1,13 @@ +using System.Text.Json.Serialization; + +namespace GoveeCSharpConnector.Objects.Misc; + +public class ApiResponse +{ + [JsonPropertyName("code")] + public int Code { get; set; } + [JsonPropertyName("message")] + public string Message { get; set; } + [JsonPropertyName("data")] + public List Data { get; set; } +} \ No newline at end of file diff --git a/GoveeCSharpConnector/Objects/Misc/Capability.cs b/GoveeCSharpConnector/Objects/Misc/Capability.cs new file mode 100644 index 0000000..0f28eb6 --- /dev/null +++ b/GoveeCSharpConnector/Objects/Misc/Capability.cs @@ -0,0 +1,13 @@ +using System.Text.Json.Serialization; + +namespace GoveeCSharpConnector.Objects.Misc; + +public class Capability +{ + [JsonPropertyName("type")] + public string Type { get; set; } + [JsonPropertyName("instance")] + public string Instance { get; set; } + [JsonPropertyName("state")] + public State State { get; set; } +} \ No newline at end of file diff --git a/GoveeCSharpConnector/Objects/Misc/Field.cs b/GoveeCSharpConnector/Objects/Misc/Field.cs new file mode 100644 index 0000000..a011bc4 --- /dev/null +++ b/GoveeCSharpConnector/Objects/Misc/Field.cs @@ -0,0 +1,21 @@ +using System.Text.Json.Serialization; + +namespace GoveeCSharpConnector.Objects.Misc; + +public class Field +{ + [JsonPropertyName("fieldName")] + public string FieldName { get; set; } + [JsonPropertyName("dataType")] + public string DataType { get; set; } + [JsonPropertyName("options")] + public List