mirror of
https://bitbucket.org/myhomie/mycorerepository.git
synced 2025-12-06 17:51:20 +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<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)
|
foreach (var arlo in arloDevices)
|
||||||
{
|
{
|
||||||
DeviceDetailDTO deviceDetailDTO = new DeviceDetailDTO();
|
DeviceDetailDTO deviceDetailDTO = new DeviceDetailDTO();
|
||||||
@ -185,6 +189,10 @@ namespace MyCore.Services.Devices
|
|||||||
{
|
{
|
||||||
List<DeviceDetailDTO> createdMerossDevices = new List<DeviceDetailDTO>();
|
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)
|
foreach (var meross in merossDevices)
|
||||||
{
|
{
|
||||||
DeviceDetailDTO deviceDetailDTO = new DeviceDetailDTO();
|
DeviceDetailDTO deviceDetailDTO = new DeviceDetailDTO();
|
||||||
@ -232,6 +240,10 @@ namespace MyCore.Services.Devices
|
|||||||
{
|
{
|
||||||
List<DeviceDetailDTO> createdYeelightDevices = new List<DeviceDetailDTO>();
|
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)
|
foreach (var light in yeelightDevices)
|
||||||
{
|
{
|
||||||
DeviceDetailDTO deviceDetailDTO = new DeviceDetailDTO();
|
DeviceDetailDTO deviceDetailDTO = new DeviceDetailDTO();
|
||||||
|
|||||||
@ -13,7 +13,6 @@ namespace MyCore.Services
|
|||||||
public async Task<List<YeelightAPI.Device>> GetDevices()
|
public async Task<List<YeelightAPI.Device>> GetDevices()
|
||||||
{
|
{
|
||||||
devices = await DeviceLocator.Discover();
|
devices = await DeviceLocator.Discover();
|
||||||
|
|
||||||
return devices;
|
return devices;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -28,6 +28,11 @@ namespace MyCore.Services.MyControlPanel
|
|||||||
return _Devices.Find<Device>(d => d.Id == id).FirstOrDefault();
|
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)
|
public bool IsExist(string id)
|
||||||
{
|
{
|
||||||
return _Devices.Find<Device>(d => d.Id == id).FirstOrDefault() != null ? true : false;
|
return _Devices.Find<Device>(d => d.Id == id).FirstOrDefault() != null ? true : false;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user