mirror of
https://github.com/SyncrowIOT/backend.git
synced 2025-07-16 02:36:19 +00:00
finished get mac address api
This commit is contained in:
@ -90,3 +90,9 @@ export interface GetPowerClampFunctionsStatusInterface {
|
||||
success: boolean;
|
||||
msg: string;
|
||||
}
|
||||
export interface GetMacAddressInterface {
|
||||
uuid: string;
|
||||
mac: string;
|
||||
sn: string;
|
||||
id: string;
|
||||
}
|
||||
|
@ -20,6 +20,7 @@ import {
|
||||
GetDeviceDetailsFunctionsInterface,
|
||||
GetDeviceDetailsFunctionsStatusInterface,
|
||||
GetDeviceDetailsInterface,
|
||||
GetMacAddressInterface,
|
||||
GetPowerClampFunctionsStatusInterface,
|
||||
controlDeviceInterface,
|
||||
getDeviceLogsInterface,
|
||||
@ -535,6 +536,9 @@ export class DeviceService {
|
||||
const response = await this.getDeviceDetailsByDeviceIdTuya(
|
||||
deviceDetails.deviceTuyaUuid,
|
||||
);
|
||||
const macAddress = await this.getMacAddressByDeviceIdTuya(
|
||||
deviceDetails.deviceTuyaUuid,
|
||||
);
|
||||
|
||||
return {
|
||||
...response,
|
||||
@ -542,6 +546,7 @@ export class DeviceService {
|
||||
productUuid: deviceDetails.productDevice.uuid,
|
||||
productType: deviceDetails.productDevice.prodType,
|
||||
permissionType: userDevicePermission,
|
||||
macAddress: macAddress.mac,
|
||||
};
|
||||
} catch (error) {
|
||||
throw new HttpException(
|
||||
@ -582,7 +587,24 @@ export class DeviceService {
|
||||
);
|
||||
}
|
||||
}
|
||||
async getMacAddressByDeviceIdTuya(
|
||||
deviceId: string,
|
||||
): Promise<GetMacAddressInterface> {
|
||||
try {
|
||||
const path = `/v1.0/devices/factory-infos?device_ids=${deviceId}`;
|
||||
const response = await this.tuya.request({
|
||||
method: 'GET',
|
||||
path,
|
||||
});
|
||||
|
||||
return response.result[0];
|
||||
} catch (error) {
|
||||
throw new HttpException(
|
||||
'Error fetching mac address device from Tuya',
|
||||
HttpStatus.INTERNAL_SERVER_ERROR,
|
||||
);
|
||||
}
|
||||
}
|
||||
async getDeviceInstructionByDeviceId(
|
||||
deviceUuid: string,
|
||||
): Promise<DeviceInstructionResponse> {
|
||||
|
Reference in New Issue
Block a user