iobroker.ring 3.2.1 → 3.2.3

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,48 +1,29 @@
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 (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
24
4
  };
25
5
  Object.defineProperty(exports, "__esModule", { value: true });
26
6
  exports.OwnRingDevice = void 0;
27
7
  const ring_client_api_1 = require("ring-client-api");
28
- const constants_1 = require("./constants");
29
- const lastAction_1 = require("./lastAction");
30
- const fs = __importStar(require("fs"));
31
- const file_service_1 = require("./services/file-service");
32
- const util = __importStar(require("util"));
33
- var EventState;
34
- (function (EventState) {
35
- EventState[EventState["Idle"] = 0] = "Idle";
36
- EventState[EventState["ReactingOnMotion"] = 1] = "ReactingOnMotion";
37
- EventState[EventState["ReactingOnDing"] = 2] = "ReactingOnDing";
38
- EventState[EventState["ReactingOnDoorbell"] = 3] = "ReactingOnDoorbell";
39
- })(EventState || (EventState = {}));
8
+ const util_1 = __importDefault(require("util"));
40
9
  class OwnRingDevice {
10
+ constructor(location, adapter, apiClient, kind, shortId, description) {
11
+ this._adapter = adapter;
12
+ this._locationId = location.fullId;
13
+ this._client = apiClient;
14
+ this.kind = kind;
15
+ this.shortId = shortId;
16
+ this.fullId = `${this.kind}_${this.shortId}`;
17
+ this.description = description;
18
+ }
19
+ get locationId() {
20
+ return this._locationId;
21
+ }
41
22
  static getFullId(device, adapter) {
42
- return `${this.evaluateKind(device, adapter)}_${device.id}`;
23
+ return `${this.evaluateKind(device.deviceType, adapter, device)}_${device.id}`;
43
24
  }
44
- static evaluateKind(device, adapter) {
45
- switch (device.deviceType) {
25
+ static evaluateKind(deviceType, adapter, device) {
26
+ switch (deviceType) {
46
27
  case ring_client_api_1.RingCameraKind.doorbot:
47
28
  case ring_client_api_1.RingCameraKind.doorbell:
48
29
  case ring_client_api_1.RingCameraKind.doorbell_v3:
@@ -75,422 +56,26 @@ class OwnRingDevice {
75
56
  case ring_client_api_1.RingCameraKind.stickup_cam_lunar:
76
57
  case ring_client_api_1.RingCameraKind.stickup_cam_elite:
77
58
  return `stickup`;
59
+ case ring_client_api_1.RingDeviceType.IntercomHandsetAudio:
60
+ return `intercom`;
78
61
  default:
79
- adapter.log.error(`Device with Type ${device.deviceType} not yet supported, please inform dev Team via Github`);
80
- adapter.log.info(`Unsupported Device Info: ${util.inspect(device, false, 1)}`);
62
+ adapter.log.error(`Device with Type ${deviceType} not yet supported, please inform dev Team via Github`);
63
+ adapter.log.info(`Unsupported Device Info: ${util_1.default.inspect(device, false, 1)}`);
81
64
  }
82
65
  return "unknown";
83
66
  }
84
- get lastLiveStreamDir() {
85
- return this._lastLiveStreamDir;
86
- }
87
- get lastSnapShotDir() {
88
- return this._lastSnapShotDir;
89
- }
90
- get locationId() {
91
- return this._locationId;
92
- }
93
- get ringDevice() {
94
- return this._ringDevice;
95
- }
96
- set ringDevice(device) {
97
- this._ringDevice = device;
98
- this.subscribeToEvents();
99
- }
100
- async subscribeToEvents() {
101
- this.silly(`Start device subscriptions`);
102
- await this._ringDevice.subscribeToDingEvents().catch((r) => {
103
- this.catcher(`Failed subscribing to Ding Events for ${this._ringDevice.name}`, r);
104
- });
105
- await this._ringDevice.subscribeToMotionEvents().catch((r) => {
106
- this.catcher(`Failed subscribing to Motion Events for ${this._ringDevice.name}`, r);
107
- });
108
- this._ringDevice.onData.subscribe(this.update.bind(this));
109
- this._ringDevice.onMotionDetected.subscribe({
110
- next: (motion) => {
111
- this.onMotion(motion);
112
- },
113
- error: (err) => {
114
- this.catcher(`Motion Observer recieved error`, err);
115
- },
116
- });
117
- this._ringDevice.onDoorbellPressed.subscribe({
118
- next: (ding) => {
119
- this.onDorbell(ding);
120
- },
121
- error: (err) => {
122
- this.catcher(`Dorbell Observer recieved error`, err);
123
- },
124
- });
125
- this._ringDevice.onNewNotification.subscribe({
126
- next: (ding) => {
127
- this.onDing(ding);
128
- },
129
- error: (err) => {
130
- this.catcher(`Ding Observer recieved error`, err);
131
- },
132
- });
133
- }
134
- constructor(ringDevice, location, adapter, apiClient) {
135
- this._requestingSnapshot = false;
136
- this._requestingLiveStream = false;
137
- this._lastLightCommand = 0;
138
- this._lastLiveStreamUrl = "";
139
- this._lastLiveStreamDir = "";
140
- this._lastLiveStreamVideo = null;
141
- this._lastLiveStreamTimestamp = 0;
142
- this._lastSnapShotUrl = "";
143
- this._lastSnapShotDir = "";
144
- this._lastSnapshotImage = null;
145
- this._lastSnapshotTimestamp = 0;
146
- this._snapshotCount = 0;
147
- this._liveStreamCount = 0;
148
- this._state = EventState.Idle;
149
- this._adapter = adapter;
150
- this._ringDevice = ringDevice;
151
- this.shortId = `${ringDevice.id}`;
152
- this.debug(`Create device`);
153
- this._locationId = location.fullId;
154
- this._client = apiClient;
155
- this.kind = OwnRingDevice.evaluateKind(ringDevice, adapter);
156
- this.fullId = `${this.kind}_${this.shortId}`;
157
- this.infoChannelId = `${this.fullId}.${constants_1.CHANNEL_NAME_INFO}`;
158
- this.historyChannelId = `${this.fullId}.${constants_1.CHANNEL_NAME_HISTORY}`;
159
- this.lightChannelId = `${this.fullId}.${constants_1.CHANNEL_NAME_LIGHT}`;
160
- this.snapshotChannelId = `${this.fullId}.${constants_1.CHANNEL_NAME_SNAPSHOT}`;
161
- this.liveStreamChannelId = `${this.fullId}.${constants_1.CHANNEL_NAME_LIVESTREAM}`;
162
- this.eventsChannelId = `${this.fullId}.${constants_1.CHANNEL_NAME_EVENTS}`;
163
- this.recreateDeviceObjectTree();
164
- this.updateDeviceInfoObject(ringDevice.data);
165
- this.updateHealth();
166
- // noinspection JSIgnoredPromiseFromCall
167
- this.updateHistory();
168
- this.updateLiveStreamObject();
169
- setTimeout(this.takeSnapshot.bind(this), 5000);
170
- this.ringDevice = ringDevice; // subscribes to the events
171
- }
172
- processUserInput(channelID, stateID, state) {
173
- switch (channelID) {
174
- case "":
175
- if (stateID !== constants_1.STATE_ID_DEBUG_REQUEST) {
176
- return;
177
- }
178
- const targetVal = state.val;
179
- if (targetVal) {
180
- this._adapter.log.info(`Device Debug Data for ${this.shortId}: ${util.inspect(this._ringDevice, false, 1)}`);
181
- this._adapter.upsertState(`${this.fullId}.${constants_1.STATE_ID_DEBUG_REQUEST}`, constants_1.COMMON_DEBUG_REQUEST, false);
182
- }
183
- return;
184
- case "Light":
185
- if (!this._ringDevice.hasLight) {
186
- return;
187
- }
188
- if (stateID === constants_1.STATE_ID_LIGHT_SWITCH) {
189
- const targetVal = state.val;
190
- this._adapter.log.debug(`Set light for ${this.shortId} to value ${targetVal}`);
191
- this._lastLightCommand = Date.now();
192
- this._ringDevice.setLight(targetVal).then((success) => {
193
- if (success) {
194
- this._adapter.upsertState(`${this.lightChannelId}.light_state`, constants_1.COMMON_LIGHT_STATE, targetVal);
195
- this._adapter.upsertState(`${this.lightChannelId}.light_switch`, constants_1.COMMON_LIGHT_SWITCH, targetVal, true);
196
- setTimeout(() => {
197
- this.updateHealth.bind(this);
198
- }, 65000);
199
- }
200
- });
201
- }
202
- else {
203
- this._adapter.log.error(`Unknown State/Switch with channel "${channelID}" and state "${stateID}"`);
204
- }
205
- break;
206
- case "Snapshot":
207
- if (stateID === constants_1.STATE_ID_SNAPSHOT_REQUEST) {
208
- const targetVal = state.val;
209
- this._adapter.log.debug(`Get Snapshot request for ${this.shortId} to value ${targetVal}`);
210
- if (targetVal) {
211
- this.takeSnapshot().catch((reason) => {
212
- this.catcher("Couldn't retrieve Snapshot.", reason);
213
- });
214
- }
215
- }
216
- else {
217
- this._adapter.log.error(`Unknown State/Switch with channel "${channelID}" and state "${stateID}"`);
218
- }
219
- break;
220
- case "Livestream":
221
- if (stateID === constants_1.STATE_ID_LIVESTREAM_REQUEST) {
222
- const targetVal = state.val;
223
- this._adapter.log.debug(`Get Livestream request for ${this.shortId} to value ${targetVal}`);
224
- if (targetVal) {
225
- this.startLivestream().catch((reason) => {
226
- this.catcher("Couldn't retrieve Livestream.", reason);
227
- });
228
- }
229
- }
230
- else {
231
- this._adapter.log.error(`Unknown State/Switch with channel "${channelID}" and state "${stateID}"`);
232
- }
233
- break;
234
- default:
235
- this._adapter.log.error(`Unknown State/Switch with channel "${channelID}" and state "${stateID}"`);
236
- }
237
- }
238
- async recreateDeviceObjectTree() {
239
- this.silly(`Recreate DeviceObjectTree`);
240
- this._adapter.createDevice(this.fullId, {
241
- name: `Device ${this.shortId} ("${this._ringDevice.data.description}")`
242
- });
243
- this._adapter.createChannel(this.fullId, constants_1.CHANNEL_NAME_INFO, { name: `Info ${this.shortId}` });
244
- this._adapter.createChannel(this.fullId, constants_1.CHANNEL_NAME_SNAPSHOT);
245
- this._adapter.createChannel(this.fullId, constants_1.CHANNEL_NAME_LIVESTREAM, { name: `Livestream ${this.shortId}` });
246
- this._adapter.createChannel(this.fullId, constants_1.CHANNEL_NAME_HISTORY);
247
- this._adapter.createChannel(this.fullId, constants_1.CHANNEL_NAME_EVENTS);
248
- if (this._ringDevice.hasLight) {
249
- this.debug(`Device with Light Capabilities detected`);
250
- this._adapter.createChannel(this.fullId, constants_1.CHANNEL_NAME_LIGHT, { name: `Light ${this.shortId}` });
251
- this._adapter.upsertState(`${this.lightChannelId}.${constants_1.STATE_ID_LIGHT_SWITCH}`, constants_1.COMMON_LIGHT_SWITCH, false, true);
252
- }
253
- this._lastSnapShotDir = await this._adapter.tryGetStringState(`${this.snapshotChannelId}.snapshot_file`);
254
- this._lastLiveStreamDir = await this._adapter.tryGetStringState(`${this.liveStreamChannelId}.livestream_file`);
255
- this._adapter.upsertState(`${this.fullId}.${constants_1.STATE_ID_DEBUG_REQUEST}`, constants_1.COMMON_DEBUG_REQUEST, false, true);
256
- }
257
- updateByDevice(ringDevice) {
258
- this.ringDevice = ringDevice;
259
- this._state = EventState.Idle;
260
- this.update(ringDevice.data);
261
- }
262
- update(data) {
263
- this.debug(`Recieved Update`);
264
- this.updateDeviceInfoObject(data);
265
- this.updateHealth();
266
- // noinspection JSIgnoredPromiseFromCall
267
- this.updateHistory();
268
- this.updateSnapshotObject();
269
- }
270
- async startLivestream(duration) {
271
- this.silly(`${this.shortId}.startLivestream()`);
272
- const { fullPath, dirname } = file_service_1.FileService.getPath(this._adapter.config.path, this._adapter.config.filename_livestream, ++this._liveStreamCount, this.shortId, this.fullId, this.kind);
273
- if (!(await file_service_1.FileService.prepareFolder(dirname))) {
274
- this.debug(`Failed to prepare Livestream folder ("${fullPath}")`);
275
- return;
276
- }
277
- file_service_1.FileService.deleteFileIfExistSync(fullPath, this._adapter);
278
- if (this._ringDevice.isOffline) {
279
- this.info(` is offline --> won't take LiveStream`);
280
- return;
281
- }
282
- duration !== null && duration !== void 0 ? duration : (duration = this._adapter.config.recordtime_livestream);
283
- const tempPath = (await file_service_1.FileService.getTempDir(this._adapter)) + `/temp_${this.shortId}_livestream.mp4`;
284
- this.silly(`Initialize Livestream (${duration}s) to temp-file ${tempPath}`);
285
- await this._ringDevice.recordToFile(tempPath, duration);
286
- if (!fs.existsSync(tempPath)) {
287
- this.info(`Could't create livestream`);
288
- return;
289
- }
290
- const video = fs.readFileSync(tempPath);
291
- fs.unlink(tempPath, (err) => {
292
- if (err) {
293
- this._adapter.logCatch(`Couldn't delete temp file`, err);
294
- }
295
- });
296
- this.silly(`Recieved Livestream has Length: ${video.length}`);
297
- this._lastLiveStreamUrl = await file_service_1.FileService.getVisUrl(this._adapter, this.fullId, "Livestream.mp4");
298
- file_service_1.FileService.writeFileSync(fullPath, video, this._adapter);
299
- if (this.lastLiveStreamDir !== "" && this._adapter.config.del_old_livestream) {
300
- file_service_1.FileService.deleteFileIfExistSync(this._lastLiveStreamDir, this._adapter);
301
- }
302
- this._lastLiveStreamDir = fullPath;
303
- this._requestingLiveStream = false;
304
- // this.silly(`Locally storing Snapshot (Length: ${image.length})`);
305
- this._lastLiveStreamVideo = video;
306
- this._lastLiveStreamTimestamp = Date.now();
307
- await this.updateLiveStreamObject();
308
- this.debug(`Done creating livestream to ${fullPath}`);
309
- }
310
- async takeSnapshot(uuid, eventBased = false) {
311
- const { fullPath, dirname } = file_service_1.FileService.getPath(this._adapter.config.path, this._adapter.config.filename_snapshot, ++this._snapshotCount, this.shortId, this.fullId, this.kind);
312
- if (!(await file_service_1.FileService.prepareFolder(dirname)))
313
- return;
314
- file_service_1.FileService.deleteFileIfExistSync(fullPath, this._adapter);
315
- if (this._ringDevice.isOffline) {
316
- this.info(`is offline --> won't take Snapshot`);
317
- return;
318
- }
319
- const image = await this._ringDevice.getSnapshot({ uuid: uuid }).catch((reason) => {
320
- if (eventBased) {
321
- this.info("Taking Snapshot on Event failed. Will try again after livestream finished.");
322
- }
323
- else {
324
- this.catcher("Couldn't get Snapshot from api.", reason);
325
- }
326
- });
327
- if (!image) {
328
- if (!eventBased) {
329
- this.info("Could not create snapshot");
330
- }
331
- return;
332
- }
333
- this.silly(`Writing Snapshot (Length: ${image.length}) to "${fullPath}"`);
334
- file_service_1.FileService.writeFileSync(fullPath, image, this._adapter);
335
- this._lastSnapShotUrl = await file_service_1.FileService.getVisUrl(this._adapter, this.fullId, "Snapshot.jpg");
336
- if (this.lastSnapShotDir !== "" && this._adapter.config.del_old_snapshot) {
337
- file_service_1.FileService.deleteFileIfExistSync(this._lastSnapShotDir, this._adapter);
338
- }
339
- this._lastSnapShotDir = fullPath;
340
- this._requestingSnapshot = false;
341
- // this.silly(`Locally storing Snapshot (Length: ${image.length})`);
342
- this._lastSnapshotImage = image;
343
- this._lastSnapshotTimestamp = Date.now();
344
- await this.updateSnapshotObject();
345
- this.debug(`Done creating snapshot to ${fullPath}`);
346
- }
347
- updateHealth() {
348
- this.silly(`Update Health`);
349
- this._ringDevice.getHealth().then(this.updateHealthObject.bind(this));
350
- }
351
- async updateHistory() {
352
- this.silly(`Update History`);
353
- this._ringDevice.getEvents({ limit: 50 })
354
- .then(async (r) => {
355
- this.silly(`Recieved Event History`);
356
- const lastAction = r.events.find((event) => {
357
- const kind = event.kind;
358
- switch (kind) {
359
- case "motion":
360
- case "ding":
361
- case "alarm":
362
- case "on_demand":
363
- return true;
364
- }
365
- return false;
366
- });
367
- if (lastAction === undefined) {
368
- return;
369
- }
370
- const url = await this._ringDevice.getRecordingUrl(lastAction.ding_id_str);
371
- this.lastAction = new lastAction_1.LastAction(lastAction, url);
372
- this.updateHistoryObject(this.lastAction);
373
- });
374
- }
375
- updateDeviceInfoObject(data) {
376
- this._adapter.upsertState(`${this.infoChannelId}.id`, constants_1.COMMON_INFO_ID, data.device_id);
377
- this._adapter.upsertState(`${this.infoChannelId}.kind`, constants_1.COMMON_INFO_KIND, data.kind);
378
- this._adapter.upsertState(`${this.infoChannelId}.description`, constants_1.COMMON_INFO_DESCRIPTION, data.description);
379
- this._adapter.upsertState(`${this.infoChannelId}.external_connection`, constants_1.COMMON_INFO_EXTERNAL_CONNECTION, data.external_connection);
380
- this._adapter.upsertState(`${this.infoChannelId}.hasLight`, constants_1.COMMON_INFO_HAS_LIGHT, this._ringDevice.hasLight);
381
- this._adapter.upsertState(`${this.infoChannelId}.hasBattery`, constants_1.COMMON_INFO_HAS_BATTERY, this._ringDevice.hasBattery);
382
- this._adapter.upsertState(`${this.infoChannelId}.hasSiren`, constants_1.COMMON_INFO_HAS_SIREN, this._ringDevice.hasSiren);
383
- }
384
- updateHistoryObject(lastAction) {
385
- this._adapter.upsertState(`${this.historyChannelId}.created_at`, constants_1.COMMON_HISTORY_CREATED_AT, lastAction.event.created_at);
386
- this._adapter.upsertState(`${this.historyChannelId}.history_url`, constants_1.COMMON_HISTORY_URL, lastAction.historyUrl);
387
- this._adapter.upsertState(`${this.historyChannelId}.kind`, constants_1.COMMON_HISTORY_KIND, lastAction.event.kind);
388
- }
389
- async updateSnapshotObject() {
390
- this.debug(`Update Snapshot Object`);
391
- if (this._lastSnapshotImage) {
392
- await this._adapter.upsertFile(`${this.snapshotChannelId}.jpg`, constants_1.COMMON_SNAPSHOT_SNAPSHOT, this._lastSnapshotImage, this._lastSnapshotTimestamp).catch((reason) => {
393
- this.debug(`Couldn't update Snapshot obejct: "${reason}"`);
394
- });
395
- }
396
- if (this._lastSnapshotTimestamp !== 0) {
397
- this._adapter.upsertState(`${this.snapshotChannelId}.snapshot_file`, constants_1.COMMON_SNAPSHOT_FILE, this._lastSnapShotDir);
398
- this._adapter.upsertState(`${this.snapshotChannelId}.moment`, constants_1.COMMON_SNAPSHOT_MOMENT, this._lastSnapshotTimestamp);
399
- this._adapter.upsertState(`${this.snapshotChannelId}.snapshot_url`, constants_1.COMMON_SNAPSHOT_URL, this._lastSnapShotUrl);
400
- this._adapter.upsertState(`${this.snapshotChannelId}.${constants_1.STATE_ID_SNAPSHOT_REQUEST}`, constants_1.COMMON_SNAPSHOT_REQUEST, this._requestingSnapshot, true);
401
- }
402
- }
403
- async updateLiveStreamObject() {
404
- this.debug(`Update Livestream Object`);
405
- if (this._lastLiveStreamVideo) {
406
- await this._adapter.upsertFile(`${this.liveStreamChannelId}.mp4`, constants_1.COMMON_LIVESTREAM_LIVESTREAM, this._lastLiveStreamVideo, this._lastLiveStreamTimestamp).catch((reason) => {
407
- this.debug(`Couldn't update Livestream obejct: "${reason}"`);
408
- });
409
- }
410
- if (this._lastLiveStreamDir !== "") {
411
- this._adapter.upsertState(`${this.liveStreamChannelId}.livestream_file`, constants_1.COMMON_LIVESTREAM_FILE, this._lastLiveStreamDir);
412
- this._adapter.upsertState(`${this.liveStreamChannelId}.livestream_url`, constants_1.COMMON_LIVESTREAM_URL, this._lastLiveStreamUrl);
413
- this._adapter.upsertState(`${this.liveStreamChannelId}.moment`, constants_1.COMMON_LIVESTREAM_MOMENT, this._lastLiveStreamTimestamp);
414
- }
415
- this._adapter.upsertState(`${this.liveStreamChannelId}.${constants_1.STATE_ID_LIVESTREAM_REQUEST}`, constants_1.COMMON_LIVESTREAM_REQUEST, this._requestingLiveStream, true);
416
- }
417
- updateHealthObject(health) {
418
- var _a;
419
- this.debug(`Update Health Callback`);
420
- let batteryPercent = parseInt((_a = health.battery_percentage) !== null && _a !== void 0 ? _a : "-1");
421
- if (isNaN(batteryPercent)) {
422
- batteryPercent = -1;
423
- }
424
- this._adapter.upsertState(`${this.infoChannelId}.battery_percentage`, constants_1.COMMON_INFO_BATTERY_PERCENTAGE, batteryPercent);
425
- this._adapter.upsertState(`${this.infoChannelId}.battery_percentage_category`, constants_1.COMMON_INFO_BATTERY_PERCENTAGE_CATEGORY, health.battery_percentage_category);
426
- this._adapter.upsertState(`${this.infoChannelId}.wifi_name`, constants_1.COMMON_INFO_WIFI_NAME, health.wifi_name);
427
- this._adapter.upsertState(`${this.infoChannelId}.latest_signal_strength`, constants_1.COMMON_INFO_LATEST_SIGNAL_STRENGTH, health.latest_signal_strength);
428
- this._adapter.upsertState(`${this.infoChannelId}.latest_signal_category`, constants_1.COMMON_INFO_LATEST_SIGNAL_CATEGORY, health.latest_signal_category);
429
- this._adapter.upsertState(`${this.infoChannelId}.firmware`, constants_1.COMMON_INFO_FIRMWARE, health.firmware);
430
- if (this._ringDevice.hasLight && (Date.now() - this._lastLightCommand > 60000)) {
431
- // this.silly(JSON.stringify(this._ringDevice.data));
432
- const floodlightOn = this._ringDevice.data.health.floodlight_on;
433
- this.debug(`Update Light within Health Update Floodlight is ${floodlightOn}`);
434
- this._adapter.upsertState(`${this.lightChannelId}.light_state`, constants_1.COMMON_LIGHT_STATE, floodlightOn);
435
- }
436
- }
437
67
  debug(message) {
438
- this._adapter.log.debug(`Device ${this.shortId} ("${this.ringDevice.data.description}"): ${message}`);
68
+ this._adapter.log.debug(`Device ${this.shortId} ("${this.description}"): ${message}`);
439
69
  }
440
70
  silly(message) {
441
- this._adapter.log.silly(`Device ${this.shortId} ("${this.ringDevice.data.description}"): ${message}`);
71
+ this._adapter.log.silly(`Device ${this.shortId} ("${this.description}"): ${message}`);
442
72
  }
443
73
  info(message) {
444
- this._adapter.log.info(`Device ${this.shortId} ("${this.ringDevice.data.description}"): ${message}`);
74
+ this._adapter.log.info(`Device ${this.shortId} ("${this.description}"): ${message}`);
445
75
  }
446
76
  catcher(message, reason) {
447
77
  this._adapter.logCatch(message, reason);
448
78
  }
449
- onDing(value) {
450
- var _a;
451
- this.debug(`Recieved Ding Event (${util.inspect(value, true, 1)})`);
452
- this.conditionalRecording(EventState.ReactingOnDing, value.ding.image_uuid);
453
- this._adapter.upsertState(`${this.eventsChannelId}.type`, constants_1.COMMON_EVENTS_TYPE, value.subtype);
454
- this._adapter.upsertState(`${this.eventsChannelId}.detectionType`, constants_1.COMMON_EVENTS_DETECTIONTYPE, (_a = value.ding.detection_type) !== null && _a !== void 0 ? _a : value.subtype);
455
- this._adapter.upsertState(`${this.eventsChannelId}.created_at`, constants_1.COMMON_EVENTS_MOMENT, Date.now());
456
- this._adapter.upsertState(`${this.eventsChannelId}.message`, constants_1.COMMON_EVENTS_MESSAGE, value.aps.alert);
457
- }
458
- onMotion(value) {
459
- this.debug(`Recieved Motion Event (${util.inspect(value, true, 1)})`);
460
- this._adapter.upsertState(`${this.eventsChannelId}.motion`, constants_1.COMMON_MOTION, value);
461
- if (value) {
462
- this.conditionalRecording(EventState.ReactingOnMotion);
463
- }
464
- }
465
- onDorbell(value) {
466
- this.debug(`Recieved Doorbell Event (${util.inspect(value, true, 1)})`);
467
- this._adapter.upsertState(`${this.eventsChannelId}.doorbell`, constants_1.COMMON_EVENTS_DOORBELL, true);
468
- setTimeout(() => {
469
- this._adapter.upsertState(`${this.eventsChannelId}.doorbell`, constants_1.COMMON_EVENTS_DOORBELL, false);
470
- }, 5000);
471
- this.conditionalRecording(EventState.ReactingOnDoorbell, value.ding.image_uuid);
472
- }
473
- async conditionalRecording(state, uuid) {
474
- if (this._state === EventState.Idle) {
475
- this.silly(`Start recording for Event "${EventState[state]}"...`);
476
- this._state = state;
477
- try {
478
- this.takeSnapshot(uuid, true);
479
- await this.startLivestream(20);
480
- }
481
- finally {
482
- this._state = EventState.Idle;
483
- }
484
- return;
485
- }
486
- this.silly(`Would have recorded due to "${EventState[state]}", but we are already reacting.`);
487
- if (uuid) {
488
- setTimeout(() => {
489
- this.debug(`delayed uuid recording`);
490
- this.takeSnapshot(uuid);
491
- }, 23000);
492
- }
493
- }
494
79
  }
495
80
  exports.OwnRingDevice = OwnRingDevice;
496
81
  //# sourceMappingURL=ownRingDevice.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ownRingDevice.js","sourceRoot":"","sources":["../../src/lib/ownRingDevice.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,qDAUyB;AAGzB,2CA8CqB;AACrB,6CAA0C;AAC1C,uCAAyB;AACzB,0DAAsD;AACtD,2CAA6B;AAG7B,IAAK,UAKJ;AALD,WAAK,UAAU;IACb,2CAAI,CAAA;IACJ,mEAAgB,CAAA;IAChB,+DAAc,CAAA;IACd,uEAAkB,CAAA;AACpB,CAAC,EALI,UAAU,KAAV,UAAU,QAKd;AAED,MAAa,aAAa;IAEjB,MAAM,CAAC,SAAS,CAAC,MAAkB,EAAE,OAAoB;QAC9D,OAAO,GAAG,IAAI,CAAC,YAAY,CAAC,MAAM,EAA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oB,UAAU,uDAAuD,CACtF,CAAC;gBACF,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,4BAA4B,cAAI,CAAC,OAAO,CAAC,MAAM,EAAE,KAAK,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC;SAClF;QACD,OAAO,SAAS,CAAC;IACnB,CAAC;IAMS,KAAK,CAAC,OAAe;QAC7B,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,KAAK,CAAC,UAAU,IAAI,CAAC,OAAO,MAAM,IAAI,CAAC,WAAW,OAAO,OAAO,EAAE,CAAC,CAAC;IACxF,CAAC;IAES,KAAK,CAAC,OAAe;QAC7B,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,KAAK,CAAC,UAAU,IAAI,CAAC,OAAO,MAAM,IAAI,CAAC,WAAW,OAAO,OAAO,EAAE,CAAC,CAAC;IACxF,CAAC;IAES,IAAI,CAAC,OAAe;QAC5B,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,UAAU,IAAI,CAAC,OAAO,MAAM,IAAI,CAAC,WAAW,OAAO,OAAO,EAAE,CAAC,CAAC;IACvF,CAAC;IAES,OAAO,CAAC,OAAe,EAAE,MAAW;QAC5C,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;IAC1C,CAAC;CACF;AArGD,sCAqGC"}
@@ -0,0 +1,98 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.OwnRingIntercom = void 0;
7
+ const ownRingDevice_1 = require("./ownRingDevice");
8
+ const constants_1 = require("./constants");
9
+ const util_1 = __importDefault(require("util"));
10
+ class OwnRingIntercom extends ownRingDevice_1.OwnRingDevice {
11
+ constructor(ringDevice, location, adapter, apiClient) {
12
+ super(location, adapter, apiClient, ownRingDevice_1.OwnRingDevice.evaluateKind(ringDevice.deviceType, adapter, ringDevice), `${ringDevice.id}`, ringDevice.data.description);
13
+ this._ringDevice = ringDevice;
14
+ this.debug(`Create device`);
15
+ this.infoChannelId = `${this.fullId}.${constants_1.CHANNEL_NAME_INFO}`;
16
+ this.eventsChannelId = `${this.fullId}.${constants_1.CHANNEL_NAME_EVENTS}`;
17
+ this.recreateDeviceObjectTree();
18
+ }
19
+ get ringDevice() {
20
+ return this._ringDevice;
21
+ }
22
+ set ringDevice(device) {
23
+ this._ringDevice = device;
24
+ this.subscribeToEvents();
25
+ }
26
+ processUserInput(channelID, stateID, state) {
27
+ switch (channelID) {
28
+ case "":
29
+ const targetBoolVal = state.val;
30
+ switch (stateID) {
31
+ case constants_1.STATE_ID_DEBUG_REQUEST:
32
+ if (targetBoolVal) {
33
+ this._adapter.log.info(`Device Debug Data for ${this.shortId}: ${util_1.default.inspect(this._ringDevice, false, 1)}`);
34
+ this._adapter.upsertState(`${this.fullId}.${constants_1.STATE_ID_DEBUG_REQUEST}`, constants_1.COMMON_DEBUG_REQUEST, false);
35
+ }
36
+ break;
37
+ case constants_1.STATE_ID_INTERCOM_UNLOCK:
38
+ if (targetBoolVal) {
39
+ this._adapter.log.info(`Unlock door request for ${this.shortId}.`);
40
+ this._ringDevice.unlock().catch((reason) => {
41
+ this.catcher("Couldn't unlock door.", reason);
42
+ });
43
+ this._adapter.upsertState(`${this.fullId}.${constants_1.STATE_ID_INTERCOM_UNLOCK}`, constants_1.COMMON_DEBUG_REQUEST, false);
44
+ }
45
+ break;
46
+ }
47
+ return;
48
+ default:
49
+ this._adapter.log.error(`Unknown State/Switch with channel "${channelID}" and state "${stateID}"`);
50
+ }
51
+ }
52
+ updateByDevice(intercom) {
53
+ this.ringDevice = intercom;
54
+ this.update(intercom.data);
55
+ }
56
+ async recreateDeviceObjectTree() {
57
+ this.silly(`Recreate DeviceObjectTree`);
58
+ this._adapter.createDevice(this.fullId, {
59
+ name: `Device ${this.shortId} ("${this._ringDevice.data.description}")`
60
+ });
61
+ this._adapter.createChannel(this.fullId, constants_1.CHANNEL_NAME_INFO, { name: `Info ${this.shortId}` });
62
+ this._adapter.createChannel(this.fullId, constants_1.CHANNEL_NAME_EVENTS);
63
+ this._adapter.upsertState(`${this.fullId}.${constants_1.STATE_ID_DEBUG_REQUEST}`, constants_1.COMMON_DEBUG_REQUEST, false, true);
64
+ this._adapter.upsertState(`${this.fullId}.${constants_1.STATE_ID_INTERCOM_UNLOCK}`, constants_1.COMMON_INTERCOM_UNLOCK_REQUEST, false, true);
65
+ }
66
+ update(data) {
67
+ this.debug(`Recieved Update`);
68
+ this.updateDeviceInfoObject(data);
69
+ }
70
+ async subscribeToEvents() {
71
+ this.silly(`Start device subscriptions`);
72
+ await this._ringDevice.subscribeToDingEvents().catch((r) => {
73
+ this.catcher(`Failed subscribing to Ding Events for ${this._ringDevice.name}`, r);
74
+ });
75
+ this._ringDevice.onDing.subscribe({
76
+ next: () => {
77
+ this.onDing();
78
+ },
79
+ error: (err) => {
80
+ this.catcher(`Ding Observer recieved error`, err);
81
+ },
82
+ });
83
+ }
84
+ updateDeviceInfoObject(data) {
85
+ this._adapter.upsertState(`${this.infoChannelId}.id`, constants_1.COMMON_INFO_ID, data.device_id);
86
+ this._adapter.upsertState(`${this.infoChannelId}.kind`, constants_1.COMMON_INFO_KIND, data.kind);
87
+ this._adapter.upsertState(`${this.infoChannelId}.description`, constants_1.COMMON_INFO_DESCRIPTION, data.description);
88
+ }
89
+ onDing() {
90
+ this.debug(`Recieved Ding Event`);
91
+ this._adapter.upsertState(`${this.eventsChannelId}.ding`, constants_1.COMMON_EVENTS_INTERCOM_DING, true);
92
+ setTimeout(() => {
93
+ this._adapter.upsertState(`${this.eventsChannelId}.ding`, constants_1.COMMON_EVENTS_INTERCOM_DING, false);
94
+ }, 5000);
95
+ }
96
+ }
97
+ exports.OwnRingIntercom = OwnRingIntercom;
98
+ //# sourceMappingURL=ownRingIntercom.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file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