ring-client-api 11.7.0-beta.5 → 11.7.0-beta.6
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/lib/api.js +9 -5
- package/lib/ring-camera.d.ts +6 -6
- package/lib/ring-camera.js +4 -0
- package/lib/ring-intercom.d.ts +1 -0
- package/lib/ring-intercom.js +4 -0
- package/lib/ring-types.d.ts +25 -1
- package/package.json +1 -1
package/lib/api.js
CHANGED
|
@@ -125,7 +125,9 @@ class RingApi extends subscribed_1.Subscribed {
|
|
|
125
125
|
const pushReceiver = new push_receiver_1.default({
|
|
126
126
|
logLevel: 'NONE',
|
|
127
127
|
senderId: '876313859327', // for Ring android app. 703521446232 for ring-site
|
|
128
|
-
}), devicesById = {}
|
|
128
|
+
}), devicesById = {}, sendToDevice = (id, notification) => {
|
|
129
|
+
devicesById[id]?.processPushNotification(notification);
|
|
130
|
+
};
|
|
129
131
|
for (const camera of cameras) {
|
|
130
132
|
devicesById[camera.id] = camera;
|
|
131
133
|
}
|
|
@@ -158,11 +160,13 @@ class RingApi extends subscribed_1.Subscribed {
|
|
|
158
160
|
(0, util_1.logInfo)(`Received push notification: ${dataJson}`);
|
|
159
161
|
try {
|
|
160
162
|
const notification = JSON.parse(dataJson);
|
|
161
|
-
if (
|
|
162
|
-
|
|
163
|
-
|
|
163
|
+
if ('ding' in notification) {
|
|
164
|
+
sendToDevice(notification.ding.doorbot_id, notification);
|
|
165
|
+
}
|
|
166
|
+
else if ('alarm_meta' in notification) {
|
|
167
|
+
// Alarm notification, such as intercom unlocked
|
|
168
|
+
sendToDevice(notification.alarm_meta.device_zid, notification);
|
|
164
169
|
}
|
|
165
|
-
devicesById[notification.ding.doorbot_id]?.processPushNotification(notification);
|
|
166
170
|
}
|
|
167
171
|
catch (e) {
|
|
168
172
|
(0, util_1.logError)(e);
|
package/lib/ring-camera.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
-
import { CameraData, CameraDeviceSettingsData, CameraEventOptions, CameraEventResponse, CameraHealth, HistoryOptions, PeriodicFootageResponse, PushNotification, VideoSearchResponse, OnvifCameraData, RingCameraKind } from './ring-types';
|
|
2
|
+
import { CameraData, CameraDeviceSettingsData, CameraEventOptions, CameraEventResponse, CameraHealth, HistoryOptions, PeriodicFootageResponse, PushNotification, PushNotificationDing, VideoSearchResponse, OnvifCameraData, RingCameraKind } from './ring-types';
|
|
3
3
|
import { RingRestClient } from './rest-client';
|
|
4
4
|
import { BehaviorSubject, Subject } from 'rxjs';
|
|
5
5
|
import { DeepPartial } from './util';
|
|
@@ -26,9 +26,9 @@ export declare class RingCamera extends Subscribed {
|
|
|
26
26
|
hasLight: boolean;
|
|
27
27
|
hasSiren: boolean;
|
|
28
28
|
onRequestUpdate: Subject<unknown>;
|
|
29
|
-
onNewNotification: Subject<
|
|
30
|
-
onActiveNotifications: BehaviorSubject<
|
|
31
|
-
onDoorbellPressed: import("rxjs").Observable<
|
|
29
|
+
onNewNotification: Subject<PushNotificationDing>;
|
|
30
|
+
onActiveNotifications: BehaviorSubject<PushNotificationDing[]>;
|
|
31
|
+
onDoorbellPressed: import("rxjs").Observable<PushNotificationDing>;
|
|
32
32
|
onMotionDetected: import("rxjs").Observable<boolean>;
|
|
33
33
|
onMotionStarted: import("rxjs").Observable<null>;
|
|
34
34
|
onBatteryLevel: import("rxjs").Observable<number | null>;
|
|
@@ -38,8 +38,8 @@ export declare class RingCamera extends Subscribed {
|
|
|
38
38
|
requestUpdate(): void;
|
|
39
39
|
get data(): AnyCameraData;
|
|
40
40
|
get name(): string;
|
|
41
|
-
get activeNotifications():
|
|
42
|
-
get latestNotification():
|
|
41
|
+
get activeNotifications(): PushNotificationDing[];
|
|
42
|
+
get latestNotification(): PushNotificationDing | undefined;
|
|
43
43
|
get batteryLevel(): number | null;
|
|
44
44
|
get hasBattery(): boolean;
|
|
45
45
|
get hasLowBattery(): boolean;
|
package/lib/ring-camera.js
CHANGED
|
@@ -252,6 +252,10 @@ class RingCamera extends subscribed_1.Subscribed {
|
|
|
252
252
|
this.onActiveNotifications.next(otherDings);
|
|
253
253
|
}
|
|
254
254
|
processPushNotification(notification) {
|
|
255
|
+
if (!('ding' in notification)) {
|
|
256
|
+
// only process ding/motion notifications
|
|
257
|
+
return;
|
|
258
|
+
}
|
|
255
259
|
const activeDings = this.activeNotifications, dingId = notification.ding.id;
|
|
256
260
|
this.onActiveNotifications.next(activeDings.filter((d) => d.ding.id !== dingId).concat([notification]));
|
|
257
261
|
this.onNewNotification.next(notification);
|
package/lib/ring-intercom.d.ts
CHANGED
|
@@ -10,6 +10,7 @@ export declare class RingIntercom {
|
|
|
10
10
|
onRequestUpdate: Subject<unknown>;
|
|
11
11
|
onBatteryLevel: import("rxjs").Observable<number | null>;
|
|
12
12
|
onDing: Subject<void>;
|
|
13
|
+
onUnlocked: Subject<void>;
|
|
13
14
|
constructor(initialData: IntercomHandsetAudioData, restClient: RingRestClient);
|
|
14
15
|
updateData(update: IntercomHandsetAudioData): void;
|
|
15
16
|
requestUpdate(): void;
|
package/lib/ring-intercom.js
CHANGED
|
@@ -13,6 +13,7 @@ class RingIntercom {
|
|
|
13
13
|
this.restClient = restClient;
|
|
14
14
|
this.onRequestUpdate = new rxjs_1.Subject();
|
|
15
15
|
this.onDing = new rxjs_1.Subject();
|
|
16
|
+
this.onUnlocked = new rxjs_1.Subject();
|
|
16
17
|
this.id = this.initialData.id;
|
|
17
18
|
this.deviceType = this.initialData.kind;
|
|
18
19
|
this.onData = new rxjs_1.BehaviorSubject(this.initialData);
|
|
@@ -78,6 +79,9 @@ class RingIntercom {
|
|
|
78
79
|
if (notification.action === ring_types_1.PushNotificationAction.Ding) {
|
|
79
80
|
this.onDing.next();
|
|
80
81
|
}
|
|
82
|
+
else if (notification.action === ring_types_1.PushNotificationAction.IntercomUnlock) {
|
|
83
|
+
this.onUnlocked.next();
|
|
84
|
+
}
|
|
81
85
|
}
|
|
82
86
|
}
|
|
83
87
|
exports.RingIntercom = RingIntercom;
|
package/lib/ring-types.d.ts
CHANGED
|
@@ -868,7 +868,7 @@ export declare enum PushNotificationAction {
|
|
|
868
868
|
LowBattery = "com.ring.push.LOW_BATTERY_ALERT",
|
|
869
869
|
IntercomUnlock = "com.ring.push.INTERCOM_UNLOCK_FROM_APP"
|
|
870
870
|
}
|
|
871
|
-
export interface
|
|
871
|
+
export interface PushNotificationDing {
|
|
872
872
|
ding: {
|
|
873
873
|
streaming_protocol: 'ring_media_server';
|
|
874
874
|
location_id: string;
|
|
@@ -895,6 +895,30 @@ export interface PushNotification {
|
|
|
895
895
|
subtype: 'motion' | 'ding' | 'human' | string;
|
|
896
896
|
action: PushNotificationAction | string;
|
|
897
897
|
}
|
|
898
|
+
export interface PushNotificationAlarm {
|
|
899
|
+
aps: {
|
|
900
|
+
alert: string;
|
|
901
|
+
};
|
|
902
|
+
action: PushNotificationAction | string;
|
|
903
|
+
alarm_meta: {
|
|
904
|
+
device_zid: number;
|
|
905
|
+
location_id: string;
|
|
906
|
+
};
|
|
907
|
+
}
|
|
908
|
+
export interface PushNotificationLowBattery {
|
|
909
|
+
data: {
|
|
910
|
+
device_name: string;
|
|
911
|
+
doorbot_id: number;
|
|
912
|
+
battery_level: number;
|
|
913
|
+
device_kind: RingDeviceType;
|
|
914
|
+
timestamp_epoch_ms: number;
|
|
915
|
+
};
|
|
916
|
+
aps: {
|
|
917
|
+
title: string;
|
|
918
|
+
};
|
|
919
|
+
action: PushNotificationAction.LowBattery;
|
|
920
|
+
}
|
|
921
|
+
export declare type PushNotification = PushNotificationDing | PushNotificationAlarm | PushNotificationLowBattery;
|
|
898
922
|
export interface LiveCallResponse {
|
|
899
923
|
ding_id: string;
|
|
900
924
|
ding_kind: DingKind;
|