mirror of
https://github.com/SyncrowIOT/backend.git
synced 2025-11-26 09:54:55 +00:00
add start time and end time for the device logs
This commit is contained in:
@ -806,6 +806,8 @@ export class DeviceService {
|
||||
const response = await this.getDeviceLogsTuya(
|
||||
deviceDetails.deviceTuyaUuid,
|
||||
query.code,
|
||||
query.startTime,
|
||||
query.endTime,
|
||||
);
|
||||
|
||||
return {
|
||||
@ -822,11 +824,13 @@ export class DeviceService {
|
||||
async getDeviceLogsTuya(
|
||||
deviceId: string,
|
||||
code: string,
|
||||
startTime: string = (Date.now() - 1 * 60 * 60 * 1000).toString(),
|
||||
endTime: string = Date.now().toString(),
|
||||
): Promise<getDeviceLogsInterface> {
|
||||
try {
|
||||
const now = Date.now();
|
||||
const oneHourAgo = now - 1 * 60 * 60 * 1000;
|
||||
const path = `/v2.0/cloud/thing/${deviceId}/report-logs?start_time=${oneHourAgo}&end_time=${now}&codes=${code}&size=50`;
|
||||
console.log(startTime, endTime);
|
||||
|
||||
const path = `/v2.0/cloud/thing/${deviceId}/report-logs?start_time=${startTime}&end_time=${endTime}&codes=${code}&size=50`;
|
||||
const response = await this.tuya.request({
|
||||
method: 'GET',
|
||||
path,
|
||||
@ -835,8 +839,8 @@ export class DeviceService {
|
||||
const camelCaseResponse = convertKeysToCamelCase(response);
|
||||
const logs = camelCaseResponse.result.logs ?? [];
|
||||
return {
|
||||
startTime: oneHourAgo,
|
||||
endTime: now,
|
||||
startTime,
|
||||
endTime,
|
||||
data: logs,
|
||||
} as getDeviceLogsInterface;
|
||||
} catch (error) {
|
||||
|
||||
Reference in New Issue
Block a user