mirror of
https://github.com/SyncrowIOT/backend.git
synced 2026-10-25 16:47:55 +00:00
finished skip any error from tuya device
This commit is contained in:
@@ -26,8 +26,8 @@ export class SpaceDeviceService {
|
||||
spaceUuid,
|
||||
);
|
||||
|
||||
const detailedDevices = await Promise.all(
|
||||
space.devices.map(async (device) => {
|
||||
const safeFetch = async (device: any) => {
|
||||
try {
|
||||
const tuyaDetails = await this.getDeviceDetailsByDeviceIdTuya(
|
||||
device.deviceTuyaUuid,
|
||||
);
|
||||
@@ -41,11 +41,18 @@ export class SpaceDeviceService {
|
||||
updatedAt: device.updatedAt,
|
||||
...tuyaDetails,
|
||||
};
|
||||
}),
|
||||
);
|
||||
} catch (error) {
|
||||
console.warn(
|
||||
`Skipping device with deviceTuyaUuid: ${device.deviceTuyaUuid} due to error.`,
|
||||
);
|
||||
return null;
|
||||
}
|
||||
};
|
||||
|
||||
const detailedDevices = await Promise.all(space.devices.map(safeFetch));
|
||||
|
||||
return new SuccessResponseDto({
|
||||
data: detailedDevices,
|
||||
data: detailedDevices.filter(Boolean), // Remove null or undefined values
|
||||
message: 'Successfully retrieved list of devices',
|
||||
});
|
||||
} catch (error) {
|
||||
|
||||
@@ -33,8 +33,8 @@ export class SubspaceDeviceService {
|
||||
|
||||
const subspace = await this.findSubspaceWithDevices(subSpaceUuid);
|
||||
|
||||
const detailedDevices = await Promise.all(
|
||||
subspace.devices.map(async (device) => {
|
||||
const safeFetch = async (device: any) => {
|
||||
try {
|
||||
const tuyaDetails = await this.getDeviceDetailsByDeviceIdTuya(
|
||||
device.deviceTuyaUuid,
|
||||
);
|
||||
@@ -49,11 +49,17 @@ export class SubspaceDeviceService {
|
||||
updatedAt: device.updatedAt,
|
||||
...tuyaDetails,
|
||||
};
|
||||
}),
|
||||
);
|
||||
} catch (error) {
|
||||
console.warn(
|
||||
`Skipping device with deviceTuyaUuid: ${device.deviceTuyaUuid} due to error.`,
|
||||
);
|
||||
return null;
|
||||
}
|
||||
};
|
||||
const detailedDevices = await Promise.all(subspace.devices.map(safeFetch));
|
||||
|
||||
return new SuccessResponseDto({
|
||||
data: detailedDevices,
|
||||
data: detailedDevices.filter(Boolean), // Remove nulls
|
||||
message: 'Successfully retrieved list of devices',
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user