hoffmation-base 3.2.3-alpha.2 → 3.2.3-alpha.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.
@@ -1,8 +1,42 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
2
35
  Object.defineProperty(exports, "__esModule", { value: true });
3
36
  exports.OwnUnifiDoor = void 0;
4
37
  const DoorDevice_1 = require("../DoorDevice");
5
38
  const enums_1 = require("../../enums");
39
+ const Util = __importStar(require("node:util"));
6
40
  class OwnUnifiDoor extends DoorDevice_1.DoorDevice {
7
41
  constructor(name, roomName, unifiDeviceName) {
8
42
  super(name, roomName);
@@ -22,10 +56,19 @@ class OwnUnifiDoor extends DoorDevice_1.DoorDevice {
22
56
  // Nothing
23
57
  }
24
58
  checkForDingUpdate(packet) {
59
+ var _a;
25
60
  switch (packet.event) {
26
61
  case 'access.data.device.remote_unlock':
27
62
  this.log(enums_1.LogLevel.Debug, `Device ${this.unifiDeviceName} was unlocked`);
28
63
  return;
64
+ case 'access.logs.add':
65
+ const event = packet.data;
66
+ if (((_a = event._source.authentication) === null || _a === void 0 ? void 0 : _a.credential_provider) === 'BUTTON_DOOR_BELL' &&
67
+ event._source.event.type === 'access.door.unlock') {
68
+ this.log(enums_1.LogLevel.Debug, `Ding Event details: ${Util.inspect(event, false, 5)}`);
69
+ this.onNewDingActiveValue(true);
70
+ }
71
+ return;
29
72
  case 'access.remote_view':
30
73
  const ringEvent = packet.data;
31
74
  this._lastDoorbellRingRequestId = ringEvent.request_id;
@@ -19,7 +19,10 @@ class UnifiAccess {
19
19
  // We had an update within the last 3 minutes --> no need to reconnect
20
20
  return;
21
21
  }
22
- this.reconnect(settings);
22
+ this._api.logout();
23
+ utils_1.Utils.guardedTimeout(() => {
24
+ this.reconnect(settings);
25
+ }, 5000, this);
23
26
  }, 5 * 60 * 1000);
24
27
  }
25
28
  static addDevice(door) {
@@ -53,6 +56,7 @@ class UnifiAccess {
53
56
  for (const device of this._api.devices) {
54
57
  this.initializeDevice(device);
55
58
  }
59
+ this._api.off('message', this.onMessage.bind(this));
56
60
  this._api.on('message', this.onMessage.bind(this));
57
61
  }
58
62
  onMessage(packet) {
@@ -62,9 +66,9 @@ class UnifiAccess {
62
66
  case 'nvr':
63
67
  break;
64
68
  default:
69
+ // this.unifiLogger.debug(`onMessage: ${JSON.stringify(packet)}`);
65
70
  // Lookup the device.
66
- const id = packet.event_object_id;
67
- const ownName = this._idMap.get(id);
71
+ const ownName = this._idMap.get(packet.event_object_id);
68
72
  if (!ownName) {
69
73
  break;
70
74
  }
@@ -87,7 +91,7 @@ class UnifiAccess {
87
91
  }
88
92
  const door = UnifiAccess.ownDoors.get(data.alias);
89
93
  door.initialize(data);
90
- logging_1.ServerLogService.writeLog(enums_1.LogLevel.Info, `Unifi-Access: ${data.name} (re)initialized`);
94
+ logging_1.ServerLogService.writeLog(enums_1.LogLevel.Info, `Unifi-Access: ${data.name} (re)initialized with unique_id: ${data.unique_id}`);
91
95
  this._idMap.set(data.unique_id, data.alias);
92
96
  }
93
97
  }