From b8c838caa3b5d02239e8fc28a8c231b98670c657 Mon Sep 17 00:00:00 2001 From: Locxion Date: Sat, 3 Feb 2024 00:49:18 +0100 Subject: [PATCH] Added UdpListener check --- GoveeCSharpConnector/Interfaces/GoveeService.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/GoveeCSharpConnector/Interfaces/GoveeService.cs b/GoveeCSharpConnector/Interfaces/GoveeService.cs index c55a907..2f949a4 100644 --- a/GoveeCSharpConnector/Interfaces/GoveeService.cs +++ b/GoveeCSharpConnector/Interfaces/GoveeService.cs @@ -22,7 +22,8 @@ public class GoveeService : IGoveeService if (!onlyLan) return devices; - _udpService.StartUdpListener(); + if (!_udpService.IsListening()) + _udpService.StartUdpListener(); var udpDevices = await _udpService.GetDevices(); @@ -37,7 +38,8 @@ public class GoveeService : IGoveeService { if (useUdp) { - _udpService.StartUdpListener(); + if (!_udpService.IsListening()) + _udpService.StartUdpListener(); if (string.IsNullOrWhiteSpace(goveeDevice.Address)) throw new Exception("Device not available via Udp/Lan"); var udpState = await _udpService.GetState(goveeDevice.Address); return new GoveeState() { State = udpState.onOff, Brightness = udpState.brightness, Color = udpState.color, ColorTempInKelvin = udpState.colorTempInKelvin };