diff --git a/GoveeCSharpConnector/Interfaces/IGoveeHttpService.cs b/GoveeCSharpConnector/Interfaces/IGoveeHttpService.cs index 1377053..dd1171f 100644 --- a/GoveeCSharpConnector/Interfaces/IGoveeHttpService.cs +++ b/GoveeCSharpConnector/Interfaces/IGoveeHttpService.cs @@ -64,6 +64,14 @@ public interface IGoveeHttpService /// Value 1-100 /// Task> SetBrightness(string deviceId, string deviceModel, int value); + + /// + /// Gets a List of all available Govee Scenes for the Device + /// + /// Device Id Guid as string + /// Device Model Number as string + /// + Task>> GetScenes(string deviceId, string deviceModel); /// /// Sets the LightScene of a single Govee Device /// diff --git a/GoveeCSharpConnector/Objects/GoveeScene.cs b/GoveeCSharpConnector/Objects/GoveeScene.cs new file mode 100644 index 0000000..5845da0 --- /dev/null +++ b/GoveeCSharpConnector/Objects/GoveeScene.cs @@ -0,0 +1,13 @@ +using System.Text.Json.Serialization; +using GoveeCSharpConnector.Objects.Misc; + +namespace GoveeCSharpConnector.Objects; + +public class GoveeScene +{ + [JsonPropertyName("name")] + public string Name { get; set; } + + [JsonPropertyName("value")] + public SceneValue SceneValue { get; set; } +} \ No newline at end of file diff --git a/GoveeCSharpConnector/Objects/Misc/SceneValue.cs b/GoveeCSharpConnector/Objects/Misc/SceneValue.cs new file mode 100644 index 0000000..c4a5755 --- /dev/null +++ b/GoveeCSharpConnector/Objects/Misc/SceneValue.cs @@ -0,0 +1,12 @@ +using System.Text.Json.Serialization; + +namespace GoveeCSharpConnector.Objects.Misc; + +public class SceneValue +{ + [JsonPropertyName("paramId")] + public long ParamId { get; set; } + + [JsonPropertyName("id")] + public long Id { get; set; } +} \ No newline at end of file diff --git a/GoveeCSharpConnector/Services/GoveeHttpService.cs b/GoveeCSharpConnector/Services/GoveeHttpService.cs index cf7662a..a7564a9 100644 --- a/GoveeCSharpConnector/Services/GoveeHttpService.cs +++ b/GoveeCSharpConnector/Services/GoveeHttpService.cs @@ -211,6 +211,34 @@ public class GoveeHttpService : IGoveeHttpService serviceResponse.Message = ""; return serviceResponse; } + /// + public async Task>> GetScenes(string deviceId, string deviceModel) + { + var serviceResponse = new ServiceResponse>(); + + var jsonPayload = $@" + {{ + ""requestId"": ""{Guid.NewGuid()}"", + ""payload"": {{ + ""sku"": ""{deviceModel}"", + ""device"": ""{deviceId}"" + }} + }}"; + + var content = new StringContent(jsonPayload, Encoding.UTF8, "application/json"); + var response = await _httpClient.PostAsync($"{GoveeApiAddress}{GoveeControlEndpoint}", content); + if (!response.IsSuccessStatusCode) + { + serviceResponse.Success = false; + serviceResponse.Message = response.ReasonPhrase; + return serviceResponse; + } + // TODO Test response Content + serviceResponse.Success = true; + serviceResponse.Message = ""; + return serviceResponse; + } + /// public async Task> SetLightScene(string deviceId, string deviceModel, int sceneValue) {