iobroker.ring 3.0.0-beta.7 → 3.0.1

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,34 @@ 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.1 (2022-06-08)
91
+ * (bluefox) Changed the russian translations
92
+
93
+ ### 3.0.0-beta.13 (2022-05-30)
94
+ * (theimo1221) Prevent missing of events, due to socket drop within ring-api-client
95
+ * (theimo1221) Improve device logging readability
96
+
97
+ ### 3.0.0-beta.12 (2022-05-28)
98
+ * (theimo1221) Fix error in beta.11 in regard to new installations
99
+ * (theimo1221) Harden Event Handling to prevent rare permanent busy occasions
100
+ * (theimo1221) Add support for doorbell device `doorbell_graham_cracker`
101
+
102
+ ### 3.0.0-beta.11 (2022-05-24)
103
+
104
+ * (theimo1221) Add processing of new token provided by ring.
105
+
106
+ ### 3.0.0-beta.10 (2022-05-24)
107
+
108
+ * (theimo1221) Add `lpd_v4` Doorbell
109
+
110
+ ### 3.0.0-beta.9 (2022-05-21)
111
+
112
+ * (theimo1221) For stability reasons, perform an active refresh every 2 hours.
113
+
114
+ ### 3.0.0-beta.8 (2022-05-17)
115
+
116
+ * (theimo1221) Fix writing to iobroker-data/files folder (thx to Apollon)
117
+
54
118
  ### 3.0.0-beta.7 (2022-05-16)
55
119
 
56
120
  * (theimo1221) Prevent Crashes on unsupported devices
@@ -71,7 +135,7 @@ You can use special variables for your livestream and snapshort path and filenam
71
135
  ### 3.0.0-beta.3 (2022-05-14)
72
136
  * (theimo1221) Rewrite V3 (Breaking Changes listed below)
73
137
  * (theimo1221) Update packages
74
- * (theimo1221) Fix in github release workflow
138
+ * (theimo1221) Fix in GitHub release workflow
75
139
 
76
140
  ### 2.0.0-beta.3 (2022-02-08)
77
141
  * (theimo1221) Fix adapter checker issues
@@ -190,47 +254,10 @@ You can use special variables for your livestream and snapshort path and filenam
190
254
  ### 0.1.0 (14.12.2018)
191
255
  * (Stübi) First Version
192
256
 
193
- ### V3 Rewrite Breaking Changes
194
- 1. The Device Names got extended by their description (e.g. from `Device 1234567` to `Device 1234567 ("Floodlight Garden")`)
195
- 2. Snapshot/Livestream Data is now in a respective channel, containing the other data points.
196
- 3. The snapshot/livestream object got changed from type meta to state with type file.
197
- 4. Events (Motion, Ding, etc.) are now in a respective channel.
198
- 5. Due to `ring-api` dropping the support for node before `v16.x` this adapter needs `node v16.x`
199
-
200
-
201
- ### Scripts in `package.json`
202
- Several npm scripts are predefined for your convenience. You can run them using `npm run <scriptname>`
203
- | Script name | Description |
204
- |-------------|-------------|
205
- | `build:ts` | Compile the TypeScript sources. |
206
- | `watch:ts` | Compile the TypeScript sources and watch for changes. |
207
- | `watch` | Shortcut for `npm run watch:ts` |
208
- | `test:ts` | Executes the tests you defined in `*.test.ts` files. |
209
- | `test:package` | Ensures your `package.json` and `io-package.json` are valid. |
210
- | `test:unit` | Tests the adapter startup with unit tests (fast, but might require module mocks to work). |
211
- | `test:integration` | Tests the adapter startup with an actual instance of ioBroker. |
212
- | `test` | Performs a minimal test run on package files and your tests. |
213
- | `check` | Performs a type-check on your code (without compiling anything). |
214
- | `coverage` | Generates code coverage using your test files. |
215
- | `lint` | Runs `ESLint` to check your code for formatting errors and potential bugs. |
216
- | `release` | Creates a new release, see [`@alcalzone/release-script`](https://github.com/AlCalzone/release-script#usage) for more details. |
217
-
218
- ### Writing tests
219
- When done right, testing code is invaluable, because it gives you the
220
- confidence to change your code while knowing exactly if and when
221
- something breaks. A good read on the topic of test-driven development
222
- is https://hackernoon.com/introduction-to-test-driven-development-tdd-61a13bc92d92.
223
- Although writing tests before the code might seem strange at first, but it has very
224
- clear upsides.
225
-
226
- The template provides you with basic tests for the adapter startup and package files.
227
- It is recommended that you add your own tests into the mix.
228
-
229
-
230
257
  ## License
231
258
  MIT License
232
259
 
233
- Copyright (c) 2022 Thorsten <thorsten@stueben.de> / <https://github.com/schmupu>
260
+ Copyright (c) 2018-2022 Thorsten <thorsten@stueben.de> / <https://github.com/schmupu>
234
261
 
235
262
  Permission is hereby granted, free of charge, to any person obtaining a copy
236
263
  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,6 @@
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_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_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 = void 0;
4
4
  exports.COMMON_INFO_ID = {
5
5
  type: "string",
6
6
  role: "state",
@@ -248,6 +248,20 @@ exports.COMMON_DEBUG_REQUEST = {
248
248
  read: false,
249
249
  write: true
250
250
  };
251
+ exports.COMMON_NEW_TOKEN = {
252
+ type: "string",
253
+ role: "text",
254
+ name: "Next Refresh Token",
255
+ read: true,
256
+ write: false
257
+ };
258
+ exports.COMMON_OLD_TOKEN = {
259
+ type: "string",
260
+ role: "text",
261
+ name: "Outdated user token",
262
+ read: true,
263
+ write: false
264
+ };
251
265
  exports.CHANNEL_NAME_INFO = "Info";
252
266
  exports.CHANNEL_NAME_HISTORY = "History";
253
267
  exports.CHANNEL_NAME_LIGHT = "Light";
@@ -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,IAAI,EAAE,SAAS;IACf,IAAI,EAAE,OAAO;IACb,IAAI,EAAE,gBAAgB;IACtB,IAAI,EAAE,IAAI;IACV,KAAK,EAAE,KAAK;CACb,CAAA;AACY,QAAA,gBAAgB,GAAkC;IAC7D,IAAI,EAAE,QAAQ;IACd,IAAI,EAAE,MAAM;IACZ,IAAI,EAAE,SAAS;IACf,IAAI,EAAE,IAAI;IACV,KAAK,EAAE,KAAK;CACb,CAAA;AACY,QAAA,8BAA8B,GAAkC;IAC3E,IAAI,EAAE,QAAQ;IACd,IAAI,EAAE,eAAe;IACrB,IAAI,EAAE,SAAS;IACf,IAAI,EAAE,IAAI;IACV,KAAK,EAAE,KAAK;IACZ,IAAI,EAAE,GAAG;CACV,CAAA;AACY,QAAA,uCAAuC,GAAkC;IACp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QAAA,iBAAiB,GAAG,MAAM,CAAC;AAC3B,QAAA,oBAAoB,GAAG,SAAS,CAAC;AACjC,QAAA,kBAAkB,GAAG,OAAO,CAAC;AAC7B,QAAA,qBAAqB,GAAG,UAAU,CAAC;AACnC,QAAA,uBAAuB,GAAG,YAAY,CAAC;AACvC,QAAA,mBAAmB,GAAG,QAAQ,CAAC;AAG/B,QAAA,qBAAqB,GAAG,cAAc,CAAC;AACvC,QAAA,yBAAyB,GAAG,kBAAkB,CAAC;AAC/C,QAAA,2BAA2B,GAAG,oBAAoB,CAAC;AACnD,QAAA,sBAAsB,GAAG,eAAe,CAAC"}
@@ -38,7 +38,7 @@ var EventState;
38
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;
@@ -54,13 +54,12 @@ class OwnRingDevice {
54
54
  this._liveStreamCount = 0;
55
55
  this._state = EventState.Idle;
56
56
  this._adapter = adapter;
57
- this.debug(`Create device with ID: ${ringDevice.id}`);
58
57
  this._ringDevice = ringDevice;
59
- this._locationIndex = locationIndex;
58
+ this.shortId = `${ringDevice.id}`;
59
+ this.debug(`Create device`);
60
+ this._locationId = location.id;
60
61
  this._client = apiClient;
61
- this.path = `${this._locationIndex}.`;
62
62
  this.kind = OwnRingDevice.evaluateKind(ringDevice, adapter);
63
- this.shortId = `${ringDevice.id}`;
64
63
  this.fullId = `${this.kind}_${this.shortId}`;
65
64
  this.infoChannelId = `${this.fullId}.${constants_1.CHANNEL_NAME_INFO}`;
66
65
  this.historyChannelId = `${this.fullId}.${constants_1.CHANNEL_NAME_HISTORY}`;
@@ -98,6 +97,9 @@ class OwnRingDevice {
98
97
  case ring_client_api_1.RingCameraKind.floodlight_v2:
99
98
  case ring_client_api_1.RingCameraKind.spotlightw_v2:
100
99
  case ring_client_api_1.RingCameraKind.jbox_v1:
100
+ case "doorbell_graham_cracker":
101
+ case "lpd_v3":
102
+ case "lpd_v4":
101
103
  return `doorbell`;
102
104
  case ring_client_api_1.RingCameraKind.cocoa_camera:
103
105
  case ring_client_api_1.RingCameraKind.cocoa_doorbell:
@@ -112,7 +114,7 @@ class OwnRingDevice {
112
114
  return `stickup`;
113
115
  default:
114
116
  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)}`);
117
+ adapter.log.info(`Unsupported Device Info: ${util.inspect(device, false, 1)}`);
116
118
  }
117
119
  return "unknown";
118
120
  }
@@ -122,21 +124,28 @@ class OwnRingDevice {
122
124
  get lastSnapShotDir() {
123
125
  return this._lastSnapShotDir;
124
126
  }
125
- get locationIndex() {
126
- return this._locationIndex;
127
+ get locationId() {
128
+ return this._locationId;
127
129
  }
128
130
  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;
131
+ const location = this._client.getLocation(this._locationId);
132
+ if (location === undefined) {
133
+ this._adapter.log.error(`Can't find a Location with id ${this._locationId}`);
132
134
  }
133
- return this._client.locations[this._locationIndex];
135
+ return location;
134
136
  }
135
137
  get ringDevice() {
136
138
  return this._ringDevice;
137
139
  }
138
140
  set ringDevice(device) {
139
141
  this._ringDevice = device;
142
+ this.silly(`Start device subscriptions`);
143
+ this._ringDevice.subscribeToDingEvents().catch((r) => {
144
+ this.catcher(`Failed subscribing to Ding Events for ${device.name}`, r);
145
+ });
146
+ this._ringDevice.subscribeToMotionEvents().catch((r) => {
147
+ this.catcher(`Failed subscribing to Motion Events for ${device.name}`, r);
148
+ });
140
149
  this._ringDevice.onData.subscribe(this.update.bind(this));
141
150
  this._ringDevice.onMotionDetected.subscribe(this.onMotion.bind(this));
142
151
  this._ringDevice.onDoorbellPressed.subscribe(this.onDorbell.bind(this));
@@ -209,7 +218,7 @@ class OwnRingDevice {
209
218
  }
210
219
  }
211
220
  async recreateDeviceObjectTree() {
212
- this.silly(`Recreate DeviceObjectTree for ${this.fullId}`);
221
+ this.silly(`Recreate DeviceObjectTree`);
213
222
  this._adapter.createDevice(this.fullId, {
214
223
  name: `Device ${this.shortId} ("${this._ringDevice.data.description}")`
215
224
  });
@@ -219,7 +228,7 @@ class OwnRingDevice {
219
228
  this._adapter.createChannel(this.fullId, constants_1.CHANNEL_NAME_HISTORY);
220
229
  this._adapter.createChannel(this.fullId, constants_1.CHANNEL_NAME_EVENTS);
221
230
  if (this._ringDevice.hasLight) {
222
- this.debug(`Device with Light Capabilities detected "${this.fullId}"`);
231
+ this.debug(`Device with Light Capabilities detected`);
223
232
  this._adapter.createChannel(this.fullId, constants_1.CHANNEL_NAME_LIGHT, { name: `Light ${this.shortId}` });
224
233
  }
225
234
  this._lastSnapShotDir = await this._adapter.tryGetStringState(`${this.snapshotChannelId}.snapshot_file`);
@@ -228,10 +237,11 @@ class OwnRingDevice {
228
237
  }
229
238
  updateByDevice(ringDevice) {
230
239
  this.ringDevice = ringDevice;
240
+ this._state = EventState.Idle;
231
241
  this.update(ringDevice.data);
232
242
  }
233
243
  update(data) {
234
- this.debug(`Recieved Update for ${this.fullId}`);
244
+ this.debug(`Recieved Update`);
235
245
  this.updateDeviceInfoObject(data);
236
246
  this.updateHealth();
237
247
  // noinspection JSIgnoredPromiseFromCall
@@ -242,27 +252,33 @@ class OwnRingDevice {
242
252
  this.silly(`${this.shortId}.startLivestream()`);
243
253
  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
254
  if (!(await file_service_1.FileService.prepareFolder(dirname))) {
245
- this.debug(`Failed to prepare Livestream folder ("${fullPath}") for ${this.shortId}`);
255
+ this.debug(`Failed to prepare Livestream folder ("${fullPath}")`);
246
256
  return;
247
257
  }
248
- file_service_1.FileService.deleteFileIfExistSync(fullPath);
258
+ file_service_1.FileService.deleteFileIfExistSync(fullPath, this._adapter);
249
259
  if (this._ringDevice.isOffline) {
250
- this.info(`Device ${this.fullId} ("${this._ringDevice.data.description}") is offline --> won't take LiveStream
251
- `);
260
+ this.info(` is offline --> won't take LiveStream`);
252
261
  return;
253
262
  }
254
263
  duration !== null && duration !== void 0 ? duration : (duration = this._adapter.config.recordtime_livestream);
255
- this.silly(`Initialize Livestream (${duration}s) to file ${fullPath}`);
256
- await this._ringDevice.recordToFile(fullPath, duration);
257
- if (!fs.existsSync(fullPath)) {
258
- this.info(`Could't create livestream for ${this.shortId}`);
264
+ const tempPath = (await file_service_1.FileService.getTempDir(this._adapter)) + `/temp_${this.shortId}_livestream.mp4`;
265
+ this.silly(`Initialize Livestream (${duration}s) to temp-file ${tempPath}`);
266
+ await this._ringDevice.recordToFile(tempPath, duration);
267
+ if (!fs.existsSync(tempPath)) {
268
+ this.info(`Could't create livestream`);
259
269
  return;
260
270
  }
261
- const video = fs.readFileSync(fullPath);
271
+ const video = fs.readFileSync(tempPath);
272
+ fs.unlink(tempPath, (err) => {
273
+ if (err) {
274
+ this._adapter.logCatch(`Couldn't delete temp file`, err);
275
+ }
276
+ });
262
277
  this.silly(`Recieved Livestream has Length: ${video.length}`);
263
278
  this._lastLiveStreamUrl = await file_service_1.FileService.getVisUrl(this._adapter, this.fullId, "Livestream.mp4");
279
+ file_service_1.FileService.writeFileSync(fullPath, video, this._adapter);
264
280
  if (this.lastLiveStreamDir !== "" && this._adapter.config.del_old_livestream) {
265
- file_service_1.FileService.deleteFileIfExistSync(this._lastLiveStreamDir);
281
+ file_service_1.FileService.deleteFileIfExistSync(this._lastLiveStreamDir, this._adapter);
266
282
  }
267
283
  this._lastLiveStreamDir = fullPath;
268
284
  this._requestingLiveStream = false;
@@ -276,10 +292,9 @@ class OwnRingDevice {
276
292
  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);
277
293
  if (!(await file_service_1.FileService.prepareFolder(dirname)))
278
294
  return;
279
- file_service_1.FileService.deleteFileIfExistSync(fullPath);
295
+ file_service_1.FileService.deleteFileIfExistSync(fullPath, this._adapter);
280
296
  if (this._ringDevice.isOffline) {
281
- this.info(`Device ${this.fullId} ("${this._ringDevice.data.description}") is offline --> won't take Snapshot
282
- `);
297
+ this.info(`is offline --> won't take Snapshot`);
283
298
  return;
284
299
  }
285
300
  const image = await this._ringDevice.getSnapshot({ uuid: uuid }).catch((reason) => {
@@ -290,10 +305,10 @@ class OwnRingDevice {
290
305
  return;
291
306
  }
292
307
  this.silly(`Writing Snapshot (Length: ${image.length}) to "${fullPath}"`);
293
- fs.writeFileSync(fullPath, image);
308
+ file_service_1.FileService.writeFileSync(fullPath, image, this._adapter);
294
309
  this._lastSnapShotUrl = await file_service_1.FileService.getVisUrl(this._adapter, this.fullId, "Snapshot.jpg");
295
310
  if (this.lastSnapShotDir !== "" && this._adapter.config.del_old_snapshot) {
296
- file_service_1.FileService.deleteFileIfExistSync(this._lastSnapShotDir);
311
+ file_service_1.FileService.deleteFileIfExistSync(this._lastSnapShotDir, this._adapter);
297
312
  }
298
313
  this._lastSnapShotDir = fullPath;
299
314
  this._requestingSnapshot = false;
@@ -304,14 +319,14 @@ class OwnRingDevice {
304
319
  this.debug(`Done creating snapshot to ${fullPath}`);
305
320
  }
306
321
  updateHealth() {
307
- this.silly(`Update Health for ${this.fullId}`);
322
+ this.silly(`Update Health`);
308
323
  this._ringDevice.getHealth().then(this.updateHealthObject.bind(this));
309
324
  }
310
325
  async updateHistory() {
311
- this.silly(`Update History for ${this.fullId}`);
326
+ this.silly(`Update History`);
312
327
  this._ringDevice.getEvents({ limit: 50 })
313
328
  .then(async (r) => {
314
- this.silly(`Recieved Event History for ${this.fullId}`);
329
+ this.silly(`Recieved Event History`);
315
330
  const lastAction = r.events.find((event) => {
316
331
  const kind = event.kind;
317
332
  switch (kind) {
@@ -346,7 +361,7 @@ class OwnRingDevice {
346
361
  this._adapter.upsertState(`${this.historyChannelId}.kind`, constants_1.COMMON_HISTORY_KIND, lastAction.event.kind);
347
362
  }
348
363
  async updateSnapshotObject() {
349
- this.debug(`Update Snapshot Object for "${this.fullId}"`);
364
+ this.debug(`Update Snapshot Object`);
350
365
  if (this._lastSnapshotImage) {
351
366
  await this._adapter.upsertFile(`${this.snapshotChannelId}.jpg`, constants_1.COMMON_SNAPSHOT_SNAPSHOT, this._lastSnapshotImage, this._lastSnapshotTimestamp).catch((reason) => {
352
367
  this.debug(`Couldn't update Snapshot obejct: "${reason}"`);
@@ -360,7 +375,7 @@ class OwnRingDevice {
360
375
  }
361
376
  }
362
377
  async updateLiveStreamObject() {
363
- this.debug(`Update Livestream Object for "${this.fullId}"`);
378
+ this.debug(`Update Livestream Object`);
364
379
  if (this._lastLiveStreamVideo) {
365
380
  await this._adapter.upsertFile(`${this.liveStreamChannelId}.mp4`, constants_1.COMMON_LIVESTREAM_LIVESTREAM, this._lastLiveStreamVideo, this._lastLiveStreamTimestamp).catch((reason) => {
366
381
  this.debug(`Couldn't update Livestream obejct: "${reason}"`);
@@ -375,7 +390,7 @@ class OwnRingDevice {
375
390
  }
376
391
  updateHealthObject(health) {
377
392
  var _a;
378
- this.debug(`Update Health Callback for "${this.fullId}"`);
393
+ this.debug(`Update Health Callback`);
379
394
  let batteryPercent = parseInt((_a = health.battery_percentage) !== null && _a !== void 0 ? _a : "-1");
380
395
  if (isNaN(batteryPercent)) {
381
396
  batteryPercent = -1;
@@ -389,25 +404,25 @@ class OwnRingDevice {
389
404
  if (this._ringDevice.hasLight && (Date.now() - this._lastLightCommand > 60000)) {
390
405
  // this.silly(JSON.stringify(this._ringDevice.data));
391
406
  const floodlightOn = this._ringDevice.data.health.floodlight_on;
392
- this.debug(`Update Light within Health Update for "${this.fullId}" FLoodlight is ${floodlightOn}`);
407
+ this.debug(`Update Light within Health Update FLoodlight is ${floodlightOn}`);
393
408
  this._adapter.upsertState(`${this.lightChannelId}.light_state`, constants_1.COMMON_LIGHT_STATE, floodlightOn);
394
409
  this._adapter.upsertState(`${this.lightChannelId}.${constants_1.STATE_ID_LIGHT_SWITCH}`, constants_1.COMMON_LIGHT_SWITCH, floodlightOn, true);
395
410
  }
396
411
  }
397
412
  debug(message) {
398
- this._adapter.log.debug(message);
413
+ this._adapter.log.debug(`Device ${this.shortId} ("${this.ringDevice.data.description}"): ${message}`);
399
414
  }
400
415
  silly(message) {
401
- this._adapter.log.silly(message);
416
+ this._adapter.log.silly(`Device ${this.shortId} ("${this.ringDevice.data.description}"): ${message}`);
402
417
  }
403
418
  info(message) {
404
- this._adapter.log.info(message);
419
+ this._adapter.log.info(`Device ${this.shortId} ("${this.ringDevice.data.description}"): ${message}`);
405
420
  }
406
421
  catcher(message, reason) {
407
422
  this._adapter.logCatch(message, reason);
408
423
  }
409
424
  onDing(value) {
410
- this.debug(`Recieved Ding Event (${value}) for ${this.shortId}`);
425
+ this.debug(`Recieved Ding Event (${value})`);
411
426
  this.conditionalRecording(EventState.ReactingOnDing, value.ding.image_uuid);
412
427
  this._adapter.upsertState(`${this.eventsChannelId}.type`, constants_1.COMMON_EVENTS_TYPE, value.subtype);
413
428
  this._adapter.upsertState(`${this.eventsChannelId}.detectionType`, constants_1.COMMON_EVENTS_DETECTIONTYPE, value.ding.detection_type);
@@ -415,31 +430,39 @@ class OwnRingDevice {
415
430
  this._adapter.upsertState(`${this.eventsChannelId}.message`, constants_1.COMMON_EVENTS_MESSAGE, value.aps.alert);
416
431
  }
417
432
  onMotion(value) {
418
- this.debug(`Recieved Motion Event (${value}) for ${this.shortId}`);
433
+ this.debug(`Recieved Motion Event (${value})`);
419
434
  this._adapter.upsertState(`${this.eventsChannelId}.motion`, constants_1.COMMON_MOTION, value);
420
435
  if (value) {
421
436
  this.conditionalRecording(EventState.ReactingOnMotion);
422
437
  }
423
438
  }
424
439
  onDorbell(value) {
425
- this.debug(`Recieved Doorbell Event (${value}) for ${this.shortId}`);
440
+ this.debug(`Recieved Doorbell Event (${value})`);
426
441
  this.conditionalRecording(EventState.ReactingOnDoorbell, value.ding.image_uuid);
427
442
  this._adapter.upsertState(`${this.eventsChannelId}.doorbell`, constants_1.COMMON_EVENTS_DOORBELL, true);
428
443
  setTimeout(() => {
429
444
  this._adapter.upsertState(`${this.eventsChannelId}.doorbell`, constants_1.COMMON_EVENTS_DOORBELL, false);
430
445
  }, 5000);
431
446
  }
432
- conditionalRecording(state, uuid) {
447
+ async conditionalRecording(state, uuid) {
433
448
  if (this._state === EventState.Idle) {
434
- this.silly(`Start recording (with: ${this.shortId}) for Event "${EventState[state]}"...`);
449
+ this.silly(`Start recording for Event "${EventState[state]}"...`);
435
450
  this._state = state;
436
- this.takeSnapshot(uuid);
437
- this.startLivestream(20).then(() => {
451
+ try {
452
+ this.takeSnapshot(uuid);
453
+ await this.startLivestream(20);
454
+ }
455
+ finally {
438
456
  this._state = EventState.Idle;
439
- });
457
+ }
458
+ return;
440
459
  }
441
- else {
442
- this.silly(`Would have recorded due to "${EventState[state]}", but we are already reacting.`);
460
+ this.silly(`Would have recorded due to "${EventState[state]}", but we are already reacting.`);
461
+ if (uuid) {
462
+ setTimeout(() => {
463
+ this.debug(`delayed uuid recording`);
464
+ this.takeSnapshot(uuid);
465
+ }, 22000);
443
466
  }
444
467
  }
445
468
  }