iobroker.ring 6.3.0 → 7.0.0
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.
- package/LICENSE +2 -1
- package/README.md +34 -419
- package/admin/assets/index-QX4NxbDg.js +693 -0
- package/admin/i18n/de.json +3 -1
- package/admin/i18n/en.json +3 -1
- package/admin/i18n/es.json +3 -2
- package/admin/i18n/fr.json +3 -1
- package/admin/i18n/it.json +3 -1
- package/admin/i18n/nl.json +5 -3
- package/admin/i18n/pl.json +3 -1
- package/admin/i18n/pt.json +3 -1
- package/admin/i18n/ru.json +3 -1
- package/admin/i18n/uk.json +3 -1
- package/admin/i18n/zh-cn.json +3 -1
- package/admin/tab_m.html +13 -34
- package/build/lib/constants.js +204 -204
- package/build/lib/constants.js.map +1 -1
- package/build/lib/lastAction.js +2 -0
- package/build/lib/lastAction.js.map +1 -1
- package/build/lib/ownRingCamera.js +286 -244
- package/build/lib/ownRingCamera.js.map +1 -1
- package/build/lib/ownRingDevice.js +57 -44
- package/build/lib/ownRingDevice.js.map +1 -1
- package/build/lib/ownRingIntercom.js +45 -40
- package/build/lib/ownRingIntercom.js.map +1 -1
- package/build/lib/ownRingLocation.js +27 -19
- package/build/lib/ownRingLocation.js.map +1 -1
- package/build/lib/ringApiClient.js +61 -49
- package/build/lib/ringApiClient.js.map +1 -1
- package/build/lib/services/event-blocker.js +13 -10
- package/build/lib/services/event-blocker.js.map +1 -1
- package/build/lib/services/file-service.js +29 -27
- package/build/lib/services/file-service.js.map +1 -1
- package/build/lib/services/image-service.js +8 -4
- package/build/lib/services/image-service.js.map +1 -1
- package/build/lib/services/text-service.js +169 -85
- package/build/lib/services/text-service.js.map +1 -1
- package/build/main.js +84 -90
- package/build/main.js.map +1 -1
- package/io-package.json +39 -38
- package/package.json +43 -90
- package/admin/admin.d.ts +0 -112
- package/admin/convert.js +0 -447
- package/admin/index_m.html +0 -318
- package/admin/style.css +0 -33
- package/admin/tab_m.js +0 -154
- package/admin/tsconfig.json +0 -11
- package/admin/words.js +0 -470
- package/build/lib/tools.js +0 -98
- package/build/lib/tools.js.map +0 -1
|
@@ -15,21 +15,31 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
15
15
|
}) : function(o, v) {
|
|
16
16
|
o["default"] = v;
|
|
17
17
|
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
};
|
|
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
|
+
})();
|
|
25
35
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
36
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
37
|
};
|
|
28
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
39
|
exports.OwnRingCamera = void 0;
|
|
30
40
|
const rxjs = __importStar(require("rxjs"));
|
|
31
|
-
const fs = __importStar(require("fs"));
|
|
32
|
-
const util = __importStar(require("util"));
|
|
41
|
+
const fs = __importStar(require("node:fs"));
|
|
42
|
+
const util = __importStar(require("node:util"));
|
|
33
43
|
const sharp_1 = __importDefault(require("sharp"));
|
|
34
44
|
const strftime_1 = __importDefault(require("strftime"));
|
|
35
45
|
const node_schedule_1 = __importDefault(require("node-schedule"));
|
|
@@ -48,25 +58,39 @@ var EventState;
|
|
|
48
58
|
EventState[EventState["ReactingOnDoorbell"] = 3] = "ReactingOnDoorbell";
|
|
49
59
|
})(EventState || (EventState = {}));
|
|
50
60
|
class OwnRingCamera extends ownRingDevice_1.OwnRingDevice {
|
|
61
|
+
infoChannelId;
|
|
62
|
+
historyChannelId;
|
|
63
|
+
lightChannelId;
|
|
64
|
+
sirenChannelId;
|
|
65
|
+
eventsChannelId;
|
|
66
|
+
snapshotChannelId;
|
|
67
|
+
HDsnapshotChannelId;
|
|
68
|
+
liveStreamChannelId;
|
|
69
|
+
lastAction;
|
|
70
|
+
_ringDevice;
|
|
71
|
+
_durationLiveStream;
|
|
72
|
+
_lastLightCommand = 0;
|
|
73
|
+
_lastLiveStreamUrl = '';
|
|
74
|
+
_lastLiveStreamTimestamp = 0;
|
|
75
|
+
_lastSnapShotUrl = '';
|
|
76
|
+
_lastSnapshotTimestamp = 0;
|
|
77
|
+
_snapshotCount = 0;
|
|
78
|
+
_lastHDSnapShotUrl = '';
|
|
79
|
+
_lastHDSnapshotTimestamp = 0;
|
|
80
|
+
_HDsnapshotCount = 0;
|
|
81
|
+
_liveStreamCount = 0;
|
|
82
|
+
_lastLiveStreamDir = '';
|
|
83
|
+
_lastSnapShotDir = '';
|
|
84
|
+
_lastHDSnapShotDir = '';
|
|
85
|
+
_motionEventBlocker;
|
|
86
|
+
_notifyEventBlocker;
|
|
87
|
+
_doorbellEventBlocker;
|
|
88
|
+
_state = EventState.Idle;
|
|
51
89
|
constructor(ringDevice, location, adapter, apiClient) {
|
|
52
90
|
super(location, adapter, apiClient, OwnRingCamera.evaluateKind(ringDevice.deviceType, adapter, ringDevice), `${ringDevice.id}`, ringDevice.data.description);
|
|
53
|
-
this.
|
|
54
|
-
this.
|
|
55
|
-
this.
|
|
56
|
-
this._lastSnapShotUrl = "";
|
|
57
|
-
this._lastSnapshotTimestamp = 0;
|
|
58
|
-
this._snapshotCount = 0;
|
|
59
|
-
this._lastHDSnapShotUrl = "";
|
|
60
|
-
this._lastHDSnapshotTimestamp = 0;
|
|
61
|
-
this._HDsnapshotCount = 0;
|
|
62
|
-
this._liveStreamCount = 0;
|
|
63
|
-
this._lastLiveStreamDir = "";
|
|
64
|
-
this._lastSnapShotDir = "";
|
|
65
|
-
this._lastHDSnapShotDir = "";
|
|
66
|
-
this._state = EventState.Idle;
|
|
67
|
-
this._motionEventBlocker = new event_blocker_1.EventBlocker(this._adapter.config.ignore_events_Motion, this._adapter.config.keep_ignoring_if_retriggered);
|
|
68
|
-
this._notifyEventBlocker = new event_blocker_1.EventBlocker(this._adapter.config.ignore_events_Motion, this._adapter.config.keep_ignoring_if_retriggered);
|
|
69
|
-
this._doorbellEventBlocker = new event_blocker_1.EventBlocker(this._adapter.config.ignore_events_Doorbell, this._adapter.config.keep_ignoring_if_retriggered);
|
|
91
|
+
this._motionEventBlocker = new event_blocker_1.EventBlocker(this._adapter, this._adapter.config.ignore_events_Motion, this._adapter.config.keep_ignoring_if_retriggered);
|
|
92
|
+
this._notifyEventBlocker = new event_blocker_1.EventBlocker(this._adapter, this._adapter.config.ignore_events_Motion, this._adapter.config.keep_ignoring_if_retriggered);
|
|
93
|
+
this._doorbellEventBlocker = new event_blocker_1.EventBlocker(this._adapter, this._adapter.config.ignore_events_Doorbell, this._adapter.config.keep_ignoring_if_retriggered);
|
|
70
94
|
this._durationLiveStream = this._adapter.config.recordtime_livestream;
|
|
71
95
|
this._ringDevice = ringDevice;
|
|
72
96
|
this.infoChannelId = `${this.fullId}.${constants_1.CHANNEL_NAME_INFO}`;
|
|
@@ -77,19 +101,19 @@ class OwnRingCamera extends ownRingDevice_1.OwnRingDevice {
|
|
|
77
101
|
this.HDsnapshotChannelId = `${this.fullId}.${constants_1.CHANNEL_NAME_HDSNAPSHOT}`;
|
|
78
102
|
this.liveStreamChannelId = `${this.fullId}.${constants_1.CHANNEL_NAME_LIVESTREAM}`;
|
|
79
103
|
this.eventsChannelId = `${this.fullId}.${constants_1.CHANNEL_NAME_EVENTS}`;
|
|
80
|
-
this.recreateDeviceObjectTree();
|
|
81
|
-
this.updateDeviceInfoObject(ringDevice.data);
|
|
104
|
+
this.recreateDeviceObjectTree().catch(e => this.catcher("Couldn't create Device Object Tree.", e));
|
|
105
|
+
this.updateDeviceInfoObject(ringDevice.data).catch(e => this.catcher("Couldn't update Device Info Object.", e));
|
|
82
106
|
this.updateHealth();
|
|
83
|
-
this.updateHistory();
|
|
107
|
+
this.updateHistory().catch(e => this.catcher("Couldn't update History.", e));
|
|
84
108
|
this.autoSched();
|
|
85
|
-
this.subscribeToEvents();
|
|
109
|
+
this.subscribeToEvents().catch(e => this.catcher("Couldn't subscribe to events.", e));
|
|
86
110
|
}
|
|
87
111
|
async startLivestream(duration) {
|
|
88
112
|
this.silly(`${this.shortId}.startLivestream()`);
|
|
89
|
-
duration
|
|
113
|
+
duration ??= this._durationLiveStream;
|
|
90
114
|
const { visURL, visPath, fullPath } = await this.prepareLivestreamTargetFile().catch((reason) => {
|
|
91
115
|
this.catcher("Couldn't prepare Livestream Target File.", reason);
|
|
92
|
-
return { visURL:
|
|
116
|
+
return { visURL: '', visPath: '', fullPath: '' };
|
|
93
117
|
});
|
|
94
118
|
if (!visURL || !visPath || !fullPath) {
|
|
95
119
|
await this.updateLivestreamRequest(false);
|
|
@@ -100,11 +124,13 @@ class OwnRingCamera extends ownRingDevice_1.OwnRingDevice {
|
|
|
100
124
|
await this.updateLivestreamRequest(false);
|
|
101
125
|
return;
|
|
102
126
|
}
|
|
103
|
-
const tempPath =
|
|
104
|
-
const liveCall = await this._ringDevice
|
|
127
|
+
const tempPath = `${await file_service_1.FileService.getTempDir(this._adapter)}/temp_${this.shortId}_livestream.mp4`;
|
|
128
|
+
const liveCall = await this._ringDevice
|
|
129
|
+
.streamVideo({
|
|
105
130
|
video: image_service_1.ImageService.videoFilter(this._adapter.config.overlay_Livestream, this._adapter.dateFormat, this._adapter.language, this._ringDevice.data.description),
|
|
106
|
-
output: [
|
|
107
|
-
})
|
|
131
|
+
output: ['-t', duration.toString(), tempPath],
|
|
132
|
+
})
|
|
133
|
+
.catch((reason) => {
|
|
108
134
|
this.catcher("Couldn't create Livestream (stream video).", reason);
|
|
109
135
|
return null;
|
|
110
136
|
});
|
|
@@ -113,9 +139,12 @@ class OwnRingCamera extends ownRingDevice_1.OwnRingDevice {
|
|
|
113
139
|
await this.updateLivestreamRequest(false);
|
|
114
140
|
return;
|
|
115
141
|
}
|
|
116
|
-
const liveCallSucceeded = await rxjs
|
|
142
|
+
const liveCallSucceeded = await rxjs
|
|
143
|
+
.firstValueFrom(liveCall.onCallEnded)
|
|
144
|
+
.then((_result) => {
|
|
117
145
|
return true;
|
|
118
|
-
})
|
|
146
|
+
})
|
|
147
|
+
.catch((reason) => {
|
|
119
148
|
this.catcher("Couldn't create Livestream (first value).", reason);
|
|
120
149
|
return null;
|
|
121
150
|
});
|
|
@@ -131,15 +160,15 @@ class OwnRingCamera extends ownRingDevice_1.OwnRingDevice {
|
|
|
131
160
|
this.catcher("Couldn't delete temp file.", err);
|
|
132
161
|
}
|
|
133
162
|
});
|
|
134
|
-
if (this._lastLiveStreamDir !==
|
|
163
|
+
if (this._lastLiveStreamDir !== '' && this._adapter.config.del_old_livestream) {
|
|
135
164
|
file_service_1.FileService.deleteFileIfExistSync(this._lastLiveStreamDir, this._adapter);
|
|
136
165
|
}
|
|
137
166
|
if (visPath) {
|
|
138
|
-
this.silly(`Locally storing
|
|
167
|
+
this.silly(`Locally storing FileStream (Length: ${video.length})`);
|
|
139
168
|
await file_service_1.FileService.writeFile(visPath, video, this._adapter);
|
|
140
169
|
this._lastLiveStreamUrl = visURL;
|
|
141
170
|
}
|
|
142
|
-
this.silly(`Writing
|
|
171
|
+
this.silly(`Writing FileStream (Length: ${video.length}) to "${fullPath}"`);
|
|
143
172
|
await file_service_1.FileService.writeFile(fullPath, video, this._adapter);
|
|
144
173
|
this._lastLiveStreamDir = fullPath;
|
|
145
174
|
this._lastLiveStreamTimestamp = Date.now();
|
|
@@ -147,15 +176,15 @@ class OwnRingCamera extends ownRingDevice_1.OwnRingDevice {
|
|
|
147
176
|
this.debug(`Done creating livestream to ${fullPath}`);
|
|
148
177
|
}
|
|
149
178
|
async takeHDSnapshot() {
|
|
150
|
-
|
|
179
|
+
// from very short Livestream
|
|
151
180
|
this.silly(`${this.shortId}.takeHDSnapshot()`);
|
|
152
181
|
// const duration = 2.0;
|
|
153
|
-
const { visURL, visPath } = await file_service_1.FileService.getVisUrl(this._adapter, this.fullId,
|
|
182
|
+
const { visURL, visPath } = await file_service_1.FileService.getVisUrl(this._adapter, this.fullId, 'HDSnapshot.jpg').catch((reason) => {
|
|
154
183
|
this.catcher("Couldn't get Vis URL.", reason);
|
|
155
|
-
return { visURL:
|
|
184
|
+
return { visURL: '', visPath: '' };
|
|
156
185
|
});
|
|
157
186
|
if (!visURL || !visPath) {
|
|
158
|
-
this.warn(
|
|
187
|
+
this.warn('Vis not available! Please install e.g. flot or other Vis related adapter');
|
|
159
188
|
await this.updateHDSnapshotRequest(false);
|
|
160
189
|
return;
|
|
161
190
|
}
|
|
@@ -172,12 +201,14 @@ class OwnRingCamera extends ownRingDevice_1.OwnRingDevice {
|
|
|
172
201
|
return;
|
|
173
202
|
}
|
|
174
203
|
const { night_contrast, night_sharpen } = this.getActiveNightImageOptions();
|
|
175
|
-
const tempPath =
|
|
176
|
-
const liveCall = await this._ringDevice
|
|
204
|
+
const tempPath = `${await file_service_1.FileService.getTempDir(this._adapter)}/temp_${this.shortId}_livestream.jpg`;
|
|
205
|
+
const liveCall = await this._ringDevice
|
|
206
|
+
.streamVideo({
|
|
177
207
|
video: image_service_1.ImageService.videoFilter(this._adapter.config.overlay_HDsnapshot, this._adapter.dateFormat, this._adapter.language, this._ringDevice.data.description, night_contrast ? this._adapter.config.contrast_HDsnapshot : 0),
|
|
178
208
|
// output: ["-t", duration.toString(), "-f", "mjpeg", "-q:v", 3, "-frames:v", 1, tempPath]
|
|
179
|
-
output: [
|
|
180
|
-
})
|
|
209
|
+
output: ['-f', 'mjpeg', '-q:v', 3, '-frames:v', 1, tempPath],
|
|
210
|
+
})
|
|
211
|
+
.catch((reason) => {
|
|
181
212
|
this.catcher("Couldn't create HD Snapshot (stream Video).", reason);
|
|
182
213
|
return null;
|
|
183
214
|
});
|
|
@@ -186,9 +217,12 @@ class OwnRingCamera extends ownRingDevice_1.OwnRingDevice {
|
|
|
186
217
|
await this.updateHDSnapshotRequest(false);
|
|
187
218
|
return;
|
|
188
219
|
}
|
|
189
|
-
const liveCallSucceeded = await rxjs
|
|
220
|
+
const liveCallSucceeded = await rxjs
|
|
221
|
+
.firstValueFrom(liveCall.onCallEnded)
|
|
222
|
+
.then((_result) => {
|
|
190
223
|
return true;
|
|
191
|
-
})
|
|
224
|
+
})
|
|
225
|
+
.catch((reason) => {
|
|
192
226
|
this.catcher("Couldn't create HD Snapshot (first value).", reason);
|
|
193
227
|
return null;
|
|
194
228
|
});
|
|
@@ -197,21 +231,20 @@ class OwnRingCamera extends ownRingDevice_1.OwnRingDevice {
|
|
|
197
231
|
await this.updateHDSnapshotRequest(false);
|
|
198
232
|
return;
|
|
199
233
|
}
|
|
200
|
-
|
|
201
|
-
this.silly("HD Snapshot from livestream created.");
|
|
202
|
-
}
|
|
234
|
+
this.silly('HD Snapshot from livestream created.');
|
|
203
235
|
let jpg = fs.readFileSync(tempPath);
|
|
204
236
|
if (night_sharpen && this._adapter.config.sharpen_HDsnapshot && this._adapter.config.sharpen_HDsnapshot > 0) {
|
|
205
237
|
const sharpen = this._adapter.config.sharpen_HDsnapshot == 1
|
|
206
238
|
? undefined
|
|
207
239
|
: { sigma: this._adapter.config.sharpen_HDsnapshot - 1 };
|
|
208
|
-
jpg =
|
|
209
|
-
.
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
240
|
+
jpg =
|
|
241
|
+
(await (0, sharp_1.default)(jpg)
|
|
242
|
+
.sharpen(sharpen)
|
|
243
|
+
.toBuffer()
|
|
244
|
+
.catch((reason) => {
|
|
245
|
+
this.catcher("Couldn't sharpen HD Snapshot.", reason);
|
|
246
|
+
return null;
|
|
247
|
+
})) ?? jpg;
|
|
215
248
|
}
|
|
216
249
|
// clean up
|
|
217
250
|
fs.unlink(tempPath, (err) => {
|
|
@@ -219,7 +252,7 @@ class OwnRingCamera extends ownRingDevice_1.OwnRingDevice {
|
|
|
219
252
|
this.catcher(`Couldn't delete temp file ${tempPath}`, err);
|
|
220
253
|
}
|
|
221
254
|
});
|
|
222
|
-
if (this._lastHDSnapShotDir !==
|
|
255
|
+
if (this._lastHDSnapShotDir !== '' && this._adapter.config.del_old_HDsnapshot) {
|
|
223
256
|
file_service_1.FileService.deleteFileIfExistSync(this._lastHDSnapShotDir, this._adapter);
|
|
224
257
|
}
|
|
225
258
|
if (visPath) {
|
|
@@ -242,7 +275,7 @@ class OwnRingCamera extends ownRingDevice_1.OwnRingDevice {
|
|
|
242
275
|
this.debug(`Toggling siren state for ${this.shortId} to ${state}`);
|
|
243
276
|
try {
|
|
244
277
|
await this._ringDevice.setSiren(state);
|
|
245
|
-
this._adapter.upsertState(`${this.sirenChannelId}.${constants_1.STATE_ID_SIREN_SWITCH}`, constants_1.COMMON_SIREN_SWITCH, state, true);
|
|
278
|
+
await this._adapter.upsertState(`${this.sirenChannelId}.${constants_1.STATE_ID_SIREN_SWITCH}`, constants_1.COMMON_SIREN_SWITCH, state, true);
|
|
246
279
|
this.debug(`Siren state set to ${state} successfully.`);
|
|
247
280
|
}
|
|
248
281
|
catch (err) {
|
|
@@ -251,9 +284,9 @@ class OwnRingCamera extends ownRingDevice_1.OwnRingDevice {
|
|
|
251
284
|
}
|
|
252
285
|
async takeSnapshot(uuid, eventBased = false) {
|
|
253
286
|
this.silly(`${this.shortId}.takeSnapshot()`);
|
|
254
|
-
const { visURL, visPath } = await file_service_1.FileService.getVisUrl(this._adapter, this.fullId,
|
|
287
|
+
const { visURL, visPath } = await file_service_1.FileService.getVisUrl(this._adapter, this.fullId, 'Snapshot.jpg');
|
|
255
288
|
if (!visURL || !visPath) {
|
|
256
|
-
this.warn(
|
|
289
|
+
this.warn('Vis not available');
|
|
257
290
|
}
|
|
258
291
|
const { fullPath, dirname } = file_service_1.FileService.getPath(this._adapter.config.path_snapshot, this._adapter.config.filename_snapshot, ++this._HDsnapshotCount, this.shortId, this.fullId, this.kind);
|
|
259
292
|
if (!(await file_service_1.FileService.prepareFolder(dirname))) {
|
|
@@ -267,21 +300,22 @@ class OwnRingCamera extends ownRingDevice_1.OwnRingDevice {
|
|
|
267
300
|
await this.updateSnapshotRequest(false);
|
|
268
301
|
return;
|
|
269
302
|
}
|
|
270
|
-
const image = await this._ringDevice
|
|
303
|
+
const image = await this._ringDevice
|
|
304
|
+
.getNextSnapshot({ force: true, uuid: uuid })
|
|
271
305
|
.then((result) => result)
|
|
272
306
|
.catch((err) => {
|
|
273
307
|
if (eventBased) {
|
|
274
|
-
this.warn(
|
|
308
|
+
this.warn('Taking Snapshot on Event failed.');
|
|
275
309
|
}
|
|
276
310
|
else {
|
|
277
311
|
this.catcher("Couldn't get Snapshot from api.", err);
|
|
278
312
|
}
|
|
279
|
-
this.updateSnapshotRequest(false);
|
|
313
|
+
this.updateSnapshotRequest(false).catch(err => this.catcher('Cannot update snapshot request.', err));
|
|
280
314
|
return err;
|
|
281
315
|
});
|
|
282
316
|
if (!image.byteLength) {
|
|
283
317
|
if (eventBased) {
|
|
284
|
-
this.warn(
|
|
318
|
+
this.warn('Taking Snapshot on Event failed (no image).');
|
|
285
319
|
}
|
|
286
320
|
else {
|
|
287
321
|
this.warn("Couldn't create snapshot from image");
|
|
@@ -289,23 +323,19 @@ class OwnRingCamera extends ownRingDevice_1.OwnRingDevice {
|
|
|
289
323
|
await this.updateSnapshotRequest(false);
|
|
290
324
|
return;
|
|
291
325
|
}
|
|
292
|
-
|
|
293
|
-
this.silly(`Response timestamp: ${image.responseTimestamp},
|
|
326
|
+
this.silly(`Response timestamp: ${image.responseTimestamp},
|
|
294
327
|
Byte Length: ${image.byteLength},
|
|
295
328
|
Byte Offset: ${image.byteOffset},
|
|
296
329
|
Length: ${image.length},
|
|
297
330
|
Time in ms: ${image.timeMillis}`);
|
|
298
|
-
}
|
|
299
331
|
let image_txt = image;
|
|
300
332
|
if (this._adapter.config.overlay_snapshot) {
|
|
301
|
-
image_txt =
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
return reason;
|
|
306
|
-
});
|
|
333
|
+
image_txt = await image_service_1.ImageService.addTextToJpgBuffer(image, this._ringDevice.data.description, (0, strftime_1.default)(`${text_service_1.TextService.getTodayName(this._adapter.language)}, ${text_service_1.TextService.getDateFormat(this._adapter.dateFormat)} %T`)).catch((reason) => {
|
|
334
|
+
this.catcher("Couldn't add text to Snapshot.", reason);
|
|
335
|
+
return reason;
|
|
336
|
+
});
|
|
307
337
|
}
|
|
308
|
-
if (this._lastSnapShotDir !==
|
|
338
|
+
if (this._lastSnapShotDir !== '' && this._adapter.config.del_old_snapshot) {
|
|
309
339
|
file_service_1.FileService.deleteFileIfExistSync(this._lastSnapShotDir, this._adapter);
|
|
310
340
|
}
|
|
311
341
|
this._lastSnapShotUrl = visURL;
|
|
@@ -322,16 +352,15 @@ class OwnRingCamera extends ownRingDevice_1.OwnRingDevice {
|
|
|
322
352
|
}
|
|
323
353
|
async updateHistory() {
|
|
324
354
|
this.silly(`Update History`);
|
|
325
|
-
this._ringDevice.getEvents({ limit: 50 })
|
|
326
|
-
.then(async (r) => {
|
|
355
|
+
await this._ringDevice.getEvents({ limit: 50 }).then(async (r) => {
|
|
327
356
|
this.silly(`Received Event History`);
|
|
328
357
|
const lastAction = r.events.find((event) => {
|
|
329
358
|
const kind = event.kind;
|
|
330
359
|
switch (kind) {
|
|
331
|
-
case
|
|
332
|
-
case
|
|
333
|
-
case
|
|
334
|
-
case
|
|
360
|
+
case 'motion':
|
|
361
|
+
case 'ding':
|
|
362
|
+
case 'alarm':
|
|
363
|
+
case 'on_demand':
|
|
335
364
|
return true;
|
|
336
365
|
}
|
|
337
366
|
return false;
|
|
@@ -341,39 +370,39 @@ class OwnRingCamera extends ownRingDevice_1.OwnRingDevice {
|
|
|
341
370
|
}
|
|
342
371
|
const url = await this._ringDevice.getRecordingUrl(lastAction.ding_id_str);
|
|
343
372
|
this.lastAction = new lastAction_1.LastAction(lastAction, url);
|
|
344
|
-
this.updateHistoryObject(this.lastAction);
|
|
373
|
+
await this.updateHistoryObject(this.lastAction);
|
|
345
374
|
});
|
|
346
375
|
}
|
|
347
376
|
async processUserInput(channelID, stateID, state) {
|
|
348
377
|
switch (channelID) {
|
|
349
|
-
case
|
|
378
|
+
case '': {
|
|
350
379
|
if (stateID !== constants_1.STATE_ID_DEBUG_REQUEST) {
|
|
351
380
|
return;
|
|
352
381
|
}
|
|
353
382
|
const targetVal = state.val;
|
|
354
383
|
if (targetVal) {
|
|
355
384
|
this.info(`Device Debug Data for ${this.shortId}: ${util.inspect(this._ringDevice, false, 1)}`);
|
|
356
|
-
this._adapter.upsertState(`${this.fullId}.${constants_1.STATE_ID_DEBUG_REQUEST}`, constants_1.COMMON_DEBUG_REQUEST, false);
|
|
385
|
+
await this._adapter.upsertState(`${this.fullId}.${constants_1.STATE_ID_DEBUG_REQUEST}`, constants_1.COMMON_DEBUG_REQUEST, false);
|
|
357
386
|
}
|
|
358
387
|
return;
|
|
359
|
-
|
|
388
|
+
}
|
|
389
|
+
case 'Siren':
|
|
360
390
|
if (!this._ringDevice.hasSiren) {
|
|
361
391
|
return;
|
|
362
392
|
}
|
|
363
393
|
if (stateID === constants_1.STATE_ID_SIREN_SWITCH) {
|
|
364
394
|
const targetVal = state.val;
|
|
365
395
|
this.debug(`Set siren for ${this.shortId} to value ${targetVal}`);
|
|
366
|
-
this._ringDevice.setSiren(targetVal)
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
});
|
|
396
|
+
const success = await this._ringDevice.setSiren(targetVal);
|
|
397
|
+
if (success) {
|
|
398
|
+
await this._adapter.upsertState(`${this.sirenChannelId}.${constants_1.STATE_ID_SIREN_SWITCH}`, constants_1.COMMON_SIREN_SWITCH, targetVal, true);
|
|
399
|
+
}
|
|
371
400
|
}
|
|
372
401
|
else {
|
|
373
402
|
this.error(`Unknown State/Switch with channel "${channelID}" and state "${stateID}"`);
|
|
374
403
|
}
|
|
375
404
|
break;
|
|
376
|
-
case
|
|
405
|
+
case 'Light':
|
|
377
406
|
if (!this._ringDevice.hasLight) {
|
|
378
407
|
return;
|
|
379
408
|
}
|
|
@@ -381,25 +410,24 @@ class OwnRingCamera extends ownRingDevice_1.OwnRingDevice {
|
|
|
381
410
|
const targetVal = state.val;
|
|
382
411
|
this.debug(`Set light for ${this.shortId} to value ${targetVal}`);
|
|
383
412
|
this._lastLightCommand = Date.now();
|
|
384
|
-
this._ringDevice.setLight(targetVal)
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
});
|
|
413
|
+
const success = await this._ringDevice.setLight(targetVal);
|
|
414
|
+
if (success) {
|
|
415
|
+
await this._adapter.upsertState(`${this.lightChannelId}.light_state`, constants_1.COMMON_LIGHT_STATE, targetVal);
|
|
416
|
+
await this._adapter.upsertState(`${this.lightChannelId}.light_switch`, constants_1.COMMON_LIGHT_SWITCH, targetVal, true);
|
|
417
|
+
this._adapter.setTimeout(() => void this.updateHealth(), 65000);
|
|
418
|
+
}
|
|
391
419
|
}
|
|
392
420
|
else {
|
|
393
421
|
this.error(`Unknown State/Switch with channel "${channelID}" and state "${stateID}"`);
|
|
394
422
|
}
|
|
395
423
|
break;
|
|
396
|
-
case
|
|
424
|
+
case 'Snapshot':
|
|
397
425
|
if (stateID === constants_1.STATE_ID_SNAPSHOT_REQUEST) {
|
|
398
426
|
const targetVal = state.val;
|
|
399
427
|
this.debug(`Get Snapshot request for ${this.shortId} to value ${targetVal}`);
|
|
400
428
|
if (targetVal) {
|
|
401
429
|
await this.takeSnapshot().catch((reason) => {
|
|
402
|
-
this.updateSnapshotRequest(false);
|
|
430
|
+
this.updateSnapshotRequest(false).catch(e => this.catcher('Cannot update snapshot request', e));
|
|
403
431
|
this.catcher("Couldn't retrieve Snapshot.", reason);
|
|
404
432
|
});
|
|
405
433
|
}
|
|
@@ -408,13 +436,13 @@ class OwnRingCamera extends ownRingDevice_1.OwnRingDevice {
|
|
|
408
436
|
this.error(`Unknown State/Switch with channel "${channelID}" and state "${stateID}"`);
|
|
409
437
|
}
|
|
410
438
|
break;
|
|
411
|
-
case
|
|
439
|
+
case 'HD Snapshot':
|
|
412
440
|
if (stateID === constants_1.STATE_ID_HDSNAPSHOT_REQUEST) {
|
|
413
441
|
const targetVal = state.val;
|
|
414
442
|
this.debug(`Get HDSnapshot request for ${this.shortId} to value ${targetVal}`);
|
|
415
443
|
if (targetVal) {
|
|
416
444
|
await this.takeHDSnapshot().catch((reason) => {
|
|
417
|
-
this.updateHDSnapshotRequest(false);
|
|
445
|
+
this.updateHDSnapshotRequest(false).catch(e => this.catcher('Cannot update HD snapshot request', e));
|
|
418
446
|
this.catcher("Couldn't retrieve HDSnapshot.", reason);
|
|
419
447
|
});
|
|
420
448
|
}
|
|
@@ -423,13 +451,13 @@ class OwnRingCamera extends ownRingDevice_1.OwnRingDevice {
|
|
|
423
451
|
this.error(`Unknown State/Switch with channel "${channelID}" and state "${stateID}"`);
|
|
424
452
|
}
|
|
425
453
|
break;
|
|
426
|
-
case
|
|
454
|
+
case 'Livestream':
|
|
427
455
|
if (stateID === constants_1.STATE_ID_LIVESTREAM_REQUEST) {
|
|
428
456
|
const targetVal = state.val;
|
|
429
457
|
this.debug(`Get Livestream request for ${this.shortId} to value ${targetVal}`);
|
|
430
458
|
if (targetVal) {
|
|
431
459
|
await this.startLivestream().catch((reason) => {
|
|
432
|
-
this.updateLivestreamRequest(false);
|
|
460
|
+
this.updateLivestreamRequest(false).catch(e => this.catcher('Cannot update Livestream request', e));
|
|
433
461
|
this.catcher("Couldn't retrieve Livestream.", reason);
|
|
434
462
|
});
|
|
435
463
|
}
|
|
@@ -450,49 +478,49 @@ class OwnRingCamera extends ownRingDevice_1.OwnRingDevice {
|
|
|
450
478
|
async recreateDeviceObjectTree() {
|
|
451
479
|
this.silly(`Recreate DeviceObjectTree`);
|
|
452
480
|
await this._adapter.setObjectNotExistsAsync(this.fullId, {
|
|
453
|
-
type:
|
|
481
|
+
type: 'device',
|
|
454
482
|
common: {
|
|
455
483
|
name: `Device ${this.shortId} ("${this._ringDevice.data.description}")`,
|
|
456
484
|
},
|
|
457
485
|
native: {},
|
|
458
486
|
});
|
|
459
487
|
await this._adapter.setObjectNotExistsAsync(`${this.fullId}.${constants_1.CHANNEL_NAME_INFO}`, {
|
|
460
|
-
type:
|
|
488
|
+
type: 'channel',
|
|
461
489
|
common: {
|
|
462
490
|
name: `Info ${this.shortId}`,
|
|
463
491
|
},
|
|
464
492
|
native: {},
|
|
465
493
|
});
|
|
466
494
|
await this._adapter.setObjectNotExistsAsync(`${this.fullId}.${constants_1.CHANNEL_NAME_SNAPSHOT}`, {
|
|
467
|
-
type:
|
|
495
|
+
type: 'channel',
|
|
468
496
|
common: {
|
|
469
497
|
name: `Snapshot ${this.shortId}`,
|
|
470
498
|
},
|
|
471
499
|
native: {},
|
|
472
500
|
});
|
|
473
501
|
await this._adapter.setObjectNotExistsAsync(`${this.fullId}.${constants_1.CHANNEL_NAME_HDSNAPSHOT}`, {
|
|
474
|
-
type:
|
|
502
|
+
type: 'channel',
|
|
475
503
|
common: {
|
|
476
504
|
name: `HD Snapshot ${this.shortId}`,
|
|
477
505
|
},
|
|
478
506
|
native: {},
|
|
479
507
|
});
|
|
480
508
|
await this._adapter.setObjectNotExistsAsync(`${this.fullId}.${constants_1.CHANNEL_NAME_LIVESTREAM}`, {
|
|
481
|
-
type:
|
|
509
|
+
type: 'channel',
|
|
482
510
|
common: {
|
|
483
511
|
name: `Livestream ${this.shortId}`,
|
|
484
512
|
},
|
|
485
513
|
native: {},
|
|
486
514
|
});
|
|
487
515
|
await this._adapter.setObjectNotExistsAsync(`${this.fullId}.${constants_1.CHANNEL_NAME_HISTORY}`, {
|
|
488
|
-
type:
|
|
516
|
+
type: 'channel',
|
|
489
517
|
common: {
|
|
490
518
|
name: `History`,
|
|
491
519
|
},
|
|
492
520
|
native: {},
|
|
493
521
|
});
|
|
494
522
|
await this._adapter.setObjectNotExistsAsync(`${this.fullId}.${constants_1.CHANNEL_NAME_EVENTS}`, {
|
|
495
|
-
type:
|
|
523
|
+
type: 'channel',
|
|
496
524
|
common: {
|
|
497
525
|
name: `Events`,
|
|
498
526
|
},
|
|
@@ -502,7 +530,7 @@ class OwnRingCamera extends ownRingDevice_1.OwnRingDevice {
|
|
|
502
530
|
this.debug(`Device with Siren Capabilities detected`);
|
|
503
531
|
// Ersetzen von createChannel durch setObjectNotExistsAsync
|
|
504
532
|
await this._adapter.setObjectNotExistsAsync(`${this.fullId}.${constants_1.CHANNEL_NAME_SIREN}`, {
|
|
505
|
-
type:
|
|
533
|
+
type: 'channel',
|
|
506
534
|
common: {
|
|
507
535
|
name: `Siren ${this.shortId}`,
|
|
508
536
|
},
|
|
@@ -514,7 +542,7 @@ class OwnRingCamera extends ownRingDevice_1.OwnRingDevice {
|
|
|
514
542
|
this.debug(`Device with Light Capabilities detected`);
|
|
515
543
|
// Ersetzen von createChannel durch setObjectNotExistsAsync
|
|
516
544
|
await this._adapter.setObjectNotExistsAsync(`${this.fullId}.${constants_1.CHANNEL_NAME_LIGHT}`, {
|
|
517
|
-
type:
|
|
545
|
+
type: 'channel',
|
|
518
546
|
common: {
|
|
519
547
|
name: `Light ${this.shortId}`,
|
|
520
548
|
},
|
|
@@ -525,51 +553,51 @@ class OwnRingCamera extends ownRingDevice_1.OwnRingDevice {
|
|
|
525
553
|
this._lastSnapShotDir = await this._adapter.tryGetStringState(`${this.snapshotChannelId}.file`);
|
|
526
554
|
this._lastHDSnapShotDir = await this._adapter.tryGetStringState(`${this.HDsnapshotChannelId}.file`);
|
|
527
555
|
this._lastLiveStreamDir = await this._adapter.tryGetStringState(`${this.liveStreamChannelId}.file`);
|
|
528
|
-
if (this._adapter.config.auto_snapshot === undefined)
|
|
556
|
+
if (this._adapter.config.auto_snapshot === undefined) {
|
|
529
557
|
this._adapter.config.auto_snapshot = false;
|
|
530
|
-
|
|
558
|
+
}
|
|
559
|
+
if (this._adapter.config.auto_HDsnapshot === undefined) {
|
|
531
560
|
this._adapter.config.auto_HDsnapshot = false;
|
|
532
|
-
|
|
561
|
+
}
|
|
562
|
+
if (this._adapter.config.auto_livestream === undefined) {
|
|
533
563
|
this._adapter.config.auto_livestream = false;
|
|
564
|
+
}
|
|
534
565
|
await this._adapter.upsertState(`${this.fullId}.${constants_1.STATE_ID_DEBUG_REQUEST}`, constants_1.COMMON_DEBUG_REQUEST, false, true, true);
|
|
535
566
|
await this._adapter.upsertState(`${this.snapshotChannelId}.${constants_1.STATE_ID_SNAPSHOT_REQUEST}`, constants_1.COMMON_SNAPSHOT_REQUEST, false, true, true);
|
|
536
567
|
await this._adapter.upsertState(`${this.HDsnapshotChannelId}.${constants_1.STATE_ID_HDSNAPSHOT_REQUEST}`, constants_1.COMMON_HDSNAPSHOT_REQUEST, false, true, true);
|
|
537
568
|
await this._adapter.upsertState(`${this.liveStreamChannelId}.${constants_1.STATE_ID_LIVESTREAM_REQUEST}`, constants_1.COMMON_LIVESTREAM_REQUEST, false, true, true);
|
|
538
|
-
this._adapter.upsertState(`${this.liveStreamChannelId}.${constants_1.STATE_ID_LIVESTREAM_DURATION}`, constants_1.COMMON_LIVESTREAM_DURATION, this._durationLiveStream, true);
|
|
539
|
-
this._adapter.upsertState(`${this.eventsChannelId}.ondemand`, constants_1.COMMON_ON_DEMAND, false);
|
|
540
|
-
this._adapter.upsertState(`${this.snapshotChannelId}.auto`, constants_1.COMMON_SNAPSHOT_AUTO, this._adapter.config.auto_snapshot);
|
|
541
|
-
this._adapter.upsertState(`${this.HDsnapshotChannelId}.auto`, constants_1.COMMON_HDSNAPSHOT_AUTO, this._adapter.config.auto_HDsnapshot);
|
|
542
|
-
this._adapter.upsertState(`${this.liveStreamChannelId}.auto`, constants_1.COMMON_LIVESTREAM_AUTO, this._adapter.config.auto_livestream);
|
|
569
|
+
await this._adapter.upsertState(`${this.liveStreamChannelId}.${constants_1.STATE_ID_LIVESTREAM_DURATION}`, constants_1.COMMON_LIVESTREAM_DURATION, this._durationLiveStream, true);
|
|
570
|
+
await this._adapter.upsertState(`${this.eventsChannelId}.ondemand`, constants_1.COMMON_ON_DEMAND, false);
|
|
571
|
+
await this._adapter.upsertState(`${this.snapshotChannelId}.auto`, constants_1.COMMON_SNAPSHOT_AUTO, this._adapter.config.auto_snapshot);
|
|
572
|
+
await this._adapter.upsertState(`${this.HDsnapshotChannelId}.auto`, constants_1.COMMON_HDSNAPSHOT_AUTO, this._adapter.config.auto_HDsnapshot);
|
|
573
|
+
await this._adapter.upsertState(`${this.liveStreamChannelId}.auto`, constants_1.COMMON_LIVESTREAM_AUTO, this._adapter.config.auto_livestream);
|
|
543
574
|
// Remove legacy states
|
|
544
|
-
this._adapter.
|
|
545
|
-
this._adapter.
|
|
546
|
-
this._adapter.
|
|
547
|
-
this._adapter.
|
|
548
|
-
this._adapter.
|
|
549
|
-
this._adapter.
|
|
575
|
+
await this._adapter.delObjectAsync(`${this.snapshotChannelId}.snapshot_file`);
|
|
576
|
+
await this._adapter.delObjectAsync(`${this.snapshotChannelId}.snapshot_url`);
|
|
577
|
+
await this._adapter.delObjectAsync(`${this.HDsnapshotChannelId}.snapshot_file`);
|
|
578
|
+
await this._adapter.delObjectAsync(`${this.HDsnapshotChannelId}.snapshot_url`);
|
|
579
|
+
await this._adapter.delObjectAsync(`${this.liveStreamChannelId}.livestream_file`);
|
|
580
|
+
await this._adapter.delObjectAsync(`${this.liveStreamChannelId}.livestream_url`);
|
|
550
581
|
}
|
|
551
582
|
async prepareLivestreamTargetFile() {
|
|
552
|
-
const { visURL, visPath } = await file_service_1.FileService.getVisUrl(this._adapter, this.fullId,
|
|
583
|
+
const { visURL, visPath } = await file_service_1.FileService.getVisUrl(this._adapter, this.fullId, 'Livestream.mp4').catch((reason) => {
|
|
553
584
|
this.catcher("Couldn't get Vis URL.", reason);
|
|
554
|
-
return { visURL:
|
|
585
|
+
return { visURL: '', visPath: '' };
|
|
555
586
|
});
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
return false;
|
|
564
|
-
});
|
|
565
|
-
if (!folderPrepared) {
|
|
566
|
-
this.warn(`Failed to prepare Livestream folder ("${fullPath}")`);
|
|
567
|
-
reject("Failed to prepare Livestream folder");
|
|
568
|
-
return;
|
|
569
|
-
}
|
|
570
|
-
file_service_1.FileService.deleteFileIfExistSync(fullPath, this._adapter);
|
|
571
|
-
resolve({ visURL: visURL, visPath: visPath, fullPath: fullPath });
|
|
587
|
+
if (!visURL || !visPath) {
|
|
588
|
+
throw new Error('Vis not available');
|
|
589
|
+
}
|
|
590
|
+
const { fullPath, dirname } = file_service_1.FileService.getPath(this._adapter.config.path_livestream, this._adapter.config.filename_livestream, ++this._liveStreamCount, this.shortId, this.fullId, this.kind);
|
|
591
|
+
const folderPrepared = await file_service_1.FileService.prepareFolder(dirname).catch((reason) => {
|
|
592
|
+
this.catcher("Couldn't prepare folder.", reason);
|
|
593
|
+
return false;
|
|
572
594
|
});
|
|
595
|
+
if (!folderPrepared) {
|
|
596
|
+
this.warn(`Failed to prepare Livestream folder ("${fullPath}")`);
|
|
597
|
+
throw new Error('Failed to prepare Livestream folder');
|
|
598
|
+
}
|
|
599
|
+
file_service_1.FileService.deleteFileIfExistSync(fullPath, this._adapter);
|
|
600
|
+
return { visURL: visURL, visPath: visPath, fullPath: fullPath };
|
|
573
601
|
}
|
|
574
602
|
getActiveNightImageOptions() {
|
|
575
603
|
let night_contrast = false;
|
|
@@ -579,73 +607,82 @@ class OwnRingCamera extends ownRingDevice_1.OwnRingDevice {
|
|
|
579
607
|
this.silly(`Now: ${today}, sunrise: ${this._adapter.Sunrise}, sunset: ${this._adapter.Sunset}`);
|
|
580
608
|
const isNight = today < this._adapter.Sunrise || today > this._adapter.Sunset;
|
|
581
609
|
this.debug(`is Night: ${isNight}`);
|
|
582
|
-
night_contrast =
|
|
583
|
-
|
|
610
|
+
night_contrast =
|
|
611
|
+
(this._adapter.config.night_contrast_HDsnapshot && isNight) ||
|
|
612
|
+
!this._adapter.config.night_contrast_HDsnapshot;
|
|
613
|
+
night_sharpen =
|
|
614
|
+
(this._adapter.config.night_sharpen_HDsnapshot && isNight) ||
|
|
615
|
+
!this._adapter.config.night_sharpen_HDsnapshot;
|
|
584
616
|
}
|
|
585
617
|
return { night_contrast, night_sharpen };
|
|
586
618
|
}
|
|
587
619
|
updateByDevice(ringDevice) {
|
|
588
620
|
this._ringDevice = ringDevice;
|
|
589
|
-
this.subscribeToEvents();
|
|
621
|
+
this.subscribeToEvents().catch(e => this.catcher("Couldn't subscribe to events.", e));
|
|
590
622
|
this._state = EventState.Idle;
|
|
591
|
-
this.update(ringDevice.data);
|
|
623
|
+
this.update(ringDevice.data).catch(e => this.catcher("Couldn't update device data.", e));
|
|
592
624
|
}
|
|
593
|
-
update(data) {
|
|
625
|
+
async update(data) {
|
|
594
626
|
this.debug(`Received Update`);
|
|
595
|
-
this.updateDeviceInfoObject(data);
|
|
627
|
+
await this.updateDeviceInfoObject(data);
|
|
596
628
|
this.updateHealth();
|
|
597
|
-
this.updateHistory();
|
|
629
|
+
this.updateHistory().catch(e => this.catcher("Couldn't update History.", e));
|
|
598
630
|
}
|
|
599
631
|
setDurationLivestream(val) {
|
|
600
632
|
this.silly(`${this.shortId}.durationLivestream()`);
|
|
601
633
|
this._durationLiveStream = val;
|
|
602
|
-
this._adapter
|
|
634
|
+
this._adapter
|
|
635
|
+
.upsertState(`${this.liveStreamChannelId}.${constants_1.STATE_ID_LIVESTREAM_DURATION}`, constants_1.COMMON_LIVESTREAM_DURATION, this._durationLiveStream)
|
|
636
|
+
.catch(e => this.catcher(`Cannot upsert state ${this.liveStreamChannelId}.${constants_1.STATE_ID_LIVESTREAM_DURATION}`, e));
|
|
603
637
|
this.debug(`Livestream duration set to: ${val}`);
|
|
604
638
|
}
|
|
605
639
|
updateHealth() {
|
|
606
640
|
this.silly(`Update Health`);
|
|
607
|
-
this._ringDevice
|
|
641
|
+
this._ringDevice
|
|
642
|
+
.getHealth()
|
|
643
|
+
.then(this.updateHealthObject.bind(this))
|
|
644
|
+
.catch(e => this.catcher("Couldn't update Health.", e));
|
|
608
645
|
}
|
|
609
646
|
autoSched() {
|
|
610
647
|
const media = [
|
|
611
648
|
{
|
|
612
|
-
name:
|
|
649
|
+
name: 'Snaspshot',
|
|
613
650
|
val: this._adapter.config.save_snapshot,
|
|
614
651
|
fct: () => {
|
|
615
|
-
this.takeSnapshot();
|
|
652
|
+
this.takeSnapshot().catch(e => this.catcher('Cannot take snapshot', e));
|
|
616
653
|
},
|
|
617
|
-
start: 0
|
|
654
|
+
start: 0,
|
|
618
655
|
},
|
|
619
656
|
{
|
|
620
|
-
name:
|
|
657
|
+
name: 'HD Snapshot',
|
|
621
658
|
val: this._adapter.config.save_HDsnapshot,
|
|
622
659
|
fct: () => {
|
|
623
|
-
this.takeHDSnapshot();
|
|
660
|
+
this.takeHDSnapshot().catch(e => this.catcher('Cannot take HD snapshot', e));
|
|
624
661
|
},
|
|
625
|
-
start: 20
|
|
662
|
+
start: 20,
|
|
626
663
|
},
|
|
627
664
|
{
|
|
628
|
-
name:
|
|
665
|
+
name: 'Livestream',
|
|
629
666
|
val: this._adapter.config.save_livestream,
|
|
630
667
|
fct: () => {
|
|
631
|
-
this.startLivestream(this._adapter.config.recordtime_auto_livestream);
|
|
668
|
+
this.startLivestream(this._adapter.config.recordtime_auto_livestream).catch(e => this.catcher('Cannot start livestream', e));
|
|
632
669
|
},
|
|
633
|
-
start: 40
|
|
634
|
-
}
|
|
670
|
+
start: 40,
|
|
671
|
+
},
|
|
635
672
|
];
|
|
636
673
|
for (const m of media) {
|
|
637
674
|
if (m.val > 0) {
|
|
638
675
|
let schedSec = m.start.toString();
|
|
639
|
-
let schedMin =
|
|
640
|
-
let schedHour =
|
|
641
|
-
let schedDay =
|
|
676
|
+
let schedMin = '*';
|
|
677
|
+
let schedHour = '*';
|
|
678
|
+
let schedDay = '*';
|
|
642
679
|
if (m.val < 60) {
|
|
643
680
|
schedSec = `*/${m.val.toString()}`;
|
|
644
681
|
}
|
|
645
682
|
else if (m.val < 3600) {
|
|
646
683
|
schedMin = `*/${(m.val / 60).toString()}`;
|
|
647
684
|
}
|
|
648
|
-
else if (m.val < 43.
|
|
685
|
+
else if (m.val < 43.2) {
|
|
649
686
|
schedHour = `*/${(m.val / 3600).toString()}`;
|
|
650
687
|
}
|
|
651
688
|
else {
|
|
@@ -653,17 +690,19 @@ class OwnRingCamera extends ownRingDevice_1.OwnRingDevice {
|
|
|
653
690
|
}
|
|
654
691
|
const t = `${schedSec} ${schedMin} ${schedHour} ${schedDay} * *`;
|
|
655
692
|
this.info(`Create scheduled Job for ${m.name} at "${t}"`);
|
|
656
|
-
node_schedule_1.default.scheduleJob(`Auto save ${m.name}_${this._adapter.name}_${this._adapter.instance}`, t, async () => {
|
|
693
|
+
this._adapter.registerScheduledJob(node_schedule_1.default.scheduleJob(`Auto save ${m.name}_${this._adapter.name}_${this._adapter.instance}`, t, async () => {
|
|
657
694
|
const recAct = await this._adapter.getStateAsync(`${this.eventsChannelId}.ondemand`);
|
|
658
695
|
if (!recAct || !recAct.val) {
|
|
659
696
|
this.info(`Cronjob Auto save ${m.name} starts`);
|
|
660
|
-
this._adapter
|
|
697
|
+
this._adapter
|
|
698
|
+
.upsertState(`${this.eventsChannelId}.ondemand`, constants_1.COMMON_ON_DEMAND, true)
|
|
699
|
+
.catch(e => this.catcher(`Cannot upsert state ${this.eventsChannelId}.ondemand`, e));
|
|
661
700
|
m.fct(this._adapter.config.recordtime_auto_livestream);
|
|
662
701
|
}
|
|
663
702
|
else {
|
|
664
703
|
this.warn(`Cronjob ${m.name} not executed because another job is already running. Please adapt timer and/or duration time!`);
|
|
665
704
|
}
|
|
666
|
-
});
|
|
705
|
+
}));
|
|
667
706
|
}
|
|
668
707
|
}
|
|
669
708
|
}
|
|
@@ -678,7 +717,7 @@ class OwnRingCamera extends ownRingDevice_1.OwnRingDevice {
|
|
|
678
717
|
this._ringDevice.onData.subscribe(this.update.bind(this));
|
|
679
718
|
this._ringDevice.onMotionDetected.subscribe({
|
|
680
719
|
next: (motion) => {
|
|
681
|
-
this.onMotion(motion);
|
|
720
|
+
this.onMotion(motion).catch(e => this.catcher('Cannot react on motion', e));
|
|
682
721
|
},
|
|
683
722
|
error: (err) => {
|
|
684
723
|
this.catcher(`Motion Observer received error`, err);
|
|
@@ -686,7 +725,7 @@ class OwnRingCamera extends ownRingDevice_1.OwnRingDevice {
|
|
|
686
725
|
});
|
|
687
726
|
this._ringDevice.onDoorbellPressed.subscribe({
|
|
688
727
|
next: (ding) => {
|
|
689
|
-
this.onDoorbell(ding);
|
|
728
|
+
this.onDoorbell(ding).catch(e => this.catcher('Cannot react on doorbell', e));
|
|
690
729
|
},
|
|
691
730
|
error: (err) => {
|
|
692
731
|
this.catcher(`Doorbell Observer received error`, err);
|
|
@@ -694,93 +733,91 @@ class OwnRingCamera extends ownRingDevice_1.OwnRingDevice {
|
|
|
694
733
|
});
|
|
695
734
|
this._ringDevice.onNewNotification.subscribe({
|
|
696
735
|
next: (ding) => {
|
|
697
|
-
this.onNotify(ding);
|
|
736
|
+
this.onNotify(ding).catch(e => this.catcher('Cannot react on notification', e));
|
|
698
737
|
},
|
|
699
738
|
error: (err) => {
|
|
700
739
|
this.catcher(`Notify Observer received error`, err);
|
|
701
740
|
},
|
|
702
741
|
});
|
|
703
742
|
}
|
|
704
|
-
updateDeviceInfoObject(data) {
|
|
705
|
-
this._adapter.upsertState(`${this.infoChannelId}.id`, constants_1.COMMON_INFO_ID, data.device_id);
|
|
706
|
-
this._adapter.upsertState(`${this.infoChannelId}.kind`, constants_1.COMMON_INFO_KIND, data.kind);
|
|
707
|
-
this._adapter.upsertState(`${this.infoChannelId}.description`, constants_1.COMMON_INFO_DESCRIPTION, data.description);
|
|
708
|
-
this._adapter.upsertState(`${this.infoChannelId}.external_connection`, constants_1.COMMON_INFO_EXTERNAL_CONNECTION, data.external_connection);
|
|
709
|
-
this._adapter.upsertState(`${this.infoChannelId}.hasLight`, constants_1.COMMON_INFO_HAS_LIGHT, this._ringDevice.hasLight);
|
|
710
|
-
this._adapter.upsertState(`${this.infoChannelId}.hasBattery`, constants_1.COMMON_INFO_HAS_BATTERY, this._ringDevice.hasBattery);
|
|
711
|
-
this._adapter.upsertState(`${this.infoChannelId}.hasSiren`, constants_1.COMMON_INFO_HAS_SIREN, this._ringDevice.hasSiren);
|
|
743
|
+
async updateDeviceInfoObject(data) {
|
|
744
|
+
await this._adapter.upsertState(`${this.infoChannelId}.id`, constants_1.COMMON_INFO_ID, data.device_id);
|
|
745
|
+
await this._adapter.upsertState(`${this.infoChannelId}.kind`, constants_1.COMMON_INFO_KIND, data.kind);
|
|
746
|
+
await this._adapter.upsertState(`${this.infoChannelId}.description`, constants_1.COMMON_INFO_DESCRIPTION, data.description);
|
|
747
|
+
await this._adapter.upsertState(`${this.infoChannelId}.external_connection`, constants_1.COMMON_INFO_EXTERNAL_CONNECTION, data.external_connection);
|
|
748
|
+
await this._adapter.upsertState(`${this.infoChannelId}.hasLight`, constants_1.COMMON_INFO_HAS_LIGHT, this._ringDevice.hasLight);
|
|
749
|
+
await this._adapter.upsertState(`${this.infoChannelId}.hasBattery`, constants_1.COMMON_INFO_HAS_BATTERY, this._ringDevice.hasBattery);
|
|
750
|
+
await this._adapter.upsertState(`${this.infoChannelId}.hasSiren`, constants_1.COMMON_INFO_HAS_SIREN, this._ringDevice.hasSiren);
|
|
712
751
|
}
|
|
713
|
-
updateHistoryObject(lastAction) {
|
|
714
|
-
this._adapter.upsertState(`${this.historyChannelId}.created_at`, constants_1.COMMON_HISTORY_CREATED_AT, lastAction.event.created_at);
|
|
715
|
-
this._adapter.upsertState(`${this.historyChannelId}.history_url`, constants_1.COMMON_HISTORY_URL, lastAction.historyUrl);
|
|
716
|
-
this._adapter.upsertState(`${this.historyChannelId}.kind`, constants_1.COMMON_HISTORY_KIND, lastAction.event.kind);
|
|
752
|
+
async updateHistoryObject(lastAction) {
|
|
753
|
+
await this._adapter.upsertState(`${this.historyChannelId}.created_at`, constants_1.COMMON_HISTORY_CREATED_AT, lastAction.event.created_at);
|
|
754
|
+
await this._adapter.upsertState(`${this.historyChannelId}.history_url`, constants_1.COMMON_HISTORY_URL, lastAction.historyUrl);
|
|
755
|
+
await this._adapter.upsertState(`${this.historyChannelId}.kind`, constants_1.COMMON_HISTORY_KIND, lastAction.event.kind);
|
|
717
756
|
}
|
|
718
757
|
async updateSnapshotRequest(ack = true) {
|
|
719
|
-
this._adapter.upsertState(`${this.eventsChannelId}.ondemand`, constants_1.COMMON_ON_DEMAND, false);
|
|
758
|
+
await this._adapter.upsertState(`${this.eventsChannelId}.ondemand`, constants_1.COMMON_ON_DEMAND, false);
|
|
720
759
|
// subscribe to true, because user request doesn't change value via upsertState
|
|
721
|
-
this._adapter.upsertState(`${this.snapshotChannelId}.${constants_1.STATE_ID_SNAPSHOT_REQUEST}`, constants_1.COMMON_SNAPSHOT_REQUEST, false, ack, true);
|
|
760
|
+
await this._adapter.upsertState(`${this.snapshotChannelId}.${constants_1.STATE_ID_SNAPSHOT_REQUEST}`, constants_1.COMMON_SNAPSHOT_REQUEST, false, ack, true);
|
|
722
761
|
}
|
|
723
762
|
async updateHDSnapshotRequest(ack = true) {
|
|
724
|
-
this._adapter.upsertState(`${this.eventsChannelId}.ondemand`, constants_1.COMMON_ON_DEMAND, false);
|
|
763
|
+
await this._adapter.upsertState(`${this.eventsChannelId}.ondemand`, constants_1.COMMON_ON_DEMAND, false);
|
|
725
764
|
// subscribe to true, because user request doesn't change value via upsertState
|
|
726
|
-
this._adapter.upsertState(`${this.HDsnapshotChannelId}.${constants_1.STATE_ID_HDSNAPSHOT_REQUEST}`, constants_1.COMMON_HDSNAPSHOT_REQUEST, false, ack, true);
|
|
765
|
+
await this._adapter.upsertState(`${this.HDsnapshotChannelId}.${constants_1.STATE_ID_HDSNAPSHOT_REQUEST}`, constants_1.COMMON_HDSNAPSHOT_REQUEST, false, ack, true);
|
|
727
766
|
}
|
|
728
767
|
async updateLivestreamRequest(ack = true) {
|
|
729
|
-
this._adapter.upsertState(`${this.eventsChannelId}.ondemand`, constants_1.COMMON_ON_DEMAND, false);
|
|
768
|
+
await this._adapter.upsertState(`${this.eventsChannelId}.ondemand`, constants_1.COMMON_ON_DEMAND, false);
|
|
730
769
|
// subscribe to true, because user request doesn't change value via upsertState
|
|
731
|
-
this._adapter.upsertState(`${this.liveStreamChannelId}.${constants_1.STATE_ID_LIVESTREAM_REQUEST}`, constants_1.COMMON_LIVESTREAM_REQUEST, false, ack, true);
|
|
770
|
+
await this._adapter.upsertState(`${this.liveStreamChannelId}.${constants_1.STATE_ID_LIVESTREAM_REQUEST}`, constants_1.COMMON_LIVESTREAM_REQUEST, false, ack, true);
|
|
732
771
|
this._durationLiveStream = this._adapter.config.recordtime_livestream;
|
|
733
|
-
this._adapter.upsertState(`${this.liveStreamChannelId}.${constants_1.STATE_ID_LIVESTREAM_DURATION}`, constants_1.COMMON_LIVESTREAM_DURATION, this._durationLiveStream, ack);
|
|
772
|
+
await this._adapter.upsertState(`${this.liveStreamChannelId}.${constants_1.STATE_ID_LIVESTREAM_DURATION}`, constants_1.COMMON_LIVESTREAM_DURATION, this._durationLiveStream, ack);
|
|
734
773
|
}
|
|
735
774
|
async updateSnapshotObject() {
|
|
736
775
|
this.debug(`Update Snapshot Object`);
|
|
737
776
|
if (this._lastSnapshotTimestamp !== 0) {
|
|
738
|
-
this._adapter.upsertState(`${this.snapshotChannelId}.file`, constants_1.COMMON_SNAPSHOT_FILE, this._lastSnapShotDir);
|
|
739
|
-
this._adapter.upsertState(`${this.snapshotChannelId}.moment`, constants_1.COMMON_SNAPSHOT_MOMENT, this._lastSnapshotTimestamp);
|
|
740
|
-
this._adapter.upsertState(`${this.snapshotChannelId}.url`, constants_1.COMMON_SNAPSHOT_URL, this._lastSnapShotUrl);
|
|
777
|
+
await this._adapter.upsertState(`${this.snapshotChannelId}.file`, constants_1.COMMON_SNAPSHOT_FILE, this._lastSnapShotDir);
|
|
778
|
+
await this._adapter.upsertState(`${this.snapshotChannelId}.moment`, constants_1.COMMON_SNAPSHOT_MOMENT, this._lastSnapshotTimestamp);
|
|
779
|
+
await this._adapter.upsertState(`${this.snapshotChannelId}.url`, constants_1.COMMON_SNAPSHOT_URL, this._lastSnapShotUrl);
|
|
741
780
|
}
|
|
742
781
|
await this.updateSnapshotRequest();
|
|
743
782
|
}
|
|
744
783
|
async updateHDSnapshotObject() {
|
|
745
784
|
this.debug(`Update HD Snapshot Object`);
|
|
746
785
|
if (this._lastHDSnapshotTimestamp !== 0) {
|
|
747
|
-
this._adapter.upsertState(`${this.HDsnapshotChannelId}.file`, constants_1.COMMON_HDSNAPSHOT_FILE, this._lastHDSnapShotDir);
|
|
748
|
-
this._adapter.upsertState(`${this.HDsnapshotChannelId}.moment`, constants_1.COMMON_HDSNAPSHOT_MOMENT, this._lastHDSnapshotTimestamp);
|
|
749
|
-
this._adapter.upsertState(`${this.HDsnapshotChannelId}.url`, constants_1.COMMON_HDSNAPSHOT_URL, this._lastHDSnapShotUrl);
|
|
786
|
+
await this._adapter.upsertState(`${this.HDsnapshotChannelId}.file`, constants_1.COMMON_HDSNAPSHOT_FILE, this._lastHDSnapShotDir);
|
|
787
|
+
await this._adapter.upsertState(`${this.HDsnapshotChannelId}.moment`, constants_1.COMMON_HDSNAPSHOT_MOMENT, this._lastHDSnapshotTimestamp);
|
|
788
|
+
await this._adapter.upsertState(`${this.HDsnapshotChannelId}.url`, constants_1.COMMON_HDSNAPSHOT_URL, this._lastHDSnapShotUrl);
|
|
750
789
|
}
|
|
751
790
|
await this.updateHDSnapshotRequest();
|
|
752
791
|
}
|
|
753
792
|
async updateLiveStreamObject() {
|
|
754
793
|
this.debug(`Update Livestream Object`);
|
|
755
794
|
if (this._lastLiveStreamTimestamp !== 0) {
|
|
756
|
-
this._adapter.upsertState(`${this.liveStreamChannelId}.file`, constants_1.COMMON_LIVESTREAM_FILE, this._lastLiveStreamDir);
|
|
757
|
-
this._adapter.upsertState(`${this.liveStreamChannelId}.url`, constants_1.COMMON_LIVESTREAM_URL, this._lastLiveStreamUrl);
|
|
758
|
-
this._adapter.upsertState(`${this.liveStreamChannelId}.moment`, constants_1.COMMON_LIVESTREAM_MOMENT, this._lastLiveStreamTimestamp);
|
|
795
|
+
await this._adapter.upsertState(`${this.liveStreamChannelId}.file`, constants_1.COMMON_LIVESTREAM_FILE, this._lastLiveStreamDir);
|
|
796
|
+
await this._adapter.upsertState(`${this.liveStreamChannelId}.url`, constants_1.COMMON_LIVESTREAM_URL, this._lastLiveStreamUrl);
|
|
797
|
+
await this._adapter.upsertState(`${this.liveStreamChannelId}.moment`, constants_1.COMMON_LIVESTREAM_MOMENT, this._lastLiveStreamTimestamp);
|
|
759
798
|
}
|
|
760
799
|
await this.updateLivestreamRequest();
|
|
761
800
|
}
|
|
762
|
-
updateHealthObject(health) {
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
let batteryPercent = parseInt((_a = health.battery_percentage) !== null && _a !== void 0 ? _a : "-1");
|
|
801
|
+
async updateHealthObject(health) {
|
|
802
|
+
this.debug('Update Health Callback');
|
|
803
|
+
let batteryPercent = parseInt(health.battery_percentage ?? '-1');
|
|
766
804
|
if (isNaN(batteryPercent)) {
|
|
767
805
|
batteryPercent = -1;
|
|
768
806
|
}
|
|
769
|
-
this._adapter.upsertState(`${this.infoChannelId}.battery_percentage`, constants_1.COMMON_INFO_BATTERY_PERCENTAGE, batteryPercent);
|
|
770
|
-
this._adapter.upsertState(`${this.infoChannelId}.battery_percentage_category`, constants_1.COMMON_INFO_BATTERY_PERCENTAGE_CATEGORY, health.battery_percentage_category);
|
|
771
|
-
this._adapter.upsertState(`${this.infoChannelId}.wifi_name`, constants_1.COMMON_INFO_WIFI_NAME, health.wifi_name);
|
|
772
|
-
this._adapter.upsertState(`${this.infoChannelId}.latest_signal_strength`, constants_1.COMMON_INFO_LATEST_SIGNAL_STRENGTH, health.latest_signal_strength);
|
|
773
|
-
this._adapter.upsertState(`${this.infoChannelId}.latest_signal_category`, constants_1.COMMON_INFO_LATEST_SIGNAL_CATEGORY, health.latest_signal_category);
|
|
774
|
-
this._adapter.upsertState(`${this.infoChannelId}.firmware`, constants_1.COMMON_INFO_FIRMWARE, health.firmware);
|
|
775
|
-
if (this._ringDevice.hasLight &&
|
|
807
|
+
await this._adapter.upsertState(`${this.infoChannelId}.battery_percentage`, constants_1.COMMON_INFO_BATTERY_PERCENTAGE, batteryPercent);
|
|
808
|
+
await this._adapter.upsertState(`${this.infoChannelId}.battery_percentage_category`, constants_1.COMMON_INFO_BATTERY_PERCENTAGE_CATEGORY, health.battery_percentage_category);
|
|
809
|
+
await this._adapter.upsertState(`${this.infoChannelId}.wifi_name`, constants_1.COMMON_INFO_WIFI_NAME, health.wifi_name);
|
|
810
|
+
await this._adapter.upsertState(`${this.infoChannelId}.latest_signal_strength`, constants_1.COMMON_INFO_LATEST_SIGNAL_STRENGTH, health.latest_signal_strength);
|
|
811
|
+
await this._adapter.upsertState(`${this.infoChannelId}.latest_signal_category`, constants_1.COMMON_INFO_LATEST_SIGNAL_CATEGORY, health.latest_signal_category);
|
|
812
|
+
await this._adapter.upsertState(`${this.infoChannelId}.firmware`, constants_1.COMMON_INFO_FIRMWARE, health.firmware);
|
|
813
|
+
if (this._ringDevice.hasLight && Date.now() - this._lastLightCommand > 60000) {
|
|
776
814
|
// this.silly(JSON.stringify(this._ringDevice.data));
|
|
777
815
|
const floodlightOn = this._ringDevice.data.health.floodlight_on;
|
|
778
816
|
this.debug(`Update Light within Health Update Floodlight is ${floodlightOn}`);
|
|
779
|
-
this._adapter.upsertState(`${this.lightChannelId}.light_state`, constants_1.COMMON_LIGHT_STATE, floodlightOn);
|
|
817
|
+
await this._adapter.upsertState(`${this.lightChannelId}.light_state`, constants_1.COMMON_LIGHT_STATE, floodlightOn);
|
|
780
818
|
}
|
|
781
819
|
}
|
|
782
|
-
onNotify(value) {
|
|
783
|
-
var _a;
|
|
820
|
+
async onNotify(value) {
|
|
784
821
|
this.debug(`Received Notify Event (${util.inspect(value, true, 1)})`);
|
|
785
822
|
if (value) {
|
|
786
823
|
if (this._notifyEventBlocker.checkBlock()) {
|
|
@@ -788,16 +825,16 @@ class OwnRingCamera extends ownRingDevice_1.OwnRingDevice {
|
|
|
788
825
|
return;
|
|
789
826
|
}
|
|
790
827
|
if (value.img != null) {
|
|
791
|
-
this.notifyRecording(EventState.ReactingOnEvent, value.img.snapshot_uuid);
|
|
828
|
+
await this.notifyRecording(EventState.ReactingOnEvent, value.img.snapshot_uuid);
|
|
792
829
|
}
|
|
793
830
|
const subType = value.data.event.ding.subtype;
|
|
794
|
-
this._adapter.upsertState(`${this.eventsChannelId}.type`, constants_1.COMMON_EVENTS_TYPE, text_service_1.TextService.
|
|
795
|
-
this._adapter.upsertState(`${this.eventsChannelId}.detectionType`, constants_1.COMMON_EVENTS_DETECTIONTYPE, text_service_1.TextService.
|
|
796
|
-
this._adapter.upsertState(`${this.eventsChannelId}.created_at`, constants_1.COMMON_EVENTS_MOMENT, Date.now());
|
|
797
|
-
this._adapter.upsertState(`${this.eventsChannelId}.message`, constants_1.COMMON_EVENTS_MESSAGE, value.android_config.body);
|
|
831
|
+
await this._adapter.upsertState(`${this.eventsChannelId}.type`, constants_1.COMMON_EVENTS_TYPE, text_service_1.TextService.getDetectionType(subType, this._adapter.language));
|
|
832
|
+
await this._adapter.upsertState(`${this.eventsChannelId}.detectionType`, constants_1.COMMON_EVENTS_DETECTIONTYPE, text_service_1.TextService.getDetectionType(value.data.event.ding.detection_type ?? subType, this._adapter.language));
|
|
833
|
+
await this._adapter.upsertState(`${this.eventsChannelId}.created_at`, constants_1.COMMON_EVENTS_MOMENT, Date.now());
|
|
834
|
+
await this._adapter.upsertState(`${this.eventsChannelId}.message`, constants_1.COMMON_EVENTS_MESSAGE, value.android_config.body);
|
|
798
835
|
}
|
|
799
836
|
}
|
|
800
|
-
onMotion(value) {
|
|
837
|
+
async onMotion(value) {
|
|
801
838
|
// value = true -> motion
|
|
802
839
|
this.debug(`Received Motion Event (${util.inspect(value, true, 1)})`);
|
|
803
840
|
if (value) {
|
|
@@ -805,19 +842,21 @@ class OwnRingCamera extends ownRingDevice_1.OwnRingDevice {
|
|
|
805
842
|
this.debug(`ignore Motion event...`);
|
|
806
843
|
return;
|
|
807
844
|
}
|
|
808
|
-
this._adapter.upsertState(`${this.eventsChannelId}.motion`, constants_1.COMMON_MOTION, value);
|
|
845
|
+
await this._adapter.upsertState(`${this.eventsChannelId}.motion`, constants_1.COMMON_MOTION, value);
|
|
809
846
|
}
|
|
810
847
|
}
|
|
811
|
-
onDoorbell(value) {
|
|
848
|
+
async onDoorbell(value) {
|
|
812
849
|
this.debug(`Received Doorbell Event (${util.inspect(value, true, 1)})`);
|
|
813
850
|
if (value) {
|
|
814
851
|
if (this._doorbellEventBlocker.checkBlock()) {
|
|
815
852
|
this.debug(`ignore Doorbell event...`);
|
|
816
853
|
return;
|
|
817
854
|
}
|
|
818
|
-
this._adapter.upsertState(`${this.eventsChannelId}.doorbell`, constants_1.COMMON_EVENTS_DOORBELL, true);
|
|
819
|
-
setTimeout(() => {
|
|
820
|
-
this._adapter
|
|
855
|
+
await this._adapter.upsertState(`${this.eventsChannelId}.doorbell`, constants_1.COMMON_EVENTS_DOORBELL, true);
|
|
856
|
+
this._adapter.setTimeout(() => {
|
|
857
|
+
this._adapter
|
|
858
|
+
.upsertState(`${this.eventsChannelId}.doorbell`, constants_1.COMMON_EVENTS_DOORBELL, false)
|
|
859
|
+
.catch(e => this.catcher(`Cannot upsert state ${this.eventsChannelId}.doorbell`, e));
|
|
821
860
|
}, 1000);
|
|
822
861
|
}
|
|
823
862
|
}
|
|
@@ -826,26 +865,29 @@ class OwnRingCamera extends ownRingDevice_1.OwnRingDevice {
|
|
|
826
865
|
while (this._state !== EventState.Idle) {
|
|
827
866
|
this.debug(`delayed notify recording for ${del_cnt}s`);
|
|
828
867
|
del_cnt++;
|
|
829
|
-
await
|
|
868
|
+
await this._adapter.delay(1000);
|
|
830
869
|
}
|
|
831
870
|
this.silly(`Start recording for Event "${EventState[state]}"...`);
|
|
832
871
|
this._state = state;
|
|
833
872
|
try {
|
|
834
873
|
/*
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
this._adapter.config.auto_snapshot && await this.takeSnapshot(uuid, true);
|
|
842
|
-
this._adapter.config.auto_HDsnapshot && await this.takeHDSnapshot();
|
|
843
|
-
this._adapter.config.auto_livestream &&
|
|
874
|
+
if (this._adapter.config.auto_snapshot)
|
|
875
|
+
if (subscr && !this._ringDevice.hasBattery)
|
|
876
|
+
await this.takeSnapshot(uuid, true);
|
|
877
|
+
else
|
|
878
|
+
await this.takeSnapshot();
|
|
879
|
+
*/
|
|
880
|
+
this._adapter.config.auto_snapshot && (await this.takeSnapshot(uuid, true));
|
|
881
|
+
this._adapter.config.auto_HDsnapshot && (await this.takeHDSnapshot());
|
|
882
|
+
this._adapter.config.auto_livestream &&
|
|
883
|
+
(await this.startLivestream(this._adapter.config.recordtime_auto_livestream));
|
|
844
884
|
// give some time to evaluate motion state, e.g. for node-red
|
|
845
|
-
setTimeout(() => {
|
|
846
|
-
this._adapter
|
|
885
|
+
this._adapter.setTimeout(() => {
|
|
886
|
+
this._adapter
|
|
887
|
+
.upsertState(`${this.eventsChannelId}.motion`, constants_1.COMMON_MOTION, false)
|
|
888
|
+
.catch(e => this.catcher(`Cannot set state ${this.eventsChannelId}.motion to false`, e));
|
|
847
889
|
}, 200);
|
|
848
|
-
this.debug(
|
|
890
|
+
this.debug('Recording of event finished.');
|
|
849
891
|
}
|
|
850
892
|
finally {
|
|
851
893
|
this._state = EventState.Idle;
|