Set Api Key on Request
This commit is contained in:
@ -18,6 +18,7 @@ public class GoveeService : IGoveeService
|
||||
public async Task<List<GoveeDevice>> GetDevices(bool onlyLan = true)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(GoveeApiKey)) throw new Exception("No Govee Api Key Set!");
|
||||
_apiService.SetApiKey(GoveeApiKey);
|
||||
var apiDevices = await _apiService.GetDevices();
|
||||
var devices = apiDevices.Select(apiDevice => new GoveeDevice() { DeviceId = apiDevice.DeviceId, DeviceName = apiDevice.DeviceName, Model = apiDevice.Model, Address = "onlyAvailableOnUdpRequest" }).ToList();
|
||||
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 };
|
||||
}
|
||||
if (string.IsNullOrWhiteSpace(GoveeApiKey)) throw new Exception("No Govee Api Key Set!");
|
||||
_apiService.SetApiKey(GoveeApiKey);
|
||||
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};
|
||||
}
|
||||
@ -59,6 +61,7 @@ public class GoveeService : IGoveeService
|
||||
return;
|
||||
}
|
||||
if (string.IsNullOrWhiteSpace(GoveeApiKey)) throw new Exception("No Govee Api Key Set!");
|
||||
_apiService.SetApiKey(GoveeApiKey);
|
||||
await _apiService.ToggleState(goveeDevice.DeviceId, goveeDevice.Model, on);
|
||||
}
|
||||
|
||||
@ -71,6 +74,7 @@ public class GoveeService : IGoveeService
|
||||
return;
|
||||
}
|
||||
if (string.IsNullOrWhiteSpace(GoveeApiKey)) throw new Exception("No Govee Api Key Set!");
|
||||
_apiService.SetApiKey(GoveeApiKey);
|
||||
await _apiService.SetBrightness(goveeDevice.DeviceId, goveeDevice.Model, value);
|
||||
}
|
||||
|
||||
@ -83,6 +87,7 @@ public class GoveeService : IGoveeService
|
||||
return;
|
||||
}
|
||||
if (string.IsNullOrWhiteSpace(GoveeApiKey)) throw new Exception("No Govee Api Key Set!");
|
||||
_apiService.SetApiKey(GoveeApiKey);
|
||||
await _apiService.SetColor(goveeDevice.DeviceId, goveeDevice.Model, color);
|
||||
}
|
||||
|
||||
@ -95,6 +100,7 @@ public class GoveeService : IGoveeService
|
||||
return;
|
||||
}
|
||||
if (string.IsNullOrWhiteSpace(GoveeApiKey)) throw new Exception("No Govee Api Key Set!");
|
||||
_apiService.SetApiKey(GoveeApiKey);
|
||||
await _apiService.SetColorTemp(goveeDevice.DeviceId, goveeDevice.Model, value);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user