mirror of
https://bitbucket.org/myhomie/mycorerepository.git
synced 2025-12-06 09:41:19 +00:00
Add device by provider - Add check if device already in system
This commit is contained in:
parent
eaaffaeeae
commit
e2f53e0d57
@ -135,6 +135,10 @@ namespace MyCore.Services.Devices
|
||||
{
|
||||
List<DeviceDetailDTO> createdArloDevices = new List<DeviceDetailDTO>();
|
||||
|
||||
List<Device> 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<DeviceDetailDTO> createdMerossDevices = new List<DeviceDetailDTO>();
|
||||
|
||||
List<Device> 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<DeviceDetailDTO> createdYeelightDevices = new List<DeviceDetailDTO>();
|
||||
|
||||
List<Device> 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();
|
||||
|
||||
@ -13,7 +13,6 @@ namespace MyCore.Services
|
||||
public async Task<List<YeelightAPI.Device>> GetDevices()
|
||||
{
|
||||
devices = await DeviceLocator.Discover();
|
||||
|
||||
return devices;
|
||||
}
|
||||
|
||||
|
||||
@ -28,6 +28,11 @@ namespace MyCore.Services.MyControlPanel
|
||||
return _Devices.Find<Device>(d => d.Id == id).FirstOrDefault();
|
||||
}
|
||||
|
||||
public List<Device> GetByprovider(string providerId)
|
||||
{
|
||||
return _Devices.Find(d => d.ProviderId == providerId).ToList();
|
||||
}
|
||||
|
||||
public bool IsExist(string id)
|
||||
{
|
||||
return _Devices.Find<Device>(d => d.Id == id).FirstOrDefault() != null ? true : false;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user