mirror of
https://github.com/SyncrowIOT/backend.git
synced 2025-07-16 18:56:22 +00:00
Merge branch 'dev' of https://github.com/SyncrowIOT/backend into feat/list-space-model
This commit is contained in:
@ -1,4 +1,5 @@
|
|||||||
import { TuyaService } from '@app/common/integrations/tuya/services/tuya.service';
|
import { TuyaService } from '@app/common/integrations/tuya/services/tuya.service';
|
||||||
|
|
||||||
import { HttpException, HttpStatus, Injectable } from '@nestjs/common';
|
import { HttpException, HttpStatus, Injectable } from '@nestjs/common';
|
||||||
import { GetDeviceDetailsInterface } from 'src/device/interfaces/get.device.interface';
|
import { GetDeviceDetailsInterface } from 'src/device/interfaces/get.device.interface';
|
||||||
import { GetSpaceParam } from '../dtos';
|
import { GetSpaceParam } from '../dtos';
|
||||||
@ -25,6 +26,12 @@ export class SpaceDeviceService {
|
|||||||
spaceUuid,
|
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) => {
|
const safeFetch = async (device: any) => {
|
||||||
try {
|
try {
|
||||||
const tuyaDetails = await this.getDeviceDetailsByDeviceIdTuya(
|
const tuyaDetails = await this.getDeviceDetailsByDeviceIdTuya(
|
||||||
@ -42,7 +49,7 @@ export class SpaceDeviceService {
|
|||||||
};
|
};
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.warn(
|
console.warn(
|
||||||
`Skipping device with deviceTuyaUuid: ${device.deviceTuyaUuid} due to error.`,
|
`Skipping device with deviceTuyaUuid: ${device.deviceTuyaUuid} due to error. ${error}`,
|
||||||
);
|
);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user