Set Api Key on Request
This commit is contained in:
@ -12,7 +12,7 @@
|
|||||||
<PackageProjectUrl>https://github.com/Locxion/GoveeCSharpConnector</PackageProjectUrl>
|
<PackageProjectUrl>https://github.com/Locxion/GoveeCSharpConnector</PackageProjectUrl>
|
||||||
<RepositoryUrl>https://github.com/Locxion/GoveeCSharpConnector</RepositoryUrl>
|
<RepositoryUrl>https://github.com/Locxion/GoveeCSharpConnector</RepositoryUrl>
|
||||||
<PackageLicenseUrl>https://github.com/Locxion/GoveeCSharpConnector/blob/main/LICENSE</PackageLicenseUrl>
|
<PackageLicenseUrl>https://github.com/Locxion/GoveeCSharpConnector/blob/main/LICENSE</PackageLicenseUrl>
|
||||||
<Version>1.1.0</Version>
|
<Version>1.1.1</Version>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
@ -18,6 +18,7 @@ public class GoveeService : IGoveeService
|
|||||||
public async Task<List<GoveeDevice>> GetDevices(bool onlyLan = true)
|
public async Task<List<GoveeDevice>> GetDevices(bool onlyLan = true)
|
||||||
{
|
{
|
||||||
if (string.IsNullOrWhiteSpace(GoveeApiKey)) throw new Exception("No Govee Api Key Set!");
|
if (string.IsNullOrWhiteSpace(GoveeApiKey)) throw new Exception("No Govee Api Key Set!");
|
||||||
|
_apiService.SetApiKey(GoveeApiKey);
|
||||||
var apiDevices = await _apiService.GetDevices();
|
var apiDevices = await _apiService.GetDevices();
|
||||||
var devices = apiDevices.Select(apiDevice => new GoveeDevice() { DeviceId = apiDevice.DeviceId, DeviceName = apiDevice.DeviceName, Model = apiDevice.Model, Address = "onlyAvailableOnUdpRequest" }).ToList();
|
var devices = apiDevices.Select(apiDevice => new GoveeDevice() { DeviceId = apiDevice.DeviceId, DeviceName = apiDevice.DeviceName, Model = apiDevice.Model, Address = "onlyAvailableOnUdpRequest" }).ToList();
|
||||||
if (!onlyLan)
|
if (!onlyLan)
|
||||||
@ -46,6 +47,7 @@ public class GoveeService : IGoveeService
|
|||||||
return new GoveeState() { State = udpState.onOff, Brightness = udpState.brightness, Color = udpState.color, ColorTempInKelvin = udpState.colorTempInKelvin };
|
return new GoveeState() { State = udpState.onOff, Brightness = udpState.brightness, Color = udpState.color, ColorTempInKelvin = udpState.colorTempInKelvin };
|
||||||
}
|
}
|
||||||
if (string.IsNullOrWhiteSpace(GoveeApiKey)) throw new Exception("No Govee Api Key Set!");
|
if (string.IsNullOrWhiteSpace(GoveeApiKey)) throw new Exception("No Govee Api Key Set!");
|
||||||
|
_apiService.SetApiKey(GoveeApiKey);
|
||||||
var apiState = await _apiService.GetDeviceState(goveeDevice.DeviceId, goveeDevice.Model);
|
var apiState = await _apiService.GetDeviceState(goveeDevice.DeviceId, goveeDevice.Model);
|
||||||
return new GoveeState{State = apiState.Properties.PowerState, Brightness = apiState.Properties.Brightness, Color = apiState.Properties.Color, ColorTempInKelvin = apiState.Properties.ColorTemp};
|
return new GoveeState{State = apiState.Properties.PowerState, Brightness = apiState.Properties.Brightness, Color = apiState.Properties.Color, ColorTempInKelvin = apiState.Properties.ColorTemp};
|
||||||
}
|
}
|
||||||
@ -59,6 +61,7 @@ public class GoveeService : IGoveeService
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (string.IsNullOrWhiteSpace(GoveeApiKey)) throw new Exception("No Govee Api Key Set!");
|
if (string.IsNullOrWhiteSpace(GoveeApiKey)) throw new Exception("No Govee Api Key Set!");
|
||||||
|
_apiService.SetApiKey(GoveeApiKey);
|
||||||
await _apiService.ToggleState(goveeDevice.DeviceId, goveeDevice.Model, on);
|
await _apiService.ToggleState(goveeDevice.DeviceId, goveeDevice.Model, on);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -71,6 +74,7 @@ public class GoveeService : IGoveeService
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (string.IsNullOrWhiteSpace(GoveeApiKey)) throw new Exception("No Govee Api Key Set!");
|
if (string.IsNullOrWhiteSpace(GoveeApiKey)) throw new Exception("No Govee Api Key Set!");
|
||||||
|
_apiService.SetApiKey(GoveeApiKey);
|
||||||
await _apiService.SetBrightness(goveeDevice.DeviceId, goveeDevice.Model, value);
|
await _apiService.SetBrightness(goveeDevice.DeviceId, goveeDevice.Model, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -83,6 +87,7 @@ public class GoveeService : IGoveeService
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (string.IsNullOrWhiteSpace(GoveeApiKey)) throw new Exception("No Govee Api Key Set!");
|
if (string.IsNullOrWhiteSpace(GoveeApiKey)) throw new Exception("No Govee Api Key Set!");
|
||||||
|
_apiService.SetApiKey(GoveeApiKey);
|
||||||
await _apiService.SetColor(goveeDevice.DeviceId, goveeDevice.Model, color);
|
await _apiService.SetColor(goveeDevice.DeviceId, goveeDevice.Model, color);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -95,6 +100,7 @@ public class GoveeService : IGoveeService
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (string.IsNullOrWhiteSpace(GoveeApiKey)) throw new Exception("No Govee Api Key Set!");
|
if (string.IsNullOrWhiteSpace(GoveeApiKey)) throw new Exception("No Govee Api Key Set!");
|
||||||
|
_apiService.SetApiKey(GoveeApiKey);
|
||||||
await _apiService.SetColorTemp(goveeDevice.DeviceId, goveeDevice.Model, value);
|
await _apiService.SetColorTemp(goveeDevice.DeviceId, goveeDevice.Model, value);
|
||||||
}
|
}
|
||||||
}
|
}
|
Reference in New Issue
Block a user