Merge branch 'dev' of https://github.com/SyncrowIOT/backend into feat/list-space-model

This commit is contained in:
hannathkadher
2024-12-18 13:00:11 +04:00

View File

@ -1,4 +1,5 @@
import { TuyaService } from '@app/common/integrations/tuya/services/tuya.service';
import { HttpException, HttpStatus, Injectable } from '@nestjs/common';
import { GetDeviceDetailsInterface } from 'src/device/interfaces/get.device.interface';
import { GetSpaceParam } from '../dtos';
@ -25,6 +26,12 @@ export class SpaceDeviceService {
spaceUuid,
);
if (!Array.isArray(space.devices)) {
throw new HttpException(
'The space does not contain any devices or the devices property is invalid.',
HttpStatus.BAD_REQUEST,
);
}
const safeFetch = async (device: any) => {
try {
const tuyaDetails = await this.getDeviceDetailsByDeviceIdTuya(
@ -42,7 +49,7 @@ export class SpaceDeviceService {
};
} catch (error) {
console.warn(
`Skipping device with deviceTuyaUuid: ${device.deviceTuyaUuid} due to error.`,
`Skipping device with deviceTuyaUuid: ${device.deviceTuyaUuid} due to error. ${error}`,
);
return null;
}