dt-common-device 7.10.5 → 7.10.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -130,21 +130,18 @@ let LocalDeviceService = (() => {
|
|
|
130
130
|
throw new Error("Device not found");
|
|
131
131
|
}
|
|
132
132
|
if (body?.status) {
|
|
133
|
-
const auditType = body?.status?.online
|
|
134
|
-
? constants_1.DT_EVENT_TYPES.DEVICE.STATUS.ONLINE
|
|
135
|
-
: constants_1.DT_EVENT_TYPES.DEVICE.STATUS.OFFLINE;
|
|
136
133
|
if (body?.status?.online) {
|
|
137
134
|
await this.handleOnlineStatus(device, device.status, body.status, auditBody?.source || Service_1.Source.SYSTEM, auditBody);
|
|
138
135
|
}
|
|
139
136
|
else {
|
|
140
137
|
await this.handleOfflineStatus(device, device.status, body.status, auditBody?.source || Service_1.Source.SYSTEM, auditBody, body.status.error?.message);
|
|
141
138
|
}
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
139
|
+
delete body.status;
|
|
140
|
+
}
|
|
141
|
+
if (body.state?.batteryPercentage?.value) {
|
|
142
|
+
await this.setBatteryLevel(deviceId, body.state?.batteryPercentage?.value, auditBody?.source || Service_1.Source.SYSTEM, auditBody);
|
|
143
|
+
delete body.state?.batteryPercentage;
|
|
145
144
|
}
|
|
146
|
-
delete body.state?.batteryPercentage;
|
|
147
|
-
delete body.status;
|
|
148
145
|
await this.deviceRepository.updateDevice(deviceId, body);
|
|
149
146
|
return await this.eventHandler.onDeviceUpdate(deviceId, body, auditBody);
|
|
150
147
|
}
|
|
@@ -470,6 +467,7 @@ let LocalDeviceService = (() => {
|
|
|
470
467
|
if (!query || Object.keys(query).length === 0) {
|
|
471
468
|
throw new Error("Query is required");
|
|
472
469
|
}
|
|
470
|
+
// TODO: Add Audit here as well onDeleteDevices
|
|
473
471
|
return await this.deviceRepository.deleteDevices(query);
|
|
474
472
|
}
|
|
475
473
|
async queryDevices(query) {
|