dt-common-device 8.0.3 → 8.0.4

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.
@@ -250,7 +250,7 @@ export declare const DT_EVENT_TYPES: {
250
250
  OFFLINE: string;
251
251
  };
252
252
  LOCK: {
253
- LOCAL_CODES_EXCLUDING_SET: string;
253
+ LOCAL_CODES: string;
254
254
  CLOUD_CODES: string;
255
255
  MISSING_CODES: string;
256
256
  ADDITIONAL_CODES: string;
@@ -253,7 +253,7 @@ exports.DT_EVENT_TYPES = {
253
253
  OFFLINE: "heartbeat.hub.offline",
254
254
  },
255
255
  LOCK: {
256
- LOCAL_CODES_EXCLUDING_SET: "heartbeat.lock.local_codes_excluding_set",
256
+ LOCAL_CODES: "heartbeat.lock.local_codes",
257
257
  CLOUD_CODES: "heartbeat.lock.cloud_codes",
258
258
  MISSING_CODES: "heartbeat.lock.missing_codes",
259
259
  ADDITIONAL_CODES: "heartbeat.lock.additional_codes",
@@ -372,40 +372,42 @@ let LocalDeviceService = (() => {
372
372
  // Check if battery level has changed
373
373
  const isDifferent = !(0, lodash_1.isEqual)(oldBatteryState?.value, batteryLevel);
374
374
  if (isDifferent) {
375
- // Check if current time is greater than or equal to last updated time (8-hour logic)
376
- const shouldUpdate = this.shouldUpdateBatteryLevel(oldBatteryState?.lastUpdated);
377
- if (shouldUpdate) {
378
- // Save the battery level in the device
379
- await this.deviceRepository.setBatteryLevel(deviceId, batteryLevel);
380
- await this.eventHandler.onBatteryLevelChange(deviceId, batteryLevel, auditBody);
381
- if (oldBatteryState?.value < batteryLevel &&
382
- batteryLevel - oldBatteryState?.value > 50) {
383
- // Battery level has increased more than 50% (considering as battery has been replaced)
384
- const batteryState = {
385
- batteryState: {
386
- value: "replaced",
387
- lastUpdated: new Date().toISOString(),
388
- },
389
- };
390
- await this.setState(deviceId, batteryState, auditBody);
391
- await this.eventHandler.onBatteryReplaced(deviceId, batteryLevel, auditBody);
392
- // Cancel any existing battery issue
393
- await this.issueService.performIssueAction({
394
- entityId: deviceId,
395
- entityType: issue_types_1.EntityType.DEVICE,
396
- type: issue_types_1.IssueType.BATTERY_LOW,
397
- propertyId: device.propertyId,
398
- zoneId: device.zoneId,
399
- }, "resolve", source);
400
- }
401
- // Get property threshold
402
- const propertyThreshold = await this.getPropertyBatteryThreshold(device.propertyId);
403
- // Check if battery level is below threshold
404
- if (batteryLevel < propertyThreshold) {
405
- // Raise issue when the level is below threshold
406
- await this.issueService.createDeviceBatteryIssue(device, batteryLevel, propertyThreshold, issue_types_1.IssuePriority.CRITICAL, source);
407
- }
375
+ // // Check if current time is greater than or equal to last updated time (8-hour logic)
376
+ // const shouldUpdate = this.shouldUpdateBatteryLevel(
377
+ // oldBatteryState?.lastUpdated
378
+ // );
379
+ // if (shouldUpdate) {
380
+ // Save the battery level in the device
381
+ await this.deviceRepository.setBatteryLevel(deviceId, batteryLevel);
382
+ await this.eventHandler.onBatteryLevelChange(deviceId, batteryLevel, auditBody);
383
+ if (oldBatteryState?.value < batteryLevel &&
384
+ batteryLevel - oldBatteryState?.value > 50) {
385
+ // Battery level has increased more than 50% (considering as battery has been replaced)
386
+ const batteryState = {
387
+ batteryState: {
388
+ value: "replaced",
389
+ lastUpdated: new Date().toISOString(),
390
+ },
391
+ };
392
+ await this.setState(deviceId, batteryState, auditBody);
393
+ await this.eventHandler.onBatteryReplaced(deviceId, batteryLevel, auditBody);
394
+ // Cancel any existing battery issue
395
+ await this.issueService.performIssueAction({
396
+ entityId: deviceId,
397
+ entityType: issue_types_1.EntityType.DEVICE,
398
+ type: issue_types_1.IssueType.BATTERY_LOW,
399
+ propertyId: device.propertyId,
400
+ zoneId: device.zoneId,
401
+ }, "resolve", source);
402
+ }
403
+ // Get property threshold
404
+ const propertyThreshold = await this.getPropertyBatteryThreshold(device.propertyId);
405
+ // Check if battery level is below threshold
406
+ if (batteryLevel < propertyThreshold) {
407
+ // Raise issue when the level is below threshold
408
+ await this.issueService.createDeviceBatteryIssue(device, batteryLevel, propertyThreshold, issue_types_1.IssuePriority.CRITICAL, source);
408
409
  }
410
+ // }
409
411
  }
410
412
  }
411
413
  shouldUpdateBatteryLevel(lastUpdated) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dt-common-device",
3
- "version": "8.0.3",
3
+ "version": "8.0.4",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "files": [