diff --git a/src/device/services/device.service.ts b/src/device/services/device.service.ts index ce13b30..1854cd1 100644 --- a/src/device/services/device.service.ts +++ b/src/device/services/device.service.ts @@ -74,15 +74,19 @@ export class DeviceService { } async getDevicesByGroupId(getDeviceByGroupIdDto: GetDeviceByGroupIdDto) { try { - const response = await this.getDevicesByGroupIdTuya( + const devicesIds = await this.getDevicesByGroupIdTuya( getDeviceByGroupIdDto, ); - + const devicesDetails = await Promise.all( + devicesIds.result.data_list.map(async (device: any) => { + const deviceData = await this.getDevicesByDeviceId(device.dev_id); + return deviceData.result; + }), + ); return { - success: response.success, - devices: response.result.data_list, - count: response.result.count, - msg: response.msg, + success: devicesIds.success, + devices: devicesDetails, + msg: devicesIds.msg, }; } catch (error) { throw new HttpException( @@ -96,12 +100,11 @@ export class DeviceService { getDeviceByGroupIdDto: GetDeviceByGroupIdDto, ): Promise { try { - const path = `/v2.0/cloud/thing/group`; + const path = `/v2.0/cloud/thing/group/${getDeviceByGroupIdDto.groupId}/devices`; const response = await this.tuya.request({ method: 'GET', path, query: { - space_id: getDeviceByGroupIdDto.groupId, page_size: getDeviceByGroupIdDto.pageSize, page_no: getDeviceByGroupIdDto.pageNo, },