homebridge-ring 11.6.0 → 11.7.0-beta.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/CHANGELOG.md CHANGED
@@ -1,5 +1,16 @@
1
1
  # homebridge-ring
2
2
 
3
+ ## 11.7.0-beta.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [`4fe3fed`](https://github.com/dgreif/ring/commit/4fe3fed87b6fac5f4f4661f80693be44c35f75f4) Thanks [@dgreif](https://github.com/dgreif)! - Add support of Intercoms. Currently the only supported features are unlocking and checking the battery level.
8
+
9
+ ### Patch Changes
10
+
11
+ - Updated dependencies [[`4fe3fed`](https://github.com/dgreif/ring/commit/4fe3fed87b6fac5f4f4661f80693be44c35f75f4)]:
12
+ - ring-client-api@11.7.0-beta.0
13
+
3
14
  ## 11.6.0
4
15
 
5
16
  ### Minor Changes
package/README.md CHANGED
@@ -211,6 +211,12 @@ Note: Although homebridge has support for HomeKit Secure Video (HKSV), I will no
211
211
  - Play "Motion" sound
212
212
  - Adjust speaker volume (Not supported in Home app)
213
213
 
214
+ ### Intercoms
215
+
216
+ Intercom support is still experimental. See [this issue](https://github.com/dgreif/ring/issues/1083) for more details
217
+
218
+ - Unlock door
219
+
214
220
  ### Alarm/Location Modes
215
221
 
216
222
  | HomeKit Mode | Ring Mode |
@@ -0,0 +1,94 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Intercom = void 0;
4
+ const hap_1 = require("./hap");
5
+ const base_data_accessory_1 = require("./base-data-accessory");
6
+ const util_1 = require("ring-client-api/util");
7
+ const operators_1 = require("rxjs/operators");
8
+ class Intercom extends base_data_accessory_1.BaseDataAccessory {
9
+ constructor(device, accessory, config) {
10
+ super();
11
+ this.device = device;
12
+ this.accessory = accessory;
13
+ this.config = config;
14
+ this.unlocking = false;
15
+ const { Characteristic, Service } = hap_1.hap, lockService = this.getService(Service.LockMechanism), { LockCurrentState, LockTargetState } = Characteristic;
16
+ // Lock Service
17
+ this.registerCharacteristic({
18
+ characteristicType: LockCurrentState,
19
+ serviceType: lockService,
20
+ getValue: () => this.getLockState(),
21
+ });
22
+ this.registerCharacteristic({
23
+ characteristicType: LockTargetState,
24
+ serviceType: lockService,
25
+ getValue: () => this.getLockState(),
26
+ setValue: async (state) => {
27
+ clearTimeout(this.unlockTimeout);
28
+ if (state === LockTargetState.UNSECURED) {
29
+ (0, util_1.logInfo)(`Unlocking ${device.name}`);
30
+ this.unlocking = true;
31
+ const response = await device.unlock().catch((e) => {
32
+ (0, util_1.logError)(e);
33
+ this.unlocking = false;
34
+ });
35
+ (0, util_1.logInfo)(`Unlock response: ${JSON.stringify(response)}`);
36
+ // Update current state to reflect that the lock is unlocked
37
+ lockService
38
+ .getCharacteristic(Characteristic.LockCurrentState)
39
+ .updateValue(this.getLockState());
40
+ // Leave the door in an "unlocked" state for 5 seconds
41
+ // After that, set the lock back to "locked" for both current and target state
42
+ this.unlockTimeout = setTimeout(() => {
43
+ this.unlocking = false;
44
+ lockService
45
+ .getCharacteristic(Characteristic.LockCurrentState)
46
+ .updateValue(this.getLockState());
47
+ lockService
48
+ .getCharacteristic(Characteristic.LockTargetState)
49
+ .updateValue(this.getLockState());
50
+ }, 5000);
51
+ }
52
+ else {
53
+ // If the user locks the door from the home app, we can't do anything but set the states back to "locked"
54
+ this.unlocking = false;
55
+ lockService
56
+ .getCharacteristic(Characteristic.LockCurrentState)
57
+ .updateValue(this.getLockState());
58
+ }
59
+ },
60
+ });
61
+ lockService.setPrimaryService(true);
62
+ // Battery Service
63
+ if (device.batteryLevel !== null) {
64
+ this.registerObservableCharacteristic({
65
+ characteristicType: Characteristic.BatteryLevel,
66
+ serviceType: Service.BatteryService,
67
+ onValue: device.onBatteryLevel.pipe((0, operators_1.map)((batteryLevel) => {
68
+ return batteryLevel === null ? 100 : batteryLevel;
69
+ })),
70
+ });
71
+ }
72
+ // Accessory Information Service
73
+ this.registerCharacteristic({
74
+ characteristicType: Characteristic.Manufacturer,
75
+ serviceType: Service.AccessoryInformation,
76
+ getValue: () => 'Ring',
77
+ });
78
+ this.registerCharacteristic({
79
+ characteristicType: Characteristic.Model,
80
+ serviceType: Service.AccessoryInformation,
81
+ getValue: () => 'Intercom Handset Audio',
82
+ });
83
+ this.registerCharacteristic({
84
+ characteristicType: Characteristic.SerialNumber,
85
+ serviceType: Service.AccessoryInformation,
86
+ getValue: (data) => data.device_id || 'Unknown',
87
+ });
88
+ }
89
+ getLockState() {
90
+ const { Characteristic: { LockCurrentState: State }, } = hap_1.hap;
91
+ return this.unlocking ? State.UNSECURED : State.SECURED;
92
+ }
93
+ }
94
+ exports.Intercom = Intercom;
@@ -29,6 +29,7 @@ const location_mode_switch_1 = require("./location-mode-switch");
29
29
  const thermostat_1 = require("./thermostat");
30
30
  const unknown_zwave_switch_1 = require("./unknown-zwave-switch");
31
31
  const util_2 = require("./util");
32
+ const intercom_1 = require("./intercom");
32
33
  const ignoreHiddenDeviceTypes = [
33
34
  ring_client_api_1.RingDeviceType.RingNetAdapter,
34
35
  ring_client_api_1.RingDeviceType.ZigbeeAdapter,
@@ -161,13 +162,15 @@ class RingPlatform {
161
162
  (0, util_1.logInfo)(` locationId: ${location.id} - ${location.name}`);
162
163
  });
163
164
  await Promise.all(locations.map(async (location) => {
164
- const devices = await location.getDevices(), cameras = location.cameras, chimes = location.chimes, allDevices = [...devices, ...cameras, ...chimes], securityPanel = devices.find((x) => x.deviceType === ring_client_api_1.RingDeviceType.SecurityPanel), debugPrefix = config_1.debug ? 'TEST ' : '', hapDevices = allDevices.map((device) => {
165
+ const devices = await location.getDevices(), { cameras, chimes, intercoms } = location, allDevices = [...devices, ...cameras, ...chimes, ...intercoms], securityPanel = devices.find((x) => x.deviceType === ring_client_api_1.RingDeviceType.SecurityPanel), debugPrefix = config_1.debug ? 'TEST ' : '', hapDevices = allDevices.map((device) => {
165
166
  const isCamera = device instanceof ring_client_api_1.RingCamera, cameraIdDifferentiator = isCamera ? 'camera' : '', // this forces bridged cameras from old version of the plugin to be seen as "stale"
166
167
  AccessoryClass = (device instanceof ring_client_api_1.RingCamera
167
168
  ? camera_1.Camera
168
169
  : device instanceof ring_client_api_1.RingChime
169
170
  ? chime_1.Chime
170
- : getAccessoryClass(device));
171
+ : device instanceof ring_client_api_1.RingIntercom
172
+ ? intercom_1.Intercom
173
+ : getAccessoryClass(device));
171
174
  return {
172
175
  deviceType: device.deviceType,
173
176
  device: device,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "homebridge-ring",
3
- "version": "11.6.0",
3
+ "version": "11.7.0-beta.0",
4
4
  "description": "Homebridge plugin for Ring doorbells, cameras, security alarm system and smart lighting",
5
5
  "main": "lib/index.js",
6
6
  "scripts": {
@@ -13,7 +13,7 @@
13
13
  "dependencies": {
14
14
  "@homebridge/camera-utils": "^2.2.0",
15
15
  "@homebridge/plugin-ui-utils": "^0.0.19",
16
- "ring-client-api": "11.6.0"
16
+ "ring-client-api": "11.7.0-beta.0"
17
17
  },
18
18
  "devDependencies": {
19
19
  "concurrently": "^7.5.0",