Added Get Scenes Method
This commit is contained in:
@ -64,6 +64,14 @@ public interface IGoveeHttpService
|
||||
/// <param name="value">Value 1-100</param>
|
||||
/// <returns></returns>
|
||||
Task<ServiceResponse<bool>> SetBrightness(string deviceId, string deviceModel, int value);
|
||||
|
||||
/// <summary>
|
||||
/// Gets a List of all available Govee Scenes for the Device
|
||||
/// </summary>
|
||||
/// <param name="deviceId">Device Id Guid as string</param>
|
||||
/// <param name="deviceModel">Device Model Number as string</param>
|
||||
/// <returns></returns>
|
||||
Task<ServiceResponse<List<GoveeScene>>> GetScenes(string deviceId, string deviceModel);
|
||||
/// <summary>
|
||||
/// Sets the LightScene of a single Govee Device
|
||||
/// </summary>
|
||||
|
13
GoveeCSharpConnector/Objects/GoveeScene.cs
Normal file
13
GoveeCSharpConnector/Objects/GoveeScene.cs
Normal file
@ -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; }
|
||||
}
|
12
GoveeCSharpConnector/Objects/Misc/SceneValue.cs
Normal file
12
GoveeCSharpConnector/Objects/Misc/SceneValue.cs
Normal file
@ -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; }
|
||||
}
|
@ -211,6 +211,34 @@ public class GoveeHttpService : IGoveeHttpService
|
||||
serviceResponse.Message = "";
|
||||
return serviceResponse;
|
||||
}
|
||||
/// <inheritdoc/>
|
||||
public async Task<ServiceResponse<List<GoveeScene>>> GetScenes(string deviceId, string deviceModel)
|
||||
{
|
||||
var serviceResponse = new ServiceResponse<List<GoveeScene>>();
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public async Task<ServiceResponse<bool>> SetLightScene(string deviceId, string deviceModel, int sceneValue)
|
||||
{
|
||||
|
Reference in New Issue
Block a user