Added UdpListener check
This commit is contained in:
@ -22,7 +22,8 @@ public class GoveeService : IGoveeService
|
|||||||
if (!onlyLan)
|
if (!onlyLan)
|
||||||
return devices;
|
return devices;
|
||||||
|
|
||||||
_udpService.StartUdpListener();
|
if (!_udpService.IsListening())
|
||||||
|
_udpService.StartUdpListener();
|
||||||
|
|
||||||
var udpDevices = await _udpService.GetDevices();
|
var udpDevices = await _udpService.GetDevices();
|
||||||
|
|
||||||
@ -37,7 +38,8 @@ public class GoveeService : IGoveeService
|
|||||||
{
|
{
|
||||||
if (useUdp)
|
if (useUdp)
|
||||||
{
|
{
|
||||||
_udpService.StartUdpListener();
|
if (!_udpService.IsListening())
|
||||||
|
_udpService.StartUdpListener();
|
||||||
if (string.IsNullOrWhiteSpace(goveeDevice.Address)) throw new Exception("Device not available via Udp/Lan");
|
if (string.IsNullOrWhiteSpace(goveeDevice.Address)) throw new Exception("Device not available via Udp/Lan");
|
||||||
var udpState = await _udpService.GetState(goveeDevice.Address);
|
var udpState = await _udpService.GetState(goveeDevice.Address);
|
||||||
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 };
|
||||||
|
Reference in New Issue
Block a user