diff --git a/MyCore/Services/Devices/DeviceService.cs b/MyCore/Services/Devices/DeviceService.cs index 96d581f..bbc11a1 100644 --- a/MyCore/Services/Devices/DeviceService.cs +++ b/MyCore/Services/Devices/DeviceService.cs @@ -135,6 +135,10 @@ namespace MyCore.Services.Devices { List createdArloDevices = new List(); + List existingDevices = _DeviceDatabaseService.GetByprovider(provider.Id); + + arloDevices = arloDevices.Where(yd => !existingDevices.Select(ed => ed.ServiceIdentification).ToList().Contains(yd.deviceId)).ToList(); + foreach (var arlo in arloDevices) { DeviceDetailDTO deviceDetailDTO = new DeviceDetailDTO(); @@ -185,6 +189,10 @@ namespace MyCore.Services.Devices { List createdMerossDevices = new List(); + List existingDevices = _DeviceDatabaseService.GetByprovider(provider.Id); + + merossDevices = merossDevices.Where(yd => !existingDevices.Select(ed => ed.ServiceIdentification).ToList().Contains(yd.uuid)).ToList(); + foreach (var meross in merossDevices) { DeviceDetailDTO deviceDetailDTO = new DeviceDetailDTO(); @@ -232,6 +240,10 @@ namespace MyCore.Services.Devices { List createdYeelightDevices = new List(); + List existingDevices = _DeviceDatabaseService.GetByprovider(provider.Id); + + yeelightDevices = yeelightDevices.Where(yd => !existingDevices.Select(ed => ed.ServiceIdentification).ToList().Contains(yd.Id)).ToList(); + foreach (var light in yeelightDevices) { DeviceDetailDTO deviceDetailDTO = new DeviceDetailDTO(); diff --git a/MyCore/Services/Devices/SupportedDevices/YeelightService.cs b/MyCore/Services/Devices/SupportedDevices/YeelightService.cs index 2318522..166eeae 100644 --- a/MyCore/Services/Devices/SupportedDevices/YeelightService.cs +++ b/MyCore/Services/Devices/SupportedDevices/YeelightService.cs @@ -13,7 +13,6 @@ namespace MyCore.Services public async Task> GetDevices() { devices = await DeviceLocator.Discover(); - return devices; } diff --git a/MyCore/Services/MyControlPanel/Database/DeviceDatabaseService.cs b/MyCore/Services/MyControlPanel/Database/DeviceDatabaseService.cs index e24da37..6f5e53c 100644 --- a/MyCore/Services/MyControlPanel/Database/DeviceDatabaseService.cs +++ b/MyCore/Services/MyControlPanel/Database/DeviceDatabaseService.cs @@ -28,6 +28,11 @@ namespace MyCore.Services.MyControlPanel return _Devices.Find(d => d.Id == id).FirstOrDefault(); } + public List GetByprovider(string providerId) + { + return _Devices.Find(d => d.ProviderId == providerId).ToList(); + } + public bool IsExist(string id) { return _Devices.Find(d => d.Id == id).FirstOrDefault() != null ? true : false;