iobroker.ring 3.0.0-beta.8 → 3.0.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.
package/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2022 Thorsten Stueben <thorsten@stueben.de>
3
+ Copyright (c) 2018-2022 Thorsten Stueben <thorsten@stueben.de>
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/README.md CHANGED
@@ -1,5 +1,4 @@
1
1
  ![Logo](admin/ring.png)
2
-
3
2
  # Ring Adapter
4
3
 
5
4
  [![Travis CI Build Status](https://travis-ci.org/iobroker-community-adapters/ioBroker.ring.svg?branch=master)](https://travis-ci.org/iobroker-community-adapters/ioBroker.ring)
@@ -9,17 +8,18 @@
9
8
 
10
9
  [![NPM](https://nodei.co/npm/iobroker.ring.png?downloads=true)](https://nodei.co/npm/iobroker.ring/)
11
10
 
12
- Requires Admin v4 and ``node 16.x``.
11
+ Requires Admin v4 and `node 16.x`.
13
12
 
14
- The Ring adapter works with Ring devices like the Ring Video Doorbell and Ring Cam and shows if somenone rings the doorbell or if motion is detected. The Ring Video Doorbell or Cam sends a videostream if a motion or doorbell ist detected.
13
+ The Ring adapter works with Ring devices like the Ring Video Doorbell and Ring Cam and shows if someone rings the doorbell or if motion is detected. The Ring Video Doorbell or Cam sends a videostream if a motion or doorbell ist detected.
15
14
 
16
15
  ### SIP (before Version 3.x)
17
16
  You can use the SIP Information for a SIP Video Conference with your SIP client.
18
- The adapter will not provide all ring devices because the used API do not includes all ring devices.
17
+ The adapter will not provide all ring devices because the used API does not include all ring devices.
19
18
 
20
19
  You can use for example the Blink SIP client on [http://icanblink.com/](http://icanblink.com/). To get video working go into Blink's Preferences and under "Accounts", switch the tab to "Media" and deselect "Encrypt audio and video" under "RTP Options". Be careful the SIP information expire after a few seconds!
21
- Hopefully I will able to support a video stream soon. Unfortunatly [ring.com](https://ring.com) does not have an official API that support this feature.
22
- If you press the livestreamrequest button you get new SIP Information for building up a SIP Video Call session. If you are using the [ring.com](https://ring.com) cloud you find under history a http link to your last motion / door bell recorded video.
20
+ Hopefully I will be able to support a video stream soon. Unfortunately [ring.com](https://ring.com) does not have an official API that support this feature.
21
+ If you press the `livestream request` button you get new SIP Information for building up a SIP Video Call session.
22
+ If you are using the [ring.com](https://ring.com) cloud you find under history a http link to your last motion / doorbell recorded video.
23
23
 
24
24
 
25
25
  ## Install & Configuration
@@ -38,12 +38,48 @@ cd /opt/iobroker/node_modules/iobroker.ring/node_modules/ring-client-api
38
38
  node ring-auth-cli
39
39
  ```
40
40
 
41
- You can use special variables for your livestream and snapshort path and filename. This variables will be replaced with a counter, timestamp, ring id or kind of ring.
41
+ You can use special variables for your livestream and snapshot path and filename. These variables will be replaced with a counter, timestamp, ring id or kind of ring.
42
42
 
43
- * %d : Unix timestamp. Example: test_%d -> test_1588331430061
44
- * %i : Id of your ring device: Example: test_%i -> test_234567890
45
- * %n : Counter since ring instance start. Example: test_%n -> test_1
46
- * %k : Kind of your ring device: Example: test_%k -> test_doorbel
43
+ * `%d`: Unix timestamp. Example: `test_%d -> test_1588331430061`
44
+ * `%i`: ID of your ring device: Example: `test_%i -> test_234567890`
45
+ * `%n`: Counter since ring instance start. Example: `test_%n -> test_1`
46
+ * `%k`: Kind of your ring device: Example: `test_%k -> test_doorbell`
47
+
48
+ ### V3 Rewrite Breaking Changes
49
+ 1. The Device Names got extended by their description (e.g. from `Device 1234567` to `Device 1234567 ("Floodlight Garden")`)
50
+ 2. Snapshot/Livestream Data is now in a respective channel, containing the other data points.
51
+ 3. The snapshot/livestream object got changed from type meta to state with type file.
52
+ 4. Events (Motion, Ding, etc.) are now in a respective channel.
53
+ 5. Due to `ring-api` dropping the support for node before `v16.x` this adapter needs `node v16.x`
54
+ 6. Active refreshes are reduced to once every 2 hours, as we are listening/reacting on events.
55
+
56
+ ### Scripts in `package.json`
57
+ Several npm scripts are predefined for your convenience. You can run them using `npm run <scriptname>`
58
+ | Script name | Description |
59
+ |-------------|-------------|
60
+ | `build:ts` | Compile the TypeScript sources. |
61
+ | `watch:ts` | Compile the TypeScript sources and watch for changes. |
62
+ | `watch` | Shortcut for `npm run watch:ts` |
63
+ | `test:ts` | Executes the tests you defined in `*.test.ts` files. |
64
+ | `test:package` | Ensures your `package.json` and `io-package.json` are valid. |
65
+ | `test:unit` | Tests the adapter startup with unit tests (fast, but might require module mocks to work). |
66
+ | `test:integration` | Tests the adapter startup with an actual instance of ioBroker. |
67
+ | `test` | Performs a minimal test run on package files and your tests. |
68
+ | `check` | Performs a type-check on your code (without compiling anything). |
69
+ | `coverage` | Generates code coverage using your test files. |
70
+ | `lint` | Runs `ESLint` to check your code for formatting errors and potential bugs. |
71
+ | `release` | Creates a new release, see [`@alcalzone/release-script`](https://github.com/AlCalzone/release-script#usage) for more details. |
72
+
73
+ ### Writing tests
74
+ When done right, testing code is invaluable, because it gives you the
75
+ confidence to change your code while knowing exactly if and when
76
+ something breaks. A good read on the topic of test-driven development
77
+ is https://hackernoon.com/introduction-to-test-driven-development-tdd-61a13bc92d92.
78
+ Although writing tests before the code might seem strange at first, but it has very
79
+ clear upsides.
80
+
81
+ The template provides you with basic tests for the adapter startup and package files.
82
+ It is recommended that you add your own tests into the mix.
47
83
 
48
84
  ## Changelog
49
85
 
@@ -51,6 +87,33 @@ You can use special variables for your livestream and snapshort path and filenam
51
87
  Placeholder for the next version (at the beginning of the line):
52
88
  ### **WORK IN PROGRESS**
53
89
  -->
90
+ ### 3.0.3 (2022-06-16)
91
+ * (theimo1221) Implement location mode
92
+
93
+ ### 3.0.1 (2022-06-08)
94
+ * (bluefox) Changed the russian translations
95
+
96
+ ### 3.0.0-beta.13 (2022-05-30)
97
+ * (theimo1221) Prevent missing of events, due to socket drop within ring-api-client
98
+ * (theimo1221) Improve device logging readability
99
+
100
+ ### 3.0.0-beta.12 (2022-05-28)
101
+ * (theimo1221) Fix error in beta.11 in regard to new installations
102
+ * (theimo1221) Harden Event Handling to prevent rare permanent busy occasions
103
+ * (theimo1221) Add support for doorbell device `doorbell_graham_cracker`
104
+
105
+ ### 3.0.0-beta.11 (2022-05-24)
106
+
107
+ * (theimo1221) Add processing of new token provided by ring.
108
+
109
+ ### 3.0.0-beta.10 (2022-05-24)
110
+
111
+ * (theimo1221) Add `lpd_v4` Doorbell
112
+
113
+ ### 3.0.0-beta.9 (2022-05-21)
114
+
115
+ * (theimo1221) For stability reasons, perform an active refresh every 2 hours.
116
+
54
117
  ### 3.0.0-beta.8 (2022-05-17)
55
118
 
56
119
  * (theimo1221) Fix writing to iobroker-data/files folder (thx to Apollon)
@@ -75,7 +138,7 @@ You can use special variables for your livestream and snapshort path and filenam
75
138
  ### 3.0.0-beta.3 (2022-05-14)
76
139
  * (theimo1221) Rewrite V3 (Breaking Changes listed below)
77
140
  * (theimo1221) Update packages
78
- * (theimo1221) Fix in github release workflow
141
+ * (theimo1221) Fix in GitHub release workflow
79
142
 
80
143
  ### 2.0.0-beta.3 (2022-02-08)
81
144
  * (theimo1221) Fix adapter checker issues
@@ -194,47 +257,10 @@ You can use special variables for your livestream and snapshort path and filenam
194
257
  ### 0.1.0 (14.12.2018)
195
258
  * (Stübi) First Version
196
259
 
197
- ### V3 Rewrite Breaking Changes
198
- 1. The Device Names got extended by their description (e.g. from `Device 1234567` to `Device 1234567 ("Floodlight Garden")`)
199
- 2. Snapshot/Livestream Data is now in a respective channel, containing the other data points.
200
- 3. The snapshot/livestream object got changed from type meta to state with type file.
201
- 4. Events (Motion, Ding, etc.) are now in a respective channel.
202
- 5. Due to `ring-api` dropping the support for node before `v16.x` this adapter needs `node v16.x`
203
-
204
-
205
- ### Scripts in `package.json`
206
- Several npm scripts are predefined for your convenience. You can run them using `npm run <scriptname>`
207
- | Script name | Description |
208
- |-------------|-------------|
209
- | `build:ts` | Compile the TypeScript sources. |
210
- | `watch:ts` | Compile the TypeScript sources and watch for changes. |
211
- | `watch` | Shortcut for `npm run watch:ts` |
212
- | `test:ts` | Executes the tests you defined in `*.test.ts` files. |
213
- | `test:package` | Ensures your `package.json` and `io-package.json` are valid. |
214
- | `test:unit` | Tests the adapter startup with unit tests (fast, but might require module mocks to work). |
215
- | `test:integration` | Tests the adapter startup with an actual instance of ioBroker. |
216
- | `test` | Performs a minimal test run on package files and your tests. |
217
- | `check` | Performs a type-check on your code (without compiling anything). |
218
- | `coverage` | Generates code coverage using your test files. |
219
- | `lint` | Runs `ESLint` to check your code for formatting errors and potential bugs. |
220
- | `release` | Creates a new release, see [`@alcalzone/release-script`](https://github.com/AlCalzone/release-script#usage) for more details. |
221
-
222
- ### Writing tests
223
- When done right, testing code is invaluable, because it gives you the
224
- confidence to change your code while knowing exactly if and when
225
- something breaks. A good read on the topic of test-driven development
226
- is https://hackernoon.com/introduction-to-test-driven-development-tdd-61a13bc92d92.
227
- Although writing tests before the code might seem strange at first, but it has very
228
- clear upsides.
229
-
230
- The template provides you with basic tests for the adapter startup and package files.
231
- It is recommended that you add your own tests into the mix.
232
-
233
-
234
260
  ## License
235
261
  MIT License
236
262
 
237
- Copyright (c) 2022 Thorsten <thorsten@stueben.de> / <https://github.com/schmupu>
263
+ Copyright (c) 2018-2022 Thorsten <thorsten@stueben.de> / <https://github.com/schmupu>
238
264
 
239
265
  Permission is hereby granted, free of charge, to any person obtaining a copy
240
266
  of this software and associated documentation files (the "Software"), to deal
@@ -0,0 +1,9 @@
1
+ {
2
+ "extends": "../tsconfig.json",
3
+ "include": [
4
+ "./admin.d.ts",
5
+ "./**/*.js",
6
+ // include the adapter-config definition if it exists
7
+ "../src/lib/adapter-config.d.ts",
8
+ ]
9
+ }
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.STATE_ID_DEBUG_REQUEST = exports.STATE_ID_LIVESTREAM_REQUEST = exports.STATE_ID_SNAPSHOT_REQUEST = exports.STATE_ID_LIGHT_SWITCH = exports.CHANNEL_NAME_EVENTS = exports.CHANNEL_NAME_LIVESTREAM = exports.CHANNEL_NAME_SNAPSHOT = exports.CHANNEL_NAME_LIGHT = exports.CHANNEL_NAME_HISTORY = exports.CHANNEL_NAME_INFO = exports.COMMON_DEBUG_REQUEST = exports.COMMON_EVENTS_MOMENT = exports.COMMON_EVENTS_MESSAGE = exports.COMMON_EVENTS_DETECTIONTYPE = exports.COMMON_EVENTS_TYPE = exports.COMMON_EVENTS_DOORBELL = exports.COMMON_MOTION = exports.COMMON_LIVESTREAM_FILE = exports.COMMON_LIVESTREAM_URL = exports.COMMON_LIVESTREAM_REQUEST = exports.COMMON_LIVESTREAM_MOMENT = exports.COMMON_LIVESTREAM_LIVESTREAM = exports.COMMON_SNAPSHOT_MOMENT = exports.COMMON_SNAPSHOT_SNAPSHOT = exports.COMMON_SNAPSHOT_REQUEST = exports.COMMON_SNAPSHOT_FILE = exports.COMMON_SNAPSHOT_URL = exports.COMMON_HISTORY_KIND = exports.COMMON_HISTORY_CREATED_AT = exports.COMMON_HISTORY_URL = exports.COMMON_LIGHT_STATE = exports.COMMON_LIGHT_SWITCH = exports.COMMON_INFO_HAS_SIREN = exports.COMMON_INFO_HAS_BATTERY = exports.COMMON_INFO_HAS_LIGHT = exports.COMMON_INFO_FIRMWARE = exports.COMMON_INFO_LATEST_SIGNAL_CATEGORY = exports.COMMON_INFO_LATEST_SIGNAL_STRENGTH = exports.COMMON_INFO_WIFI_NAME = exports.COMMON_INFO_BATTERY_PERCENTAGE_CATEGORY = exports.COMMON_INFO_BATTERY_PERCENTAGE = exports.COMMON_INFO_KIND = exports.COMMON_INFO_EXTERNAL_CONNECTION = exports.COMMON_INFO_DESCRIPTION = exports.COMMON_INFO_ID = void 0;
3
+ exports.STATE_ID_LOCATIONMODE = exports.STATE_ID_DEBUG_REQUEST = exports.STATE_ID_LIVESTREAM_REQUEST = exports.STATE_ID_SNAPSHOT_REQUEST = exports.STATE_ID_LIGHT_SWITCH = exports.CHANNEL_NAME_EVENTS = exports.CHANNEL_NAME_LIVESTREAM = exports.CHANNEL_NAME_SNAPSHOT = exports.CHANNEL_NAME_LIGHT = exports.CHANNEL_NAME_HISTORY = exports.CHANNEL_NAME_INFO = exports.COMMON_LOCATIONMODE = exports.COMMON_OLD_TOKEN = exports.COMMON_NEW_TOKEN = exports.COMMON_DEBUG_REQUEST = exports.COMMON_EVENTS_MOMENT = exports.COMMON_EVENTS_MESSAGE = exports.COMMON_EVENTS_DETECTIONTYPE = exports.COMMON_EVENTS_TYPE = exports.COMMON_EVENTS_DOORBELL = exports.COMMON_MOTION = exports.COMMON_LIVESTREAM_FILE = exports.COMMON_LIVESTREAM_URL = exports.COMMON_LIVESTREAM_REQUEST = exports.COMMON_LIVESTREAM_MOMENT = exports.COMMON_LIVESTREAM_LIVESTREAM = exports.COMMON_SNAPSHOT_MOMENT = exports.COMMON_SNAPSHOT_SNAPSHOT = exports.COMMON_SNAPSHOT_REQUEST = exports.COMMON_SNAPSHOT_FILE = exports.COMMON_SNAPSHOT_URL = exports.COMMON_HISTORY_KIND = exports.COMMON_HISTORY_CREATED_AT = exports.COMMON_HISTORY_URL = exports.COMMON_LIGHT_STATE = exports.COMMON_LIGHT_SWITCH = exports.COMMON_INFO_HAS_SIREN = exports.COMMON_INFO_HAS_BATTERY = exports.COMMON_INFO_HAS_LIGHT = exports.COMMON_INFO_FIRMWARE = exports.COMMON_INFO_LATEST_SIGNAL_CATEGORY = exports.COMMON_INFO_LATEST_SIGNAL_STRENGTH = exports.COMMON_INFO_WIFI_NAME = exports.COMMON_INFO_BATTERY_PERCENTAGE_CATEGORY = exports.COMMON_INFO_BATTERY_PERCENTAGE = exports.COMMON_INFO_KIND = exports.COMMON_INFO_EXTERNAL_CONNECTION = exports.COMMON_INFO_DESCRIPTION = exports.COMMON_INFO_ID = exports.LOCATION_MODE_OPTIONS = void 0;
4
+ exports.LOCATION_MODE_OPTIONS = ["home", "away", "disarmed", "disabled", "unset"];
4
5
  exports.COMMON_INFO_ID = {
5
6
  type: "string",
6
7
  role: "state",
@@ -248,6 +249,28 @@ exports.COMMON_DEBUG_REQUEST = {
248
249
  read: false,
249
250
  write: true
250
251
  };
252
+ exports.COMMON_NEW_TOKEN = {
253
+ type: "string",
254
+ role: "text",
255
+ name: "Next Refresh Token",
256
+ read: true,
257
+ write: false
258
+ };
259
+ exports.COMMON_OLD_TOKEN = {
260
+ type: "string",
261
+ role: "text",
262
+ name: "Outdated user token",
263
+ read: true,
264
+ write: false
265
+ };
266
+ exports.COMMON_LOCATIONMODE = {
267
+ type: "string",
268
+ role: "text",
269
+ name: "Location Mode",
270
+ read: true,
271
+ write: true,
272
+ states: exports.LOCATION_MODE_OPTIONS
273
+ };
251
274
  exports.CHANNEL_NAME_INFO = "Info";
252
275
  exports.CHANNEL_NAME_HISTORY = "History";
253
276
  exports.CHANNEL_NAME_LIGHT = "Light";
@@ -258,4 +281,5 @@ exports.STATE_ID_LIGHT_SWITCH = "light_switch";
258
281
  exports.STATE_ID_SNAPSHOT_REQUEST = "snapshot_request";
259
282
  exports.STATE_ID_LIVESTREAM_REQUEST = "livestream_request";
260
283
  exports.STATE_ID_DEBUG_REQUEST = "debug_request";
284
+ exports.STATE_ID_LOCATIONMODE = "locationMode";
261
285
  //# sourceMappingURL=constants.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/lib/constants.ts"],"names":[],"mappings":";;;AAAa,QAAA,cAAc,GAAkC;IAC3D,IAAI,EAAE,QAAQ;IACd,IAAI,EAAE,OAAO;IACb,IAAI,EAAE,WAAW;IACjB,IAAI,EAAE,IAAI;IACV,KAAK,EAAE,KAAK;CACb,CAAA;AACY,QAAA,uBAAuB,GAAkC;IACpE,IAAI,EAAE,QAAQ;IACd,IAAI,EAAE,MAAM;IACZ,IAAI,EAAE,aAAa;IACnB,IAAI,EAAE,IAAI;IACV,KAAK,EAAE,KAAK;CACb,CAAA;AACY,QAAA,+BAA+B,GAAkC;IAC5E,IA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38
  EventState[EventState["ReactingOnDoorbell"] = 3] = "ReactingOnDoorbell";
39
39
  })(EventState || (EventState = {}));
40
40
  class OwnRingDevice {
41
- constructor(ringDevice, locationIndex, adapter, apiClient) {
41
+ constructor(ringDevice, location, adapter, apiClient) {
42
42
  this._requestingSnapshot = false;
43
43
  this._requestingLiveStream = false;
44
44
  this._lastLightCommand = 0;
@@ -53,14 +53,23 @@ class OwnRingDevice {
53
53
  this._snapshotCount = 0;
54
54
  this._liveStreamCount = 0;
55
55
  this._state = EventState.Idle;
56
+ this.motionObserver = {
57
+ next: (x) => this.onMotion(x),
58
+ error: (err) => this.catcher(`Motion Observer recieved error`, err),
59
+ complete: () => this.debug("Motion Observer got a complete notification"),
60
+ };
61
+ this.dingObserver = {
62
+ next: (x) => this.onDing(x),
63
+ error: (err) => this.catcher(`Ding Observer recieved error`, err),
64
+ complete: () => this.debug("Ding Observer got a complete notification"),
65
+ };
56
66
  this._adapter = adapter;
57
- this.debug(`Create device with ID: ${ringDevice.id}`);
58
67
  this._ringDevice = ringDevice;
59
- this._locationIndex = locationIndex;
68
+ this.shortId = `${ringDevice.id}`;
69
+ this.debug(`Create device`);
70
+ this._locationId = location.fullId;
60
71
  this._client = apiClient;
61
- this.path = `${this._locationIndex}.`;
62
72
  this.kind = OwnRingDevice.evaluateKind(ringDevice, adapter);
63
- this.shortId = `${ringDevice.id}`;
64
73
  this.fullId = `${this.kind}_${this.shortId}`;
65
74
  this.infoChannelId = `${this.fullId}.${constants_1.CHANNEL_NAME_INFO}`;
66
75
  this.historyChannelId = `${this.fullId}.${constants_1.CHANNEL_NAME_HISTORY}`;
@@ -98,6 +107,9 @@ class OwnRingDevice {
98
107
  case ring_client_api_1.RingCameraKind.floodlight_v2:
99
108
  case ring_client_api_1.RingCameraKind.spotlightw_v2:
100
109
  case ring_client_api_1.RingCameraKind.jbox_v1:
110
+ case "doorbell_graham_cracker":
111
+ case "lpd_v3":
112
+ case "lpd_v4":
101
113
  return `doorbell`;
102
114
  case ring_client_api_1.RingCameraKind.cocoa_camera:
103
115
  case ring_client_api_1.RingCameraKind.cocoa_doorbell:
@@ -112,7 +124,7 @@ class OwnRingDevice {
112
124
  return `stickup`;
113
125
  default:
114
126
  adapter.log.error(`Device with Type ${device.deviceType} not yet supported, please inform dev Team via Github`);
115
- adapter.log.debug(`Unsupported Device Info: ${util.inspect(device, false, 1)}`);
127
+ adapter.log.info(`Unsupported Device Info: ${util.inspect(device, false, 1)}`);
116
128
  }
117
129
  return "unknown";
118
130
  }
@@ -122,25 +134,28 @@ class OwnRingDevice {
122
134
  get lastSnapShotDir() {
123
135
  return this._lastSnapShotDir;
124
136
  }
125
- get locationIndex() {
126
- return this._locationIndex;
127
- }
128
- get location() {
129
- if (this._client.locations.length < this._locationIndex) {
130
- this._adapter.log.error(`Can't find a Location with index ${this._locationIndex}`);
131
- return undefined;
132
- }
133
- return this._client.locations[this._locationIndex];
137
+ get locationId() {
138
+ return this._locationId;
134
139
  }
135
140
  get ringDevice() {
136
141
  return this._ringDevice;
137
142
  }
138
143
  set ringDevice(device) {
139
144
  this._ringDevice = device;
145
+ this.subscribeToEvents();
146
+ }
147
+ async subscribeToEvents() {
148
+ this.silly(`Start device subscriptions`);
149
+ await this._ringDevice.subscribeToDingEvents().catch((r) => {
150
+ this.catcher(`Failed subscribing to Ding Events for ${this._ringDevice.name}`, r);
151
+ });
152
+ await this._ringDevice.subscribeToMotionEvents().catch((r) => {
153
+ this.catcher(`Failed subscribing to Motion Events for ${this._ringDevice.name}`, r);
154
+ });
140
155
  this._ringDevice.onData.subscribe(this.update.bind(this));
141
- this._ringDevice.onMotionDetected.subscribe(this.onMotion.bind(this));
156
+ this._ringDevice.onMotionDetected.subscribe(this.motionObserver);
142
157
  this._ringDevice.onDoorbellPressed.subscribe(this.onDorbell.bind(this));
143
- this._ringDevice.onNewNotification.subscribe(this.onDing.bind(this));
158
+ this._ringDevice.onNewNotification.subscribe(this.dingObserver);
144
159
  }
145
160
  processUserInput(channelID, stateID, state) {
146
161
  switch (channelID) {
@@ -209,7 +224,7 @@ class OwnRingDevice {
209
224
  }
210
225
  }
211
226
  async recreateDeviceObjectTree() {
212
- this.silly(`Recreate DeviceObjectTree for ${this.fullId}`);
227
+ this.silly(`Recreate DeviceObjectTree`);
213
228
  this._adapter.createDevice(this.fullId, {
214
229
  name: `Device ${this.shortId} ("${this._ringDevice.data.description}")`
215
230
  });
@@ -219,7 +234,7 @@ class OwnRingDevice {
219
234
  this._adapter.createChannel(this.fullId, constants_1.CHANNEL_NAME_HISTORY);
220
235
  this._adapter.createChannel(this.fullId, constants_1.CHANNEL_NAME_EVENTS);
221
236
  if (this._ringDevice.hasLight) {
222
- this.debug(`Device with Light Capabilities detected "${this.fullId}"`);
237
+ this.debug(`Device with Light Capabilities detected`);
223
238
  this._adapter.createChannel(this.fullId, constants_1.CHANNEL_NAME_LIGHT, { name: `Light ${this.shortId}` });
224
239
  }
225
240
  this._lastSnapShotDir = await this._adapter.tryGetStringState(`${this.snapshotChannelId}.snapshot_file`);
@@ -228,10 +243,11 @@ class OwnRingDevice {
228
243
  }
229
244
  updateByDevice(ringDevice) {
230
245
  this.ringDevice = ringDevice;
246
+ this._state = EventState.Idle;
231
247
  this.update(ringDevice.data);
232
248
  }
233
249
  update(data) {
234
- this.debug(`Recieved Update for ${this.fullId}`);
250
+ this.debug(`Recieved Update`);
235
251
  this.updateDeviceInfoObject(data);
236
252
  this.updateHealth();
237
253
  // noinspection JSIgnoredPromiseFromCall
@@ -242,13 +258,12 @@ class OwnRingDevice {
242
258
  this.silly(`${this.shortId}.startLivestream()`);
243
259
  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);
244
260
  if (!(await file_service_1.FileService.prepareFolder(dirname))) {
245
- this.debug(`Failed to prepare Livestream folder ("${fullPath}") for ${this.shortId}`);
261
+ this.debug(`Failed to prepare Livestream folder ("${fullPath}")`);
246
262
  return;
247
263
  }
248
264
  file_service_1.FileService.deleteFileIfExistSync(fullPath, this._adapter);
249
265
  if (this._ringDevice.isOffline) {
250
- this.info(`Device ${this.fullId} ("${this._ringDevice.data.description}") is offline --> won't take LiveStream
251
- `);
266
+ this.info(` is offline --> won't take LiveStream`);
252
267
  return;
253
268
  }
254
269
  duration !== null && duration !== void 0 ? duration : (duration = this._adapter.config.recordtime_livestream);
@@ -256,7 +271,7 @@ class OwnRingDevice {
256
271
  this.silly(`Initialize Livestream (${duration}s) to temp-file ${tempPath}`);
257
272
  await this._ringDevice.recordToFile(tempPath, duration);
258
273
  if (!fs.existsSync(tempPath)) {
259
- this.info(`Could't create livestream for ${this.shortId}`);
274
+ this.info(`Could't create livestream`);
260
275
  return;
261
276
  }
262
277
  const video = fs.readFileSync(tempPath);
@@ -285,8 +300,7 @@ class OwnRingDevice {
285
300
  return;
286
301
  file_service_1.FileService.deleteFileIfExistSync(fullPath, this._adapter);
287
302
  if (this._ringDevice.isOffline) {
288
- this.info(`Device ${this.fullId} ("${this._ringDevice.data.description}") is offline --> won't take Snapshot
289
- `);
303
+ this.info(`is offline --> won't take Snapshot`);
290
304
  return;
291
305
  }
292
306
  const image = await this._ringDevice.getSnapshot({ uuid: uuid }).catch((reason) => {
@@ -311,14 +325,14 @@ class OwnRingDevice {
311
325
  this.debug(`Done creating snapshot to ${fullPath}`);
312
326
  }
313
327
  updateHealth() {
314
- this.silly(`Update Health for ${this.fullId}`);
328
+ this.silly(`Update Health`);
315
329
  this._ringDevice.getHealth().then(this.updateHealthObject.bind(this));
316
330
  }
317
331
  async updateHistory() {
318
- this.silly(`Update History for ${this.fullId}`);
332
+ this.silly(`Update History`);
319
333
  this._ringDevice.getEvents({ limit: 50 })
320
334
  .then(async (r) => {
321
- this.silly(`Recieved Event History for ${this.fullId}`);
335
+ this.silly(`Recieved Event History`);
322
336
  const lastAction = r.events.find((event) => {
323
337
  const kind = event.kind;
324
338
  switch (kind) {
@@ -353,7 +367,7 @@ class OwnRingDevice {
353
367
  this._adapter.upsertState(`${this.historyChannelId}.kind`, constants_1.COMMON_HISTORY_KIND, lastAction.event.kind);
354
368
  }
355
369
  async updateSnapshotObject() {
356
- this.debug(`Update Snapshot Object for "${this.fullId}"`);
370
+ this.debug(`Update Snapshot Object`);
357
371
  if (this._lastSnapshotImage) {
358
372
  await this._adapter.upsertFile(`${this.snapshotChannelId}.jpg`, constants_1.COMMON_SNAPSHOT_SNAPSHOT, this._lastSnapshotImage, this._lastSnapshotTimestamp).catch((reason) => {
359
373
  this.debug(`Couldn't update Snapshot obejct: "${reason}"`);
@@ -367,7 +381,7 @@ class OwnRingDevice {
367
381
  }
368
382
  }
369
383
  async updateLiveStreamObject() {
370
- this.debug(`Update Livestream Object for "${this.fullId}"`);
384
+ this.debug(`Update Livestream Object`);
371
385
  if (this._lastLiveStreamVideo) {
372
386
  await this._adapter.upsertFile(`${this.liveStreamChannelId}.mp4`, constants_1.COMMON_LIVESTREAM_LIVESTREAM, this._lastLiveStreamVideo, this._lastLiveStreamTimestamp).catch((reason) => {
373
387
  this.debug(`Couldn't update Livestream obejct: "${reason}"`);
@@ -382,7 +396,7 @@ class OwnRingDevice {
382
396
  }
383
397
  updateHealthObject(health) {
384
398
  var _a;
385
- this.debug(`Update Health Callback for "${this.fullId}"`);
399
+ this.debug(`Update Health Callback`);
386
400
  let batteryPercent = parseInt((_a = health.battery_percentage) !== null && _a !== void 0 ? _a : "-1");
387
401
  if (isNaN(batteryPercent)) {
388
402
  batteryPercent = -1;
@@ -396,25 +410,25 @@ class OwnRingDevice {
396
410
  if (this._ringDevice.hasLight && (Date.now() - this._lastLightCommand > 60000)) {
397
411
  // this.silly(JSON.stringify(this._ringDevice.data));
398
412
  const floodlightOn = this._ringDevice.data.health.floodlight_on;
399
- this.debug(`Update Light within Health Update for "${this.fullId}" FLoodlight is ${floodlightOn}`);
413
+ this.debug(`Update Light within Health Update FLoodlight is ${floodlightOn}`);
400
414
  this._adapter.upsertState(`${this.lightChannelId}.light_state`, constants_1.COMMON_LIGHT_STATE, floodlightOn);
401
415
  this._adapter.upsertState(`${this.lightChannelId}.${constants_1.STATE_ID_LIGHT_SWITCH}`, constants_1.COMMON_LIGHT_SWITCH, floodlightOn, true);
402
416
  }
403
417
  }
404
418
  debug(message) {
405
- this._adapter.log.debug(message);
419
+ this._adapter.log.debug(`Device ${this.shortId} ("${this.ringDevice.data.description}"): ${message}`);
406
420
  }
407
421
  silly(message) {
408
- this._adapter.log.silly(message);
422
+ this._adapter.log.silly(`Device ${this.shortId} ("${this.ringDevice.data.description}"): ${message}`);
409
423
  }
410
424
  info(message) {
411
- this._adapter.log.info(message);
425
+ this._adapter.log.info(`Device ${this.shortId} ("${this.ringDevice.data.description}"): ${message}`);
412
426
  }
413
427
  catcher(message, reason) {
414
428
  this._adapter.logCatch(message, reason);
415
429
  }
416
430
  onDing(value) {
417
- this.debug(`Recieved Ding Event (${value}) for ${this.shortId}`);
431
+ this.debug(`Recieved Ding Event (${value})`);
418
432
  this.conditionalRecording(EventState.ReactingOnDing, value.ding.image_uuid);
419
433
  this._adapter.upsertState(`${this.eventsChannelId}.type`, constants_1.COMMON_EVENTS_TYPE, value.subtype);
420
434
  this._adapter.upsertState(`${this.eventsChannelId}.detectionType`, constants_1.COMMON_EVENTS_DETECTIONTYPE, value.ding.detection_type);
@@ -422,31 +436,39 @@ class OwnRingDevice {
422
436
  this._adapter.upsertState(`${this.eventsChannelId}.message`, constants_1.COMMON_EVENTS_MESSAGE, value.aps.alert);
423
437
  }
424
438
  onMotion(value) {
425
- this.debug(`Recieved Motion Event (${value}) for ${this.shortId}`);
439
+ this.debug(`Recieved Motion Event (${value})`);
426
440
  this._adapter.upsertState(`${this.eventsChannelId}.motion`, constants_1.COMMON_MOTION, value);
427
441
  if (value) {
428
442
  this.conditionalRecording(EventState.ReactingOnMotion);
429
443
  }
430
444
  }
431
445
  onDorbell(value) {
432
- this.debug(`Recieved Doorbell Event (${value}) for ${this.shortId}`);
446
+ this.debug(`Recieved Doorbell Event (${value})`);
433
447
  this.conditionalRecording(EventState.ReactingOnDoorbell, value.ding.image_uuid);
434
448
  this._adapter.upsertState(`${this.eventsChannelId}.doorbell`, constants_1.COMMON_EVENTS_DOORBELL, true);
435
449
  setTimeout(() => {
436
450
  this._adapter.upsertState(`${this.eventsChannelId}.doorbell`, constants_1.COMMON_EVENTS_DOORBELL, false);
437
451
  }, 5000);
438
452
  }
439
- conditionalRecording(state, uuid) {
453
+ async conditionalRecording(state, uuid) {
440
454
  if (this._state === EventState.Idle) {
441
- this.silly(`Start recording (with: ${this.shortId}) for Event "${EventState[state]}"...`);
455
+ this.silly(`Start recording for Event "${EventState[state]}"...`);
442
456
  this._state = state;
443
- this.takeSnapshot(uuid);
444
- this.startLivestream(20).then(() => {
457
+ try {
458
+ this.takeSnapshot(uuid);
459
+ await this.startLivestream(20);
460
+ }
461
+ finally {
445
462
  this._state = EventState.Idle;
446
- });
463
+ }
464
+ return;
447
465
  }
448
- else {
449
- this.silly(`Would have recorded due to "${EventState[state]}", but we are already reacting.`);
466
+ this.silly(`Would have recorded due to "${EventState[state]}", but we are already reacting.`);
467
+ if (uuid) {
468
+ setTimeout(() => {
469
+ this.debug(`delayed uuid recording`);
470
+ this.takeSnapshot(uuid);
471
+ }, 22000);
450
472
  }
451
473
  }
452
474
  }