Typos, format and async consistency

This commit is contained in:
2025-08-12 18:28:00 -07:00
parent 76ccf20c30
commit 17cb171e36
35 changed files with 1937 additions and 907 deletions

View File

@ -2,73 +2,16 @@
namespace GoveeCSharpConnector.Interfaces;
public interface IGoveeApiService
{
/// <summary>
/// Sets the required Api Key for the Govee Api.
/// Request Api Key in the Mobile Phone App.
/// </summary>
/// <param name="apiKey">Api Key as String</param>
void SetApiKey(string apiKey);
public interface IGoveeApiService {
/// <summary>
/// Returns current set Govee Api Key
/// </summary>
/// <returns>Govee Api Key as String</returns>
string GetApiKey();
/// <summary>
/// Removes the Set Api Key and resets the HTTP Header
/// </summary>
void RemoveApiKey();
void SetApiKey(string apiKey);
Task<GoveeResponse> GetDevicesResponseAsync();
Task<GoveeApiState> GetDeviceStateAsync(string deviceId, string deviceModel);
Task<HttpResponseMessage> ToggleStateAsync(string deviceId, string deviceModel, bool on);
Task<HttpResponseMessage> SetColorTempAsync(string deviceId, string deviceModel, int value);
Task<HttpResponseMessage> SetBrightnessAsync(string deviceId, string deviceModel, int value);
Task<HttpResponseMessage> SetColorAsync(string deviceId, string deviceModel, RgbColor color);
/// <summary>
/// Requests all Devices registered to Api Key Govee Account
/// </summary>
/// <returns>List of GoveeApiDevices</returns>
Task<List<GoveeApiDevice>> GetDevices();
/// <summary>
/// Requests the State of a single Govee Device
/// </summary>
/// <param name="deviceId">Device Id Guid as string</param>
/// <param name="deviceModel">Device Model Number as string</param>
/// <returns>GoveeApiStat Object</returns>
Task<GoveeApiState> GetDeviceState(string deviceId, string deviceModel);
/// <summary>
/// Sets the On/Off state of a single Govee Device
/// </summary>
/// <param name="deviceId">Device Id Guid as string</param>
/// <param name="deviceModel">Device Model Number as string</param>
/// <param name="on"></param>
/// <returns></returns>
Task ToggleState(string deviceId, string deviceModel, bool on);
/// <summary>
/// Sets the Brightness in Percent of a single Govee Device
/// </summary>
/// <param name="deviceId">Device Id Guid as string</param>
/// <param name="deviceModel">Device Model Number as string</param>
/// <param name="value">Brightness in Percent as Int</param>
/// <returns></returns>
Task SetBrightness(string deviceId, string deviceModel, int value);
/// <summary>
/// Sets a Rgb Color of a single Govee Device
/// </summary>
/// <param name="deviceId">Device Id Guid as string</param>
/// <param name="deviceModel">Device Model Number as string</param>
/// <param name="color">Rgb Color</param>
/// <returns></returns>
Task SetColor(string deviceId, string deviceModel, RgbColor color);
/// <summary>
/// Sets the Color Temperature of a single Govee Device
/// </summary>
/// <param name="deviceId">Device Id Guid as string</param>
/// <param name="deviceModel">Device Model Number as string</param>
/// <param name="value">Color Temp in Kelvin as Int</param>
/// <returns></returns>
Task SetColorTemp(string deviceId, string deviceModel, int value);
}

View File

@ -2,61 +2,14 @@ using GoveeCSharpConnector.Objects;
namespace GoveeCSharpConnector.Interfaces;
public interface IGoveeService
{
/// <summary>
/// Govee Api Key
/// </summary>
public interface IGoveeService {
string GoveeApiKey { get; set; }
List<GoveeDevice> GetDevices(bool onlyLan = true);
void ToggleState(GoveeDevice goveeDevice, bool on, bool useUdp = true);
GoveeState GetDeviceState(GoveeDevice goveeDevice, bool useUdp = true);
void SetColorTemp(GoveeDevice goveeDevice, int value, bool useUdp = true);
void SetBrightness(GoveeDevice goveeDevice, int value, bool useUdp = true);
void SetColor(GoveeDevice goveeDevice, RgbColor color, bool useUdp = true);
/// <summary>
/// Gets a List of Govee Devices
/// </summary>
/// <param name="onlyLan">If true returns that are available on Api and Lan</param>
/// <returns>List of Govee Devices</returns>
Task<List<GoveeDevice>> GetDevices(bool onlyLan = true);
/// <summary>
/// Gets the State of a GoveeDevice
/// </summary>
/// <param name="goveeDevice">GoveeDevice</param>
/// <param name="useUdp">Use Udp Connection instead of the Api</param>
/// <returns></returns>
Task<GoveeState> GetDeviceState(GoveeDevice goveeDevice, bool useUdp = true);
/// <summary>
/// Sets the On/Off State of the GoveeDevice
/// </summary>
/// <param name="goveeDevice">GoveeDevice</param>
/// <param name="on"></param>
/// <param name="useUdp">Use Udp Connection instead of the Api</param>
/// <returns></returns>
Task ToggleState(GoveeDevice goveeDevice, bool on, bool useUdp = true);
/// <summary>
/// Sets the Brightness of the GoveeDevice
/// </summary>
/// <param name="goveeDevice">GoveeDevice</param>
/// <param name="value">Brightness in Percent</param>
/// <param name="useUdp">Use Udp Connection instead of the Api</param>
/// <returns></returns>
Task SetBrightness(GoveeDevice goveeDevice, int value, bool useUdp = true);
/// <summary>
/// Sets the Color of the GoveeDevice
/// </summary>
/// <param name="goveeDevice">GoveeDevice</param>
/// <param name="color">RgBColor</param>
/// <param name="useUdp">Use Udp Connection instead of the Api</param>
/// <returns></returns>
Task SetColor(GoveeDevice goveeDevice, RgbColor color, bool useUdp = true);
/// <summary>
/// Sets the Color Temperature in Kelvin for the GoveeDevice
/// </summary>
/// <param name="goveeDevice">GoveeDevice</param>
/// <param name="value">Color Temp in Kelvin</param>
/// <param name="useUdp">Use Udp Connection instead of the Api</param>
/// <returns></returns>
Task SetColorTemp(GoveeDevice goveeDevice, int value, bool useUdp = true);
}

View File

@ -1,76 +1,33 @@
using System.Data;
using System.Net;
using System.Net.Sockets;
using System.Text;
using System.Text.Json;
using GoveeCSharpConnector.Objects;
using GoveeCSharpConnector.Objects;
namespace GoveeCSharpConnector.Interfaces;
public interface IGoveeUdpService
{
/// <summary>
/// Sends a Scan Command via Udp Multicast.
/// </summary>
/// <param name="timeout">Standard 250ms</param>
/// <returns>List of GoveeUdpDevices</returns>
Task<List<GoveeUdpDevice>> GetDevices(TimeSpan? timeout = null);
public interface IGoveeUdpService {
/// <summary>
/// Request the State of the Device
/// </summary>
/// <param name="deviceAddress">Ip Address of the Device</param>
/// <param name="uniCastPort">Port of the Device. Standard 4003</param>
/// <param name="timeout">Standard 250ms</param>
/// <returns></returns>
Task<GoveeUdpState> GetState(string deviceAddress, int uniCastPort = 4003, TimeSpan? timeout = null);
/// <summary>
/// Sets the On/Off State of the Device
/// </summary>
/// <param name="deviceAddress">Ip Address of the Device</param>
/// <param name="on"></param>
/// <param name="uniCastPort">Port of the Device. Standard 4003</param>
/// <returns></returns>
Task ToggleDevice(string deviceAddress, bool on, int uniCastPort = 4003);
/// <summary>
/// Sets the Brightness of the Device
/// </summary>
/// <param name="deviceAddress">Ip Address of the Device</param>
/// <param name="brightness">In Percent 1-100</param>
/// <param name="uniCastPort">Port of the Device. Standard 4003</param>
/// <returns></returns>
Task SetBrightness(string deviceAddress, int brightness, int uniCastPort = 4003);
/// <summary>
/// Sets the Color of the Device
/// </summary>
/// <param name="deviceAddress">Ip Address of the Device</param>
/// <param name="color"></param>
/// <param name="uniCastPort">Port of the Device. Standard 4003</param>
/// <returns></returns>
Task SetColor(string deviceAddress, RgbColor color, int uniCastPort = 4003);
/// <summary>
/// Sets the ColorTemp of the Device
/// </summary>
/// <param name="deviceAddress">Ip Address of the Device</param>
/// <param name="colorTempInKelvin"></param>
/// <param name="uniCastPort">Port of the Device. Standard 4003</param>
/// <returns></returns>
Task SetColorTemp(string deviceAddress, int colorTempInKelvin, int uniCastPort = 4003);
/// <summary>
/// Starts the Udp Listener
/// </summary>
/// <returns></returns>
void StartUdpListener();
/// <summary>
/// Returns the State of the Udp Listener
/// </summary>
/// <returns>True if Active</returns>
bool IsListening();
/// <summary>
/// Stops the Udp Listener
/// </summary>
/// <returns></returns>
void StopUdpListener();
}
Task StartUdpListenerAsync();
Task<IList<GoveeUdpDevice>> GetDevicesAsync(TimeSpan? timeout = null);
void ToggleDevice(string deviceAddress, bool on, int uniCastPort = 4003);
void SetColor(string deviceAddress, RgbColor color, int uniCastPort = 4003);
void SetBrightness(string deviceAddress, int brightness, int uniCastPort = 4003);
void SetColorTemp(string deviceAddress, int colorTempInKelvin, int uniCastPort = 4003);
Task<GoveeUdpState> GetStateAsync(string deviceAddress, int uniCastPort = 4003, TimeSpan? timeout = null);
// void StartUdpListener();
// Task<ReadOnlyCollection<GoveeUdpDevice>> GetDevices(TimeSpan? timeout = null);
// Task<GoveeUdpState> GetState(string deviceAddress, int uniCastPort = 4003, TimeSpan? timeout = null);
// public async Task<ReadOnlyCollection<GoveeUdpDevice>> GetDevices(TimeSpan? timeout = null) =>
// new([.. (await GetDevicesAsync(timeout))]);
// public async Task<GoveeUdpState> GetState(string deviceAddress, int uniCastPort = 4003, TimeSpan? timeout = null) =>
// await GetStateAsync(deviceAddress, uniCastPort, timeout);
// public async void StartUdpListener() =>
// await StartUdpListenerAsync();
// private async void SetupUdpClientListener() =>
// await SetupUdpClientListenerAsync();
}