mirror of
https://github.com/SyncrowIOT/backend.git
synced 2025-11-27 12:44:55 +00:00
finished get mac address api
This commit is contained in:
@ -90,3 +90,9 @@ export interface GetPowerClampFunctionsStatusInterface {
|
|||||||
success: boolean;
|
success: boolean;
|
||||||
msg: string;
|
msg: string;
|
||||||
}
|
}
|
||||||
|
export interface GetMacAddressInterface {
|
||||||
|
uuid: string;
|
||||||
|
mac: string;
|
||||||
|
sn: string;
|
||||||
|
id: string;
|
||||||
|
}
|
||||||
|
|||||||
@ -20,6 +20,7 @@ import {
|
|||||||
GetDeviceDetailsFunctionsInterface,
|
GetDeviceDetailsFunctionsInterface,
|
||||||
GetDeviceDetailsFunctionsStatusInterface,
|
GetDeviceDetailsFunctionsStatusInterface,
|
||||||
GetDeviceDetailsInterface,
|
GetDeviceDetailsInterface,
|
||||||
|
GetMacAddressInterface,
|
||||||
GetPowerClampFunctionsStatusInterface,
|
GetPowerClampFunctionsStatusInterface,
|
||||||
controlDeviceInterface,
|
controlDeviceInterface,
|
||||||
getDeviceLogsInterface,
|
getDeviceLogsInterface,
|
||||||
@ -535,6 +536,9 @@ export class DeviceService {
|
|||||||
const response = await this.getDeviceDetailsByDeviceIdTuya(
|
const response = await this.getDeviceDetailsByDeviceIdTuya(
|
||||||
deviceDetails.deviceTuyaUuid,
|
deviceDetails.deviceTuyaUuid,
|
||||||
);
|
);
|
||||||
|
const macAddress = await this.getMacAddressByDeviceIdTuya(
|
||||||
|
deviceDetails.deviceTuyaUuid,
|
||||||
|
);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
...response,
|
...response,
|
||||||
@ -542,6 +546,7 @@ export class DeviceService {
|
|||||||
productUuid: deviceDetails.productDevice.uuid,
|
productUuid: deviceDetails.productDevice.uuid,
|
||||||
productType: deviceDetails.productDevice.prodType,
|
productType: deviceDetails.productDevice.prodType,
|
||||||
permissionType: userDevicePermission,
|
permissionType: userDevicePermission,
|
||||||
|
macAddress: macAddress.mac,
|
||||||
};
|
};
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
throw new HttpException(
|
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(
|
async getDeviceInstructionByDeviceId(
|
||||||
deviceUuid: string,
|
deviceUuid: string,
|
||||||
): Promise<DeviceInstructionResponse> {
|
): Promise<DeviceInstructionResponse> {
|
||||||
|
|||||||
Reference in New Issue
Block a user