homebridge-ring 10.0.0-beta.4 → 10.0.0-beta.5
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/CHANGELOG.md +11 -0
- package/lib/api/api.js +2 -2
- package/lib/api/index.js +5 -1
- package/lib/api/live-call-ring-edge.js +1 -1
- package/lib/api/live-call.js +2 -1
- package/lib/api/ring-camera.d.ts +3 -1
- package/lib/api/ring-camera.js +21 -4
- package/lib/api/util.js +7 -0
- package/lib/test/api/ring-camera.spec.d.ts +1 -0
- package/lib/test/api/ring-camera.spec.js +25 -0
- package/package.json +22 -22
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,17 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
|
4
4
|
|
|
5
|
+
## [10.0.0-beta.5](https://github.com/dgreif/ring/compare/v10.0.0-beta.4...v10.0.0-beta.5) (2022-04-10)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
* **cameras:** wait to activate session until connected ([9a49389](https://github.com/dgreif/ring/commit/9a49389aa434cc5df4cfb4ba039bad0f2a30f756))
|
|
11
|
+
* handle push notification for unknown camera ([cc8fc2a](https://github.com/dgreif/ring/commit/cc8fc2a6377084515d3b169a85644b2a2b13235e))
|
|
12
|
+
* hide ECONNRESET errors from push receiver ([1196d96](https://github.com/dgreif/ring/commit/1196d96e67e26952f18dfbe75103419a7261bd1e))
|
|
13
|
+
* restore dual battery level calculations ([26fa84d](https://github.com/dgreif/ring/commit/26fa84dbd4bbcea8208fd0ade81c54c407aabf63))
|
|
14
|
+
* update dependencies ([4b97fb3](https://github.com/dgreif/ring/commit/4b97fb33623248147997944bab3de4ea3c2e5ee2))
|
|
15
|
+
|
|
5
16
|
## [10.0.0-beta.4](https://github.com/dgreif/ring/compare/v10.0.0-beta.3...v10.0.0-beta.4) (2022-04-03)
|
|
6
17
|
|
|
7
18
|
|
package/lib/api/api.js
CHANGED
|
@@ -126,7 +126,7 @@ class RingApi extends subscribed_1.Subscribed {
|
|
|
126
126
|
}
|
|
127
127
|
}));
|
|
128
128
|
pushReceiver.onNotification(({ message }) => {
|
|
129
|
-
var _a;
|
|
129
|
+
var _a, _b;
|
|
130
130
|
const dataJson = (_a = message.data) === null || _a === void 0 ? void 0 : _a.gcmData;
|
|
131
131
|
try {
|
|
132
132
|
const notification = JSON.parse(dataJson);
|
|
@@ -134,7 +134,7 @@ class RingApi extends subscribed_1.Subscribed {
|
|
|
134
134
|
// We may get notification that are not for a ding/motion, which can be ignored
|
|
135
135
|
return;
|
|
136
136
|
}
|
|
137
|
-
camerasById[notification.ding.doorbot_id].processPushNotification(notification);
|
|
137
|
+
(_b = camerasById[notification.ding.doorbot_id]) === null || _b === void 0 ? void 0 : _b.processPushNotification(notification);
|
|
138
138
|
}
|
|
139
139
|
catch (e) {
|
|
140
140
|
(0, util_1.logError)(e);
|
package/lib/api/index.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
|
@@ -236,7 +236,7 @@ class LiveCallRingEdge extends subscribed_1.Subscribed {
|
|
|
236
236
|
return;
|
|
237
237
|
}
|
|
238
238
|
this.activated = true;
|
|
239
|
-
yield (0, rxjs_1.firstValueFrom)(this.
|
|
239
|
+
yield (0, rxjs_1.firstValueFrom)(this.pc.onConnectionState.pipe((0, operators_1.filter)((state) => state === 'connected')));
|
|
240
240
|
(0, util_1.logInfo)('Activating Session');
|
|
241
241
|
this.sendSessionMessage('activate_session');
|
|
242
242
|
});
|
package/lib/api/live-call.js
CHANGED
|
@@ -145,7 +145,8 @@ class LiveCall extends subscribed_1.Subscribed {
|
|
|
145
145
|
return;
|
|
146
146
|
}
|
|
147
147
|
this.activated = true;
|
|
148
|
-
yield (0, rxjs_1.firstValueFrom)(this.
|
|
148
|
+
yield (0, rxjs_1.firstValueFrom)(this.pc.onConnectionState.pipe((0, operators_1.filter)((state) => state === 'connected')));
|
|
149
|
+
(0, util_1.logInfo)('Activating Session');
|
|
149
150
|
this.sendMessage({ method: 'activate_session' });
|
|
150
151
|
this.sendMessage({
|
|
151
152
|
video_enabled: true,
|
package/lib/api/ring-camera.d.ts
CHANGED
|
@@ -6,7 +6,9 @@ import { DeepPartial } from './util';
|
|
|
6
6
|
import { Subscribed } from './subscribed';
|
|
7
7
|
import { FfmpegOptions, LiveCall } from './live-call';
|
|
8
8
|
import { LiveCallRingEdge } from './live-call-ring-edge';
|
|
9
|
-
export declare function getBatteryLevel(
|
|
9
|
+
export declare function getBatteryLevel(data: Pick<CameraData, 'battery_life' | 'battery_life_2'> & {
|
|
10
|
+
health?: Partial<CameraData['health']>;
|
|
11
|
+
}): number | null;
|
|
10
12
|
export declare function getSearchQueryString(options: CameraEventOptions | (HistoryOptions & {
|
|
11
13
|
accountId: string;
|
|
12
14
|
})): string;
|
package/lib/api/ring-camera.js
CHANGED
|
@@ -19,17 +19,34 @@ const subscribed_1 = require("./subscribed");
|
|
|
19
19
|
const live_call_1 = require("./live-call");
|
|
20
20
|
const live_call_ring_edge_1 = require("./live-call-ring-edge");
|
|
21
21
|
const maxSnapshotRefreshSeconds = 15, fullDayMs = 24 * 60 * 60 * 1000;
|
|
22
|
+
function parseBatteryLife(batteryLife) {
|
|
23
|
+
if (batteryLife === null || batteryLife === undefined) {
|
|
24
|
+
return null;
|
|
25
|
+
}
|
|
26
|
+
const batteryLevel = typeof batteryLife === 'number'
|
|
27
|
+
? batteryLife
|
|
28
|
+
: Number.parseFloat(batteryLife);
|
|
29
|
+
if (isNaN(batteryLevel)) {
|
|
30
|
+
return null;
|
|
31
|
+
}
|
|
32
|
+
return batteryLevel;
|
|
33
|
+
}
|
|
22
34
|
function getStartOfToday() {
|
|
23
35
|
return new Date(new Date().toLocaleDateString()).getTime();
|
|
24
36
|
}
|
|
25
37
|
function getEndOfToday() {
|
|
26
38
|
return getStartOfToday() + fullDayMs - 1;
|
|
27
39
|
}
|
|
28
|
-
function getBatteryLevel(
|
|
29
|
-
|
|
40
|
+
function getBatteryLevel(data) {
|
|
41
|
+
const levels = [
|
|
42
|
+
parseBatteryLife(data.battery_life),
|
|
43
|
+
parseBatteryLife(data.battery_life_2),
|
|
44
|
+
].filter((level) => level !== null), { health } = data;
|
|
45
|
+
if (!levels.length ||
|
|
46
|
+
(health && !health.battery_percentage && !health.battery_present)) {
|
|
30
47
|
return null;
|
|
31
48
|
}
|
|
32
|
-
return
|
|
49
|
+
return Math.min(...levels);
|
|
33
50
|
}
|
|
34
51
|
exports.getBatteryLevel = getBatteryLevel;
|
|
35
52
|
function getSearchQueryString(options) {
|
|
@@ -117,7 +134,7 @@ class RingCamera extends subscribed_1.Subscribed {
|
|
|
117
134
|
return this.data.alerts.battery === 'low';
|
|
118
135
|
}
|
|
119
136
|
get isCharging() {
|
|
120
|
-
return
|
|
137
|
+
return this.initialData.external_connection;
|
|
121
138
|
}
|
|
122
139
|
get operatingOnBattery() {
|
|
123
140
|
return this.hasBattery && this.data.settings.power_mode !== 'wired';
|
package/lib/api/util.js
CHANGED
|
@@ -18,6 +18,7 @@ const colors_1 = require("colors");
|
|
|
18
18
|
const readline_1 = require("readline");
|
|
19
19
|
const uuid_1 = require("uuid");
|
|
20
20
|
const systeminformation_1 = require("systeminformation");
|
|
21
|
+
const logger_1 = __importDefault(require("@eneris/push-receiver/dist/utils/logger"));
|
|
21
22
|
const debugLogger = (0, debug_1.default)('ring'), uuidNamespace = 'e53ffdc0-e91d-4ce1-bec2-df939d94739d';
|
|
22
23
|
let logger = {
|
|
23
24
|
logInfo(message) {
|
|
@@ -120,3 +121,9 @@ function randomString(length) {
|
|
|
120
121
|
return uuid.replace(/-/g, '').substring(0, length).toLowerCase();
|
|
121
122
|
}
|
|
122
123
|
exports.randomString = randomString;
|
|
124
|
+
// Override push receiver logging to avoid ECONNRESET errors leaking
|
|
125
|
+
function logPushReceiver(...args) {
|
|
126
|
+
logDebug('[Push Receiver]');
|
|
127
|
+
logDebug(args[0]);
|
|
128
|
+
}
|
|
129
|
+
logger_1.default.error = logPushReceiver;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const api_1 = require("../../api");
|
|
4
|
+
describe('Ring Camera', () => {
|
|
5
|
+
describe('battery level', () => {
|
|
6
|
+
it('should handle string battery life', () => {
|
|
7
|
+
expect((0, api_1.getBatteryLevel)({
|
|
8
|
+
battery_life: '49',
|
|
9
|
+
})).toEqual(49);
|
|
10
|
+
});
|
|
11
|
+
it('should handle null battery life', () => {
|
|
12
|
+
expect((0, api_1.getBatteryLevel)({ battery_life: null })).toEqual(null);
|
|
13
|
+
});
|
|
14
|
+
it('should handle right battery only', () => {
|
|
15
|
+
expect((0, api_1.getBatteryLevel)({ battery_life: null, battery_life_2: 24 })).toEqual(24);
|
|
16
|
+
});
|
|
17
|
+
it('should handle left battery only', () => {
|
|
18
|
+
expect((0, api_1.getBatteryLevel)({ battery_life: 76, battery_life_2: null })).toEqual(76);
|
|
19
|
+
});
|
|
20
|
+
it('should handle dual batteries', () => {
|
|
21
|
+
expect((0, api_1.getBatteryLevel)({ battery_life: '92', battery_life_2: 84 })).toEqual(84);
|
|
22
|
+
expect((0, api_1.getBatteryLevel)({ battery_life: '92', battery_life_2: 100 })).toEqual(92);
|
|
23
|
+
});
|
|
24
|
+
});
|
|
25
|
+
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "homebridge-ring",
|
|
3
|
-
"version": "10.0.0-beta.
|
|
3
|
+
"version": "10.0.0-beta.5",
|
|
4
4
|
"description": "Homebridge plugin for Ring doorbells, cameras, security alarm system and smart lighting",
|
|
5
5
|
"main": "lib/homebridge/index.js",
|
|
6
6
|
"bin": {
|
|
@@ -42,42 +42,42 @@
|
|
|
42
42
|
"@eneris/push-receiver": "^3.0.1",
|
|
43
43
|
"@homebridge/camera-utils": "2.1.0",
|
|
44
44
|
"@homebridge/plugin-ui-utils": "0.0.19",
|
|
45
|
-
"@koush/werift": "0.14.5-
|
|
45
|
+
"@koush/werift": "0.14.5-beta9",
|
|
46
46
|
"@types/socket.io-client": "1.4.36",
|
|
47
47
|
"colors": "1.4.0",
|
|
48
|
-
"debug": "4.3.
|
|
48
|
+
"debug": "4.3.4",
|
|
49
49
|
"got": "11.8.3",
|
|
50
|
-
"rxjs": "7.5.
|
|
50
|
+
"rxjs": "7.5.5",
|
|
51
51
|
"socket.io-client": "2.4.0",
|
|
52
|
-
"systeminformation": "5.
|
|
52
|
+
"systeminformation": "5.11.9",
|
|
53
53
|
"uuid": "8.3.2",
|
|
54
|
-
"ws": "8.
|
|
54
|
+
"ws": "8.5.0"
|
|
55
55
|
},
|
|
56
56
|
"devDependencies": {
|
|
57
57
|
"@types/debug": "4.1.7",
|
|
58
|
-
"@types/jest": "27.4.
|
|
59
|
-
"@types/node": "17.0.
|
|
58
|
+
"@types/jest": "27.4.1",
|
|
59
|
+
"@types/node": "17.0.23",
|
|
60
60
|
"@types/uuid": "8.3.4",
|
|
61
|
-
"@types/ws": "^8.
|
|
62
|
-
"@typescript-eslint/eslint-plugin": "5.
|
|
63
|
-
"@typescript-eslint/parser": "5.
|
|
64
|
-
"concurrently": "^7.
|
|
61
|
+
"@types/ws": "^8.5.3",
|
|
62
|
+
"@typescript-eslint/eslint-plugin": "5.18.0",
|
|
63
|
+
"@typescript-eslint/parser": "5.18.0",
|
|
64
|
+
"concurrently": "^7.1.0",
|
|
65
65
|
"conventional-github-releaser": "3.1.5",
|
|
66
|
-
"dotenv": "
|
|
67
|
-
"esbuild": "^0.14.
|
|
68
|
-
"eslint": "8.
|
|
69
|
-
"eslint-config-prettier": "8.
|
|
70
|
-
"eslint-plugin-jest": "
|
|
66
|
+
"dotenv": "16.0.0",
|
|
67
|
+
"esbuild": "^0.14.34",
|
|
68
|
+
"eslint": "8.13.0",
|
|
69
|
+
"eslint-config-prettier": "8.5.0",
|
|
70
|
+
"eslint-plugin-jest": "26.1.4",
|
|
71
71
|
"eslint-plugin-prettier": "4.0.0",
|
|
72
|
-
"express": "4.17.
|
|
72
|
+
"express": "4.17.3",
|
|
73
73
|
"homebridge": "1.4.0",
|
|
74
|
-
"jest": "27.
|
|
75
|
-
"prettier": "2.
|
|
74
|
+
"jest": "27.5.1",
|
|
75
|
+
"prettier": "2.6.2",
|
|
76
76
|
"reflect-metadata": "0.1.13",
|
|
77
77
|
"rimraf": "3.0.2",
|
|
78
78
|
"standard-version": "9.3.2",
|
|
79
|
-
"ts-jest": "27.1.
|
|
80
|
-
"typescript": "4.
|
|
79
|
+
"ts-jest": "27.1.4",
|
|
80
|
+
"typescript": "4.6.3"
|
|
81
81
|
},
|
|
82
82
|
"engines": {
|
|
83
83
|
"node": ">=8.3.0",
|