homebridge-ring 11.1.0 → 11.2.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.
Files changed (64) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/README.md +153 -144
  3. package/config.schema.json +6 -6
  4. package/lib/api/ring-types.d.ts +11 -1
  5. package/lib/api/ring-types.js +3 -0
  6. package/lib/api/util.d.ts +2 -2
  7. package/lib/api/util.js +2 -2
  8. package/lib/homebridge/base-accessory.d.ts +1 -2
  9. package/lib/homebridge/base-accessory.js +3 -2
  10. package/lib/homebridge/base-data-accessory.d.ts +1 -2
  11. package/lib/homebridge/base-data-accessory.js +5 -6
  12. package/lib/homebridge/base-device-accessory.d.ts +1 -2
  13. package/lib/homebridge/beam.d.ts +2 -3
  14. package/lib/homebridge/beam.js +6 -5
  15. package/lib/homebridge/{base-station.d.ts → brightness-only.d.ts} +4 -4
  16. package/lib/homebridge/brightness-only.js +52 -0
  17. package/lib/homebridge/camera.d.ts +2 -3
  18. package/lib/homebridge/camera.js +6 -6
  19. package/lib/homebridge/chime.d.ts +2 -3
  20. package/lib/homebridge/chime.js +1 -2
  21. package/lib/homebridge/co-alarm.d.ts +2 -3
  22. package/lib/homebridge/co-alarm.js +1 -2
  23. package/lib/homebridge/config.d.ts +1 -1
  24. package/lib/homebridge/contact-sensor.d.ts +2 -3
  25. package/lib/homebridge/contact-sensor.js +1 -2
  26. package/lib/homebridge/fan.d.ts +2 -3
  27. package/lib/homebridge/fan.js +4 -4
  28. package/lib/homebridge/flood-freeze-sensor.d.ts +2 -3
  29. package/lib/homebridge/flood-freeze-sensor.js +4 -4
  30. package/lib/homebridge/freeze-sensor.d.ts +2 -3
  31. package/lib/homebridge/freeze-sensor.js +3 -3
  32. package/lib/homebridge/location-mode-switch.d.ts +2 -3
  33. package/lib/homebridge/location-mode-switch.js +4 -5
  34. package/lib/homebridge/lock.d.ts +2 -3
  35. package/lib/homebridge/lock.js +1 -2
  36. package/lib/homebridge/motion-sensor.d.ts +2 -3
  37. package/lib/homebridge/motion-sensor.js +1 -2
  38. package/lib/homebridge/multi-level-switch.d.ts +2 -3
  39. package/lib/homebridge/multi-level-switch.js +4 -4
  40. package/lib/homebridge/outlet.d.ts +2 -3
  41. package/lib/homebridge/outlet.js +3 -3
  42. package/lib/homebridge/panic-buttons.d.ts +2 -3
  43. package/lib/homebridge/panic-buttons.js +6 -6
  44. package/lib/homebridge/ring-platform.js +24 -25
  45. package/lib/homebridge/security-panel.d.ts +4 -4
  46. package/lib/homebridge/security-panel.js +14 -11
  47. package/lib/homebridge/smoke-alarm.d.ts +2 -3
  48. package/lib/homebridge/smoke-alarm.js +1 -2
  49. package/lib/homebridge/smoke-co-listener.d.ts +2 -3
  50. package/lib/homebridge/smoke-co-listener.js +1 -2
  51. package/lib/homebridge/switch.d.ts +2 -3
  52. package/lib/homebridge/switch.js +3 -3
  53. package/lib/homebridge/temperature-sensor.d.ts +2 -3
  54. package/lib/homebridge/temperature-sensor.js +1 -2
  55. package/lib/homebridge/thermostat.d.ts +2 -3
  56. package/lib/homebridge/thermostat.js +11 -11
  57. package/lib/homebridge/unknown-zwave-switch.d.ts +2 -3
  58. package/lib/homebridge/unknown-zwave-switch.js +3 -3
  59. package/lib/homebridge/water-sensor.d.ts +2 -3
  60. package/lib/homebridge/water-sensor.js +3 -3
  61. package/package.json +1 -1
  62. package/lib/homebridge/base-station.js +0 -14
  63. package/lib/homebridge/keypad.d.ts +0 -11
  64. package/lib/homebridge/keypad.js +0 -14
@@ -1,13 +1,12 @@
1
1
  import { BaseDeviceAccessory } from './base-device-accessory';
2
2
  import { RingDevice } from '../api';
3
3
  import { RingPlatformConfig } from './config';
4
- import { Logging, PlatformAccessory } from 'homebridge';
4
+ import { PlatformAccessory } from 'homebridge';
5
5
  export declare class MultiLevelSwitch extends BaseDeviceAccessory {
6
6
  readonly device: RingDevice;
7
7
  readonly accessory: PlatformAccessory;
8
- readonly logger: Logging;
9
8
  readonly config: RingPlatformConfig;
10
- constructor(device: RingDevice, accessory: PlatformAccessory, logger: Logging, config: RingPlatformConfig);
9
+ constructor(device: RingDevice, accessory: PlatformAccessory, config: RingPlatformConfig);
11
10
  setOnState(on: boolean): Promise<void>;
12
11
  setLevelState(level: number): Promise<void>;
13
12
  }
@@ -3,12 +3,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.MultiLevelSwitch = void 0;
4
4
  const base_device_accessory_1 = require("./base-device-accessory");
5
5
  const hap_1 = require("./hap");
6
+ const util_1 = require("../api/util");
6
7
  class MultiLevelSwitch extends base_device_accessory_1.BaseDeviceAccessory {
7
- constructor(device, accessory, logger, config) {
8
+ constructor(device, accessory, config) {
8
9
  super();
9
10
  this.device = device;
10
11
  this.accessory = accessory;
11
- this.logger = logger;
12
12
  this.config = config;
13
13
  const { Characteristic, Service } = hap_1.hap, { data: initialData } = this.device;
14
14
  this.registerCharacteristic({
@@ -30,11 +30,11 @@ class MultiLevelSwitch extends base_device_accessory_1.BaseDeviceAccessory {
30
30
  // SOMEDAY: Hue/Sat/Color Temp
31
31
  }
32
32
  setOnState(on) {
33
- this.logger.info(`Turning ${this.device.name} ${on ? 'On' : 'Off'}`);
33
+ (0, util_1.logInfo)(`Turning ${this.device.name} ${on ? 'On' : 'Off'}`);
34
34
  return this.device.setInfo({ device: { v1: { on } } });
35
35
  }
36
36
  setLevelState(level) {
37
- this.logger.info(`Setting brightness of ${this.device.name} to ${level}%`);
37
+ (0, util_1.logInfo)(`Setting brightness of ${this.device.name} to ${level}%`);
38
38
  return this.device.setInfo({
39
39
  device: { v1: { level: level / 100 } },
40
40
  });
@@ -1,12 +1,11 @@
1
1
  import { BaseDeviceAccessory } from './base-device-accessory';
2
2
  import { RingDevice } from '../api';
3
3
  import { RingPlatformConfig } from './config';
4
- import { Logging, PlatformAccessory } from 'homebridge';
4
+ import { PlatformAccessory } from 'homebridge';
5
5
  export declare class Outlet extends BaseDeviceAccessory {
6
6
  readonly device: RingDevice;
7
7
  readonly accessory: PlatformAccessory;
8
- readonly logger: Logging;
9
8
  readonly config: RingPlatformConfig;
10
- constructor(device: RingDevice, accessory: PlatformAccessory, logger: Logging, config: RingPlatformConfig);
9
+ constructor(device: RingDevice, accessory: PlatformAccessory, config: RingPlatformConfig);
11
10
  setOnState(on: boolean): Promise<void>;
12
11
  }
@@ -3,12 +3,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Outlet = void 0;
4
4
  const base_device_accessory_1 = require("./base-device-accessory");
5
5
  const hap_1 = require("./hap");
6
+ const util_1 = require("../api/util");
6
7
  class Outlet extends base_device_accessory_1.BaseDeviceAccessory {
7
- constructor(device, accessory, logger, config) {
8
+ constructor(device, accessory, config) {
8
9
  super();
9
10
  this.device = device;
10
11
  this.accessory = accessory;
11
- this.logger = logger;
12
12
  this.config = config;
13
13
  const { Characteristic, Service } = hap_1.hap;
14
14
  this.registerCharacteristic({
@@ -24,7 +24,7 @@ class Outlet extends base_device_accessory_1.BaseDeviceAccessory {
24
24
  });
25
25
  }
26
26
  setOnState(on) {
27
- this.logger.info(`Turning ${this.device.name} ${on ? 'On' : 'Off'}`);
27
+ (0, util_1.logInfo)(`Turning ${this.device.name} ${on ? 'On' : 'Off'}`);
28
28
  return this.device.setInfo({ device: { v1: { on } } });
29
29
  }
30
30
  }
@@ -1,12 +1,11 @@
1
1
  import { RingDevice } from '../api';
2
2
  import { RingPlatformConfig } from './config';
3
3
  import { BaseDataAccessory } from './base-data-accessory';
4
- import { Logging, PlatformAccessory } from 'homebridge';
4
+ import { PlatformAccessory } from 'homebridge';
5
5
  export declare class PanicButtons extends BaseDataAccessory<RingDevice> {
6
6
  readonly device: RingDevice;
7
7
  readonly accessory: PlatformAccessory;
8
- readonly logger: Logging;
9
8
  readonly config: RingPlatformConfig;
10
- constructor(device: RingDevice, accessory: PlatformAccessory, logger: Logging, config: RingPlatformConfig);
9
+ constructor(device: RingDevice, accessory: PlatformAccessory, config: RingPlatformConfig);
11
10
  initBase(): void;
12
11
  }
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.PanicButtons = void 0;
4
4
  const hap_1 = require("./hap");
5
5
  const base_data_accessory_1 = require("./base-data-accessory");
6
+ const util_1 = require("../api/util");
6
7
  const burglarStates = [
7
8
  'burglar-alarm',
8
9
  'user-verified-burglar-alarm',
@@ -16,11 +17,10 @@ function matchesAnyAlarmState({ alarmInfo }, targetStates) {
16
17
  return Boolean(alarmInfo && targetStates.includes(alarmInfo.state));
17
18
  }
18
19
  class PanicButtons extends base_data_accessory_1.BaseDataAccessory {
19
- constructor(device, accessory, logger, config) {
20
+ constructor(device, accessory, config) {
20
21
  super();
21
22
  this.device = device;
22
23
  this.accessory = accessory;
23
- this.logger = logger;
24
24
  this.config = config;
25
25
  const { Characteristic, Service } = hap_1.hap, locationName = device.location.name;
26
26
  this.registerCharacteristic({
@@ -31,10 +31,10 @@ class PanicButtons extends base_data_accessory_1.BaseDataAccessory {
31
31
  getValue: (data) => matchesAnyAlarmState(data, burglarStates),
32
32
  setValue: (on) => {
33
33
  if (on) {
34
- this.logger.info(`Burglar Alarm activated for ${locationName}`);
34
+ (0, util_1.logInfo)(`Burglar Alarm activated for ${locationName}`);
35
35
  return this.device.location.triggerBurglarAlarm();
36
36
  }
37
- this.logger.info(`Burglar Alarm turned off for ${locationName}`);
37
+ (0, util_1.logInfo)(`Burglar Alarm turned off for ${locationName}`);
38
38
  return this.device.location.setAlarmMode('none');
39
39
  },
40
40
  });
@@ -46,10 +46,10 @@ class PanicButtons extends base_data_accessory_1.BaseDataAccessory {
46
46
  getValue: (data) => matchesAnyAlarmState(data, fireStates),
47
47
  setValue: (on) => {
48
48
  if (on) {
49
- this.logger.info(`Fire Alarm activated for ${locationName}`);
49
+ (0, util_1.logInfo)(`Fire Alarm activated for ${locationName}`);
50
50
  return this.device.location.triggerFireAlarm();
51
51
  }
52
- this.logger.info(`Fire Alarm turned off for ${locationName}`);
52
+ (0, util_1.logInfo)(`Fire Alarm turned off for ${locationName}`);
53
53
  return this.device.location.setAlarmMode('none');
54
54
  },
55
55
  });
@@ -4,9 +4,8 @@ exports.RingPlatform = exports.pluginName = exports.platformName = void 0;
4
4
  const api_1 = require("../api");
5
5
  const hap_1 = require("./hap");
6
6
  const security_panel_1 = require("./security-panel");
7
- const base_station_1 = require("./base-station");
8
7
  const chime_1 = require("./chime");
9
- const keypad_1 = require("./keypad");
8
+ const brightness_only_1 = require("./brightness-only");
10
9
  const contact_sensor_1 = require("./contact-sensor");
11
10
  const motion_sensor_1 = require("./motion-sensor");
12
11
  const lock_1 = require("./lock");
@@ -30,7 +29,7 @@ const location_mode_switch_1 = require("./location-mode-switch");
30
29
  const thermostat_1 = require("./thermostat");
31
30
  const unknown_zwave_switch_1 = require("./unknown-zwave-switch");
32
31
  const util_2 = require("./util");
33
- const debug = __filename.includes('release-homebridge'), unsupportedDeviceTypes = [api_1.RingDeviceType.BaseStation, api_1.RingDeviceType.Keypad], ignoreHiddenDeviceTypes = [
32
+ const debug = __filename.includes('release-homebridge'), ignoreHiddenDeviceTypes = [
34
33
  api_1.RingDeviceType.RingNetAdapter,
35
34
  api_1.RingDeviceType.ZigbeeAdapter,
36
35
  api_1.RingDeviceType.CodeVault,
@@ -63,9 +62,9 @@ function getAccessoryClass(device) {
63
62
  case api_1.RingDeviceType.SecurityPanel:
64
63
  return security_panel_1.SecurityPanel;
65
64
  case api_1.RingDeviceType.BaseStation:
66
- return base_station_1.BaseStation;
65
+ case api_1.RingDeviceType.BaseStationPro:
67
66
  case api_1.RingDeviceType.Keypad:
68
- return keypad_1.Keypad;
67
+ return brightness_only_1.BrightnessOnly;
69
68
  case api_1.RingDeviceType.SmokeAlarm:
70
69
  return smoke_alarm_1.SmokeAlarm;
71
70
  case api_1.RingDeviceType.CoAlarm:
@@ -117,16 +116,18 @@ class RingPlatform {
117
116
  this.config = config;
118
117
  this.api = api;
119
118
  this.homebridgeAccessories = {};
120
- (0, util_1.useLogger)({
121
- logInfo(message) {
122
- log.info(message);
123
- },
124
- logError(message) {
125
- log.error(message);
126
- },
127
- });
119
+ if (!config.disableLogs) {
120
+ (0, util_1.useLogger)({
121
+ logInfo(message) {
122
+ log.info(message);
123
+ },
124
+ logError(message) {
125
+ log.error(message);
126
+ },
127
+ });
128
+ }
128
129
  if (!config) {
129
- this.log.info('No configuration found for platform Ring');
130
+ (0, util_1.logInfo)('No configuration found for platform Ring');
130
131
  return;
131
132
  }
132
133
  config.cameraStatusPollingSeconds = config.cameraStatusPollingSeconds ?? 20;
@@ -146,7 +147,7 @@ class RingPlatform {
146
147
  this.homebridgeAccessories = {};
147
148
  }
148
149
  configureAccessory(accessory) {
149
- this.log.info(`Configuring cached accessory ${accessory.UUID} ${accessory.displayName}`);
150
+ (0, util_1.logInfo)(`Configuring cached accessory ${accessory.UUID} ${accessory.displayName}`);
150
151
  this.log.debug('%j', accessory);
151
152
  this.homebridgeAccessories[accessory.UUID] = accessory;
152
153
  }
@@ -156,9 +157,9 @@ class RingPlatform {
156
157
  ...config,
157
158
  systemId,
158
159
  }), locations = await ringApi.getLocations(), cachedAccessoryIds = Object.keys(this.homebridgeAccessories), platformAccessories = [], externalAccessories = [], activeAccessoryIds = [];
159
- this.log.info('Found the following locations:');
160
+ (0, util_1.logInfo)('Found the following locations:');
160
161
  locations.forEach((location) => {
161
- this.log.info(` locationId: ${location.id} - ${location.name}`);
162
+ (0, util_1.logInfo)(` locationId: ${location.id} - ${location.name}`);
162
163
  });
163
164
  await Promise.all(locations.map(async (location) => {
164
165
  const devices = await location.getDevices(), cameras = location.cameras, chimes = location.chimes, allDevices = [...devices, ...cameras, ...chimes], securityPanel = devices.find((x) => x.deviceType === api_1.RingDeviceType.SecurityPanel), debugPrefix = debug ? 'TEST ' : '', hapDevices = allDevices.map((device) => {
@@ -200,18 +201,16 @@ class RingPlatform {
200
201
  AccessoryClass: location_mode_switch_1.LocationModeSwitch,
201
202
  });
202
203
  }
203
- this.log.info(`Configuring ${cameras.length} cameras and ${hapDevices.length} devices for location "${location.name}" - locationId: ${location.id}`);
204
+ (0, util_1.logInfo)(`Configuring ${cameras.length} cameras and ${hapDevices.length} devices for location "${location.name}" - locationId: ${location.id}`);
204
205
  hapDevices.forEach(({ deviceType, device, isCamera, id, name, AccessoryClass }) => {
205
206
  const uuid = hap_1.hap.uuid.generate(debugPrefix + id), displayName = debugPrefix + name, isExternalCamera = isCamera && this.config.unbridgeCameras;
206
207
  if (!AccessoryClass ||
207
208
  (config.hideLightGroups &&
208
209
  deviceType === api_1.RingDeviceType.BeamsLightGroupSwitch) ||
209
- (config.hideUnsupportedServices &&
210
- unsupportedDeviceTypes.includes(deviceType)) ||
211
210
  hideDeviceIds.includes(uuid) ||
212
211
  (onlyDeviceTypes && !onlyDeviceTypes.includes(deviceType))) {
213
212
  if (!ignoreHiddenDeviceTypes.includes(deviceType)) {
214
- this.log.info(`Hidden accessory ${uuid} ${deviceType} ${displayName}`);
213
+ (0, util_1.logInfo)(`Hidden accessory ${uuid} ${deviceType} ${displayName}`);
215
214
  }
216
215
  return;
217
216
  }
@@ -228,11 +227,11 @@ class RingPlatform {
228
227
  ? 17 /* hap.Categories.CAMERA */
229
228
  : 11 /* hap.Categories.SECURITY_SYSTEM */);
230
229
  if (isExternalCamera) {
231
- this.log.info(`Configured camera ${uuid} ${deviceType} ${displayName}`);
230
+ (0, util_1.logInfo)(`Configured camera ${uuid} ${deviceType} ${displayName}`);
232
231
  externalAccessories.push(accessory);
233
232
  }
234
233
  else {
235
- this.log.info(`Adding new accessory ${uuid} ${deviceType} ${displayName}`);
234
+ (0, util_1.logInfo)(`Adding new accessory ${uuid} ${deviceType} ${displayName}`);
236
235
  platformAccessories.push(accessory);
237
236
  }
238
237
  if (isCamera &&
@@ -242,7 +241,7 @@ class RingPlatform {
242
241
  hap_1.hap.Accessory.cleanupAccessoryData((0, util_2.generateMacAddress)(accessory.UUID));
243
242
  }
244
243
  return accessory;
245
- }, homebridgeAccessory = this.homebridgeAccessories[uuid] || createHomebridgeAccessory(), accessory = new AccessoryClass(device, homebridgeAccessory, this.log, config);
244
+ }, homebridgeAccessory = this.homebridgeAccessories[uuid] || createHomebridgeAccessory(), accessory = new AccessoryClass(device, homebridgeAccessory, config);
246
245
  accessory.initBase();
247
246
  this.homebridgeAccessories[uuid] = homebridgeAccessory;
248
247
  activeAccessoryIds.push(uuid);
@@ -258,7 +257,7 @@ class RingPlatform {
258
257
  .filter((cachedId) => !activeAccessoryIds.includes(cachedId))
259
258
  .map((id) => this.homebridgeAccessories[id]);
260
259
  staleAccessories.forEach((staleAccessory) => {
261
- this.log.info(`Removing stale cached accessory ${staleAccessory.UUID} ${staleAccessory.displayName}`);
260
+ (0, util_1.logInfo)(`Removing stale cached accessory ${staleAccessory.UUID} ${staleAccessory.displayName}`);
262
261
  });
263
262
  if (staleAccessories.length) {
264
263
  this.api.unregisterPlatformAccessories(exports.pluginName, exports.platformName, staleAccessories);
@@ -1,17 +1,17 @@
1
1
  import { BaseDeviceAccessory } from './base-device-accessory';
2
2
  import { AlarmMode, RingDevice, RingDeviceData } from '../api';
3
3
  import { RingPlatformConfig } from './config';
4
- import { Logging, PlatformAccessory } from 'homebridge';
4
+ import { PlatformAccessory } from 'homebridge';
5
5
  export declare class SecurityPanel extends BaseDeviceAccessory {
6
6
  readonly device: RingDevice;
7
7
  readonly accessory: PlatformAccessory;
8
- readonly logger: Logging;
9
8
  readonly config: RingPlatformConfig;
10
9
  private alarmStates;
11
- constructor(device: RingDevice, accessory: PlatformAccessory, logger: Logging, config: RingPlatformConfig);
10
+ constructor(device: RingDevice, accessory: PlatformAccessory, config: RingPlatformConfig);
12
11
  getTargetNightMode(): false | AlarmMode;
13
12
  getTargetState({ mode }: RingDeviceData): 1 | 0 | 2 | 3;
14
13
  getCurrentState(data: RingDeviceData): 1 | 0 | 2 | 3 | 4;
15
- private targetingNightMode;
14
+ get targetingNightMode(): boolean;
15
+ set targetingNightMode(value: boolean);
16
16
  setTargetState(state: any): Promise<void>;
17
17
  }
@@ -4,20 +4,19 @@ exports.SecurityPanel = void 0;
4
4
  const base_device_accessory_1 = require("./base-device-accessory");
5
5
  const api_1 = require("../api");
6
6
  const hap_1 = require("./hap");
7
+ const util_1 = require("../api/util");
7
8
  function isValidNightModeBypass(mode) {
8
9
  return mode && (mode === 'all' || mode === 'some');
9
10
  }
10
11
  class SecurityPanel extends base_device_accessory_1.BaseDeviceAccessory {
11
- constructor(device, accessory, logger, config) {
12
+ constructor(device, accessory, config) {
12
13
  super();
13
14
  this.device = device;
14
15
  this.accessory = accessory;
15
- this.logger = logger;
16
16
  this.config = config;
17
17
  this.alarmStates = this.config.alarmOnEntryDelay
18
18
  ? api_1.allAlarmStates
19
19
  : api_1.allAlarmStates.filter((x) => x !== 'entry-delay');
20
- this.targetingNightMode = false;
21
20
  const { Characteristic, Service } = hap_1.hap, validValues = [
22
21
  Characteristic.SecuritySystemTargetState.AWAY_ARM,
23
22
  Characteristic.SecuritySystemTargetState.STAY_ARM,
@@ -62,12 +61,10 @@ class SecurityPanel extends base_device_accessory_1.BaseDeviceAccessory {
62
61
  getTargetState({ mode }) {
63
62
  const { Characteristic: { SecuritySystemTargetState: State }, } = hap_1.hap;
64
63
  if (mode === this.getTargetNightMode()) {
65
- setTimeout(() => {
66
- // clear in next tick so that Target and Current state both get night mode
67
- this.targetingNightMode = false;
68
- });
69
64
  return State.NIGHT_ARM;
70
65
  }
66
+ // current mode does not match night mode target, so we are no longer targeting night mode
67
+ this.targetingNightMode = false;
71
68
  switch (mode) {
72
69
  case 'all':
73
70
  return State.AWAY_ARM;
@@ -86,6 +83,12 @@ class SecurityPanel extends base_device_accessory_1.BaseDeviceAccessory {
86
83
  }
87
84
  return this.getTargetState(data);
88
85
  }
86
+ get targetingNightMode() {
87
+ return this.accessory.context.targetingNightMode;
88
+ }
89
+ set targetingNightMode(value) {
90
+ this.accessory.context.targetingNightMode = value;
91
+ }
89
92
  async setTargetState(state) {
90
93
  const { Characteristic: { SecuritySystemTargetState: State }, } = hap_1.hap, { location } = this.device, { nightModeBypassFor } = this.config;
91
94
  let bypass = false;
@@ -111,20 +114,20 @@ class SecurityPanel extends base_device_accessory_1.BaseDeviceAccessory {
111
114
  : '';
112
115
  try {
113
116
  if (state === State.AWAY_ARM) {
114
- this.logger.info(`Arming (Away) ${this.device.name}${bypassLog}`);
117
+ (0, util_1.logInfo)(`Arming (Away) ${this.device.name}${bypassLog}`);
115
118
  await location.armAway(bypassSensorZids);
116
119
  }
117
120
  else if (state === State.DISARM) {
118
- this.logger.info(`Disarming ${this.device.name}`);
121
+ (0, util_1.logInfo)(`Disarming ${this.device.name}`);
119
122
  await location.disarm();
120
123
  }
121
124
  else {
122
- this.logger.info(`Arming (Home) ${this.device.name}${bypassLog}`);
125
+ (0, util_1.logInfo)(`Arming (Home) ${this.device.name}${bypassLog}`);
123
126
  await location.armHome(bypassSensorZids);
124
127
  }
125
128
  }
126
129
  catch (e) {
127
- this.logger.error(e);
130
+ (0, util_1.logError)(e);
128
131
  this.getService(hap_1.hap.Service.SecuritySystem)
129
132
  .getCharacteristic(hap_1.hap.Characteristic.SecuritySystemTargetState)
130
133
  .updateValue(this.getTargetState(this.device.data));
@@ -1,11 +1,10 @@
1
1
  import { BaseDeviceAccessory } from './base-device-accessory';
2
2
  import { RingDevice } from '../api';
3
3
  import { RingPlatformConfig } from './config';
4
- import { Logging, PlatformAccessory } from 'homebridge';
4
+ import { PlatformAccessory } from 'homebridge';
5
5
  export declare class SmokeAlarm extends BaseDeviceAccessory {
6
6
  readonly device: RingDevice;
7
7
  readonly accessory: PlatformAccessory;
8
- readonly logger: Logging;
9
8
  readonly config: RingPlatformConfig;
10
- constructor(device: RingDevice, accessory: PlatformAccessory, logger: Logging, config: RingPlatformConfig);
9
+ constructor(device: RingDevice, accessory: PlatformAccessory, config: RingPlatformConfig);
11
10
  }
@@ -4,11 +4,10 @@ exports.SmokeAlarm = void 0;
4
4
  const base_device_accessory_1 = require("./base-device-accessory");
5
5
  const hap_1 = require("./hap");
6
6
  class SmokeAlarm extends base_device_accessory_1.BaseDeviceAccessory {
7
- constructor(device, accessory, logger, config) {
7
+ constructor(device, accessory, config) {
8
8
  super();
9
9
  this.device = device;
10
10
  this.accessory = accessory;
11
- this.logger = logger;
12
11
  this.config = config;
13
12
  const { Characteristic: { SmokeDetected }, Service: { SmokeSensor }, } = hap_1.hap;
14
13
  this.registerCharacteristic({
@@ -1,11 +1,10 @@
1
1
  import { BaseDeviceAccessory } from './base-device-accessory';
2
2
  import { RingDevice } from '../api';
3
3
  import { RingPlatformConfig } from './config';
4
- import { Logging, PlatformAccessory } from 'homebridge';
4
+ import { PlatformAccessory } from 'homebridge';
5
5
  export declare class SmokeCoListener extends BaseDeviceAccessory {
6
6
  readonly device: RingDevice;
7
7
  readonly accessory: PlatformAccessory;
8
- readonly logger: Logging;
9
8
  readonly config: RingPlatformConfig;
10
- constructor(device: RingDevice, accessory: PlatformAccessory, logger: Logging, config: RingPlatformConfig);
9
+ constructor(device: RingDevice, accessory: PlatformAccessory, config: RingPlatformConfig);
11
10
  }
@@ -4,11 +4,10 @@ exports.SmokeCoListener = void 0;
4
4
  const base_device_accessory_1 = require("./base-device-accessory");
5
5
  const hap_1 = require("./hap");
6
6
  class SmokeCoListener extends base_device_accessory_1.BaseDeviceAccessory {
7
- constructor(device, accessory, logger, config) {
7
+ constructor(device, accessory, config) {
8
8
  super();
9
9
  this.device = device;
10
10
  this.accessory = accessory;
11
- this.logger = logger;
12
11
  this.config = config;
13
12
  const { Characteristic: { SmokeDetected, CarbonMonoxideDetected }, Service: { SmokeSensor, CarbonMonoxideSensor }, } = hap_1.hap;
14
13
  this.registerCharacteristic({
@@ -1,12 +1,11 @@
1
1
  import { BaseDeviceAccessory } from './base-device-accessory';
2
2
  import { RingDevice } from '../api';
3
3
  import { RingPlatformConfig } from './config';
4
- import { Logging, PlatformAccessory } from 'homebridge';
4
+ import { PlatformAccessory } from 'homebridge';
5
5
  export declare class Switch extends BaseDeviceAccessory {
6
6
  readonly device: RingDevice;
7
7
  readonly accessory: PlatformAccessory;
8
- readonly logger: Logging;
9
8
  readonly config: RingPlatformConfig;
10
- constructor(device: RingDevice, accessory: PlatformAccessory, logger: Logging, config: RingPlatformConfig);
9
+ constructor(device: RingDevice, accessory: PlatformAccessory, config: RingPlatformConfig);
11
10
  setOnState(on: boolean): Promise<void>;
12
11
  }
@@ -3,12 +3,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Switch = void 0;
4
4
  const base_device_accessory_1 = require("./base-device-accessory");
5
5
  const hap_1 = require("./hap");
6
+ const util_1 = require("../api/util");
6
7
  class Switch extends base_device_accessory_1.BaseDeviceAccessory {
7
- constructor(device, accessory, logger, config) {
8
+ constructor(device, accessory, config) {
8
9
  super();
9
10
  this.device = device;
10
11
  this.accessory = accessory;
11
- this.logger = logger;
12
12
  this.config = config;
13
13
  const { Characteristic, Service } = hap_1.hap;
14
14
  this.registerCharacteristic({
@@ -19,7 +19,7 @@ class Switch extends base_device_accessory_1.BaseDeviceAccessory {
19
19
  });
20
20
  }
21
21
  setOnState(on) {
22
- this.logger.info(`Turning ${this.device.name} ${on ? 'On' : 'Off'}`);
22
+ (0, util_1.logInfo)(`Turning ${this.device.name} ${on ? 'On' : 'Off'}`);
23
23
  return this.device.setInfo({ device: { v1: { on } } });
24
24
  }
25
25
  }
@@ -1,11 +1,10 @@
1
1
  import { BaseDeviceAccessory } from './base-device-accessory';
2
2
  import { RingDevice } from '../api';
3
3
  import { RingPlatformConfig } from './config';
4
- import { Logging, PlatformAccessory } from 'homebridge';
4
+ import { PlatformAccessory } from 'homebridge';
5
5
  export declare class TemperatureSensor extends BaseDeviceAccessory {
6
6
  readonly device: RingDevice;
7
7
  readonly accessory: PlatformAccessory;
8
- readonly logger: Logging;
9
8
  readonly config: RingPlatformConfig;
10
- constructor(device: RingDevice, accessory: PlatformAccessory, logger: Logging, config: RingPlatformConfig);
9
+ constructor(device: RingDevice, accessory: PlatformAccessory, config: RingPlatformConfig);
11
10
  }
@@ -5,11 +5,10 @@ const base_device_accessory_1 = require("./base-device-accessory");
5
5
  const hap_1 = require("./hap");
6
6
  const operators_1 = require("rxjs/operators");
7
7
  class TemperatureSensor extends base_device_accessory_1.BaseDeviceAccessory {
8
- constructor(device, accessory, logger, config) {
8
+ constructor(device, accessory, config) {
9
9
  super();
10
10
  this.device = device;
11
11
  this.accessory = accessory;
12
- this.logger = logger;
13
12
  this.config = config;
14
13
  const { Characteristic: { CurrentTemperature }, Service: { TemperatureSensor: TempSensorService }, } = hap_1.hap;
15
14
  this.registerObservableCharacteristic({
@@ -1,12 +1,11 @@
1
- import { Logging, PlatformAccessory } from 'homebridge';
1
+ import { PlatformAccessory } from 'homebridge';
2
2
  import { RingDevice } from '../api';
3
3
  import { BaseDeviceAccessory } from './base-device-accessory';
4
4
  import { RingPlatformConfig } from './config';
5
5
  export declare class Thermostat extends BaseDeviceAccessory {
6
6
  readonly device: RingDevice;
7
7
  readonly accessory: PlatformAccessory;
8
- readonly logger: Logging;
9
8
  readonly config: RingPlatformConfig;
10
9
  private onTemperature;
11
- constructor(device: RingDevice, accessory: PlatformAccessory, logger: Logging, config: RingPlatformConfig);
10
+ constructor(device: RingDevice, accessory: PlatformAccessory, config: RingPlatformConfig);
12
11
  }
@@ -4,14 +4,14 @@ exports.Thermostat = void 0;
4
4
  const rxjs_1 = require("rxjs");
5
5
  const operators_1 = require("rxjs/operators");
6
6
  const ring_types_1 = require("../api/ring-types");
7
+ const util_1 = require("../api/util");
7
8
  const base_device_accessory_1 = require("./base-device-accessory");
8
9
  const hap_1 = require("./hap");
9
10
  class Thermostat extends base_device_accessory_1.BaseDeviceAccessory {
10
- constructor(device, accessory, logger, config) {
11
+ constructor(device, accessory, config) {
11
12
  super();
12
13
  this.device = device;
13
14
  this.accessory = accessory;
14
- this.logger = logger;
15
15
  this.config = config;
16
16
  const { Characteristic, Service } = hap_1.hap;
17
17
  // Component Device (Temperature Sensor)
@@ -20,9 +20,9 @@ class Thermostat extends base_device_accessory_1.BaseDeviceAccessory {
20
20
  if (!temperatureSensor) {
21
21
  return [];
22
22
  }
23
- this.logger.debug(`Discovered a component temperature sensor for ${this.device.name}`);
23
+ (0, util_1.logDebug)(`Discovered a component temperature sensor for ${this.device.name}`);
24
24
  return temperatureSensor.onData.pipe((0, operators_1.map)(({ celsius: temperature }) => {
25
- this.logger.debug(`Component temperature sensor for ${this.device.name} reported ${temperature} degrees`);
25
+ (0, util_1.logDebug)(`Component temperature sensor for ${this.device.name} reported ${temperature} degrees`);
26
26
  return temperature;
27
27
  }), (0, operators_1.distinctUntilChanged)());
28
28
  }));
@@ -36,7 +36,7 @@ class Thermostat extends base_device_accessory_1.BaseDeviceAccessory {
36
36
  return Characteristic.CurrentHeatingCoolingState.OFF;
37
37
  }
38
38
  if (!temperature || !setPoint) {
39
- this.logger.error(`Could not determine 'CurrentHeatingCoolingState' for ${this.device.name} given temperature: ${temperature}, set point: ${setPoint} and mode: ${mode}. Reporting 'off' state as a fallback.`);
39
+ (0, util_1.logError)(`Could not determine 'CurrentHeatingCoolingState' for ${this.device.name} given temperature: ${temperature}, set point: ${setPoint} and mode: ${mode}. Reporting 'off' state as a fallback.`);
40
40
  return Characteristic.CurrentHeatingCoolingState.OFF;
41
41
  }
42
42
  // Checking with a threshold to avoid floating point weirdness
@@ -90,10 +90,10 @@ class Thermostat extends base_device_accessory_1.BaseDeviceAccessory {
90
90
  }
91
91
  })();
92
92
  if (!mode) {
93
- this.logger.error(`Couldn’t match ${targetHeatingCoolingState} to a recognized mode string.`);
93
+ (0, util_1.logError)(`Couldn’t match ${targetHeatingCoolingState} to a recognized mode string.`);
94
94
  return;
95
95
  }
96
- this.logger.info(`Setting ${this.device.name} mode to ${mode}`);
96
+ (0, util_1.logInfo)(`Setting ${this.device.name} mode to ${mode}`);
97
97
  return this.device.setInfo({ device: { v1: { mode } } });
98
98
  },
99
99
  });
@@ -113,7 +113,7 @@ class Thermostat extends base_device_accessory_1.BaseDeviceAccessory {
113
113
  serviceType: Service.Thermostat,
114
114
  onValue: this.onTemperature.pipe((0, operators_1.map)((temperature) => {
115
115
  if (!temperature) {
116
- this.logger.error(`Could not determine 'CurrentTemperature' for ${this.device.name} given temperature: ${temperature}. Returning 22 degrees celsius as a fallback.`);
116
+ (0, util_1.logError)(`Could not determine 'CurrentTemperature' for ${this.device.name} given temperature: ${temperature}. Returning 22 degrees celsius as a fallback.`);
117
117
  return 22;
118
118
  }
119
119
  // Documentation: https://developers.homebridge.io/#/characteristic/CurrentTemperature
@@ -128,13 +128,13 @@ class Thermostat extends base_device_accessory_1.BaseDeviceAccessory {
128
128
  return setPoint;
129
129
  },
130
130
  setValue: (setPoint) => {
131
- this.logger.info(`Setting ${this.device.name} target temperature to ${setPoint}`);
131
+ (0, util_1.logInfo)(`Setting ${this.device.name} target temperature to ${setPoint}`);
132
132
  // Documentation: https://developers.homebridge.io/#/characteristic/TargetTemperature
133
133
  // 'Characteristic.TargetTemperature' has a valid range from 10 to 38 degrees celsius,
134
134
  // but devices may support a different range. When limits differ, accept the more strict.
135
135
  const setPointMin = Math.max(this.device.data.setPointMin || 10, 10), setPointMax = Math.min(this.device.data.setPointMax || 38, 38);
136
136
  if (setPoint < setPointMin || setPoint > setPointMax) {
137
- this.logger.error(`Ignoring request to set ${this.device.name} target temperature to ${setPoint}. Target temperature must be between ${setPointMin} and ${setPointMax}.`);
137
+ (0, util_1.logError)(`Ignoring request to set ${this.device.name} target temperature to ${setPoint}. Target temperature must be between ${setPointMin} and ${setPointMax}.`);
138
138
  return;
139
139
  }
140
140
  return this.device.setInfo({ device: { v1: { setPoint } } });
@@ -145,7 +145,7 @@ class Thermostat extends base_device_accessory_1.BaseDeviceAccessory {
145
145
  // 'Characteristic.TargetTemperature' has a valid range from 10 to 38 degrees celsius,
146
146
  // but devices may support a different range. When limits differ, accept the more strict.
147
147
  const setPointMin = Math.max(this.device.data.setPointMin || 10, 10), setPointMax = Math.min(this.device.data.setPointMax || 38, 38);
148
- this.logger.debug(`Setting ${this.device.name} target temperature range to ${setPointMin}–${setPointMax}`);
148
+ (0, util_1.logDebug)(`Setting ${this.device.name} target temperature range to ${setPointMin}–${setPointMax}`);
149
149
  this.getService(Service.Thermostat)
150
150
  .getCharacteristic(Characteristic.TargetTemperature)
151
151
  .setProps({
@@ -1,12 +1,11 @@
1
1
  import { BaseDeviceAccessory } from './base-device-accessory';
2
2
  import { RingDevice } from '../api';
3
3
  import { RingPlatformConfig } from './config';
4
- import { Logging, PlatformAccessory } from 'homebridge';
4
+ import { PlatformAccessory } from 'homebridge';
5
5
  export declare class UnknownZWaveSwitchSwitch extends BaseDeviceAccessory {
6
6
  readonly device: RingDevice;
7
7
  readonly accessory: PlatformAccessory;
8
- readonly logger: Logging;
9
8
  readonly config: RingPlatformConfig;
10
- constructor(device: RingDevice, accessory: PlatformAccessory, logger: Logging, config: RingPlatformConfig);
9
+ constructor(device: RingDevice, accessory: PlatformAccessory, config: RingPlatformConfig);
11
10
  setOnState(on: boolean): Promise<void>;
12
11
  }