ring-client-api 11.7.0-beta.5 → 11.7.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/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
  }
@@ -155,14 +157,15 @@ class RingApi extends subscribed_1.Subscribed {
155
157
  });
156
158
  pushReceiver.onNotification(({ message }) => {
157
159
  const dataJson = message.data?.gcmData;
158
- (0, util_1.logInfo)(`Received push notification: ${dataJson}`);
159
160
  try {
160
161
  const notification = JSON.parse(dataJson);
161
- if (!notification.ding) {
162
- // We may get notification that are not for a ding/motion, which can be ignored
163
- return;
162
+ if ('ding' in notification) {
163
+ sendToDevice(notification.ding.doorbot_id, notification);
164
+ }
165
+ else if ('alarm_meta' in notification) {
166
+ // Alarm notification, such as intercom unlocked
167
+ sendToDevice(notification.alarm_meta.device_zid, notification);
164
168
  }
165
- devicesById[notification.ding.doorbot_id]?.processPushNotification(notification);
166
169
  }
167
170
  catch (e) {
168
171
  (0, util_1.logError)(e);
@@ -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<PushNotification>;
30
- onActiveNotifications: BehaviorSubject<PushNotification[]>;
31
- onDoorbellPressed: import("rxjs").Observable<PushNotification>;
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(): PushNotification[];
42
- get latestNotification(): PushNotification | undefined;
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;
@@ -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);
@@ -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;
@@ -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;
@@ -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 PushNotification {
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;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ring-client-api",
3
- "version": "11.7.0-beta.5",
3
+ "version": "11.7.0",
4
4
  "description": "Unofficial API for Ring doorbells, cameras, security alarm system and smart lighting",
5
5
  "main": "lib/index.js",
6
6
  "exports": {