mirror of
https://github.com/SyncrowIOT/backend.git
synced 2025-07-16 02:36:19 +00:00
get devices
This commit is contained in:
@ -136,6 +136,17 @@ export class ControllerRoute {
|
||||
};
|
||||
};
|
||||
|
||||
static SPACE_DEVICES = class {
|
||||
public static readonly ROUTE =
|
||||
'/communities/:communityUuid/spaces/:spaceUuid/devices';
|
||||
static ACTIONS = class {
|
||||
public static readonly LIST_SPACE_DEVICE_SUMMARY =
|
||||
'List devices in a space';
|
||||
public static readonly LIST_SPACE_DEVICE_DESCRIPTION =
|
||||
'Retrieves a list of all devices associated with a specified space.';
|
||||
};
|
||||
};
|
||||
|
||||
static SUBSPACE = class {
|
||||
public static readonly ROUTE =
|
||||
'/communities/:communityUuid/spaces/:spaceUuid/subspaces';
|
||||
|
@ -35,4 +35,21 @@ export class TuyaService {
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
async getDeviceDetails(deviceId: string) {
|
||||
const path = `/v1.1/iot-03/devices/${deviceId}`;
|
||||
const response = await this.tuya.request({
|
||||
method: 'GET',
|
||||
path,
|
||||
});
|
||||
|
||||
if (!response.success) {
|
||||
throw new HttpException(
|
||||
`Error fetching device details: ${response.msg}`,
|
||||
HttpStatus.BAD_REQUEST,
|
||||
);
|
||||
}
|
||||
|
||||
return response.result;
|
||||
}
|
||||
}
|
||||
|
@ -42,7 +42,7 @@ export class DeviceEntity extends AbstractEntity<DeviceDto> {
|
||||
)
|
||||
deviceUserNotification: DeviceNotificationEntity[];
|
||||
|
||||
@ManyToOne(() => SpaceEntity, (space) => space.devicesSpaceEntity, {
|
||||
@ManyToOne(() => SpaceEntity, (space) => space.devices, {
|
||||
nullable: true,
|
||||
})
|
||||
spaceDevice: SpaceEntity;
|
||||
|
@ -81,7 +81,7 @@ export class SpaceEntity extends AbstractEntity<SpaceDto> {
|
||||
() => DeviceEntity,
|
||||
(devicesSpaceEntity) => devicesSpaceEntity.spaceDevice,
|
||||
)
|
||||
devicesSpaceEntity: DeviceEntity[];
|
||||
devices: DeviceEntity[];
|
||||
|
||||
constructor(partial: Partial<SpaceEntity>) {
|
||||
super();
|
||||
|
Reference in New Issue
Block a user