homebridge-ring 11.5.0 → 11.5.2

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/camera.js CHANGED
@@ -1,103 +1,87 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- Object.defineProperty(exports, "Camera", {
6
- enumerable: true,
7
- get: ()=>Camera
8
- });
9
- const _hap = require("./hap");
10
- const _baseDataAccessory = require("./base-data-accessory");
11
- const _operators = require("rxjs/operators");
12
- const _cameraSource = require("./camera-source");
13
- const _targetValueTimer = require("./target-value-timer");
14
- const _util = require("ring-client-api/util");
15
- class Camera extends _baseDataAccessory.BaseDataAccessory {
16
- async loadSnapshotForEvent(eventDescription, characteristicValue) {
17
- const latestNotification = this.device.latestNotification, imageUuid = latestNotification?.ding.image_uuid;
18
- if (this.device.operatingOnBattery && !imageUuid) {
19
- // battery cameras cannot fetch a new snapshot while recording is in progress
20
- (0, _util.logInfo)(this.device.name + ' ' + eventDescription);
21
- return characteristicValue;
22
- }
23
- (0, _util.logInfo)(this.device.name + ` ${eventDescription}. Loading snapshot before sending event to HomeKit`);
24
- try {
25
- await this.cameraSource.loadSnapshot(imageUuid);
26
- } catch (e) {
27
- (0, _util.logInfo)(this.device.name + ' Failed to load snapshot. Sending event to HomeKit without new snapshot');
28
- }
29
- return characteristicValue;
30
- }
31
- constructor(device, accessory, config){
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Camera = void 0;
4
+ const hap_1 = require("./hap");
5
+ const base_data_accessory_1 = require("./base-data-accessory");
6
+ const operators_1 = require("rxjs/operators");
7
+ const camera_source_1 = require("./camera-source");
8
+ const target_value_timer_1 = require("./target-value-timer");
9
+ const util_1 = require("ring-client-api/util");
10
+ class Camera extends base_data_accessory_1.BaseDataAccessory {
11
+ constructor(device, accessory, config) {
32
12
  super();
33
13
  this.device = device;
34
14
  this.accessory = accessory;
35
15
  this.config = config;
36
- this.cameraSource = new _cameraSource.CameraSource(this.device, this.config.unbridgeCameras);
37
- if (!_hap.hap.CameraController) {
16
+ this.cameraSource = new camera_source_1.CameraSource(this.device, this.config.unbridgeCameras);
17
+ if (!hap_1.hap.CameraController) {
38
18
  const error = 'HAP CameraController not found. Please make sure you are on homebridge version 1.0.0 or newer';
39
- (0, _util.logError)(error);
19
+ (0, util_1.logError)(error);
40
20
  throw new Error(error);
41
21
  }
42
- const { Characteristic , Service } = _hap.hap, { ChargingState , StatusLowBattery } = Characteristic;
22
+ const { Characteristic, Service } = hap_1.hap, { ChargingState, StatusLowBattery } = Characteristic;
43
23
  accessory.configureController(this.cameraSource.controller);
44
24
  this.registerCharacteristic({
45
25
  characteristicType: Characteristic.Mute,
46
26
  serviceType: Service.Microphone,
47
- getValue: ()=>false
27
+ getValue: () => false,
48
28
  });
49
29
  this.registerCharacteristic({
50
30
  characteristicType: Characteristic.Mute,
51
31
  serviceType: Service.Speaker,
52
- getValue: ()=>false
32
+ getValue: () => false,
53
33
  });
54
34
  if (!config.hideCameraMotionSensor) {
55
35
  this.registerObservableCharacteristic({
56
36
  characteristicType: Characteristic.MotionDetected,
57
37
  serviceType: Service.MotionSensor,
58
- onValue: device.onMotionDetected.pipe((0, _operators.switchMap)((motion)=>{
38
+ onValue: device.onMotionDetected.pipe((0, operators_1.switchMap)((motion) => {
59
39
  if (!motion) {
60
40
  return Promise.resolve(false);
61
41
  }
62
42
  return this.loadSnapshotForEvent('Detected Motion', true);
63
- }))
43
+ })),
64
44
  });
65
45
  }
66
46
  if (device.isDoorbot) {
67
47
  this.registerObservableCharacteristic({
68
48
  characteristicType: Characteristic.ProgrammableSwitchEvent,
69
49
  serviceType: Service.Doorbell,
70
- onValue: device.onDoorbellPressed.pipe((0, _operators.throttleTime)(15000), (0, _operators.switchMap)(()=>{
50
+ onValue: device.onDoorbellPressed.pipe((0, operators_1.throttleTime)(15000), (0, operators_1.switchMap)(() => {
71
51
  return this.loadSnapshotForEvent('Doorbell Pressed', Characteristic.ProgrammableSwitchEvent.SINGLE_PRESS);
72
- }))
52
+ })),
73
53
  });
74
54
  if (!config.hideDoorbellSwitch) {
75
55
  this.registerObservableCharacteristic({
76
56
  characteristicType: Characteristic.ProgrammableSwitchEvent,
77
57
  serviceType: Service.StatelessProgrammableSwitch,
78
- onValue: device.onDoorbellPressed.pipe((0, _operators.mapTo)(Characteristic.ProgrammableSwitchEvent.SINGLE_PRESS))
58
+ onValue: device.onDoorbellPressed.pipe((0, operators_1.mapTo)(Characteristic.ProgrammableSwitchEvent.SINGLE_PRESS)),
79
59
  });
80
60
  // Hide long and double press events by setting max value
81
- this.getService(Service.StatelessProgrammableSwitch).getCharacteristic(Characteristic.ProgrammableSwitchEvent).setProps({
82
- maxValue: Characteristic.ProgrammableSwitchEvent.SINGLE_PRESS
61
+ this.getService(Service.StatelessProgrammableSwitch)
62
+ .getCharacteristic(Characteristic.ProgrammableSwitchEvent)
63
+ .setProps({
64
+ maxValue: Characteristic.ProgrammableSwitchEvent.SINGLE_PRESS,
83
65
  });
84
66
  }
85
67
  }
86
68
  if (device.hasLight && !config.hideCameraLight) {
87
- const lightTargetTimer = new _targetValueTimer.TargetValueTimer();
69
+ const lightTargetTimer = new target_value_timer_1.TargetValueTimer();
88
70
  this.registerCharacteristic({
89
71
  characteristicType: Characteristic.On,
90
72
  serviceType: Service.Lightbulb,
91
- getValue: (data)=>{
92
- const value = lightTargetTimer.hasTarget() ? lightTargetTimer.getTarget() : data.led_status === 'on';
73
+ getValue: (data) => {
74
+ const value = lightTargetTimer.hasTarget()
75
+ ? lightTargetTimer.getTarget()
76
+ : data.led_status === 'on';
93
77
  return value;
94
78
  },
95
- setValue: (value)=>{
79
+ setValue: (value) => {
96
80
  // Allow 5 seconds for the light value to update in our status updates from Ring
97
81
  lightTargetTimer.setTarget(value, 5000);
98
82
  return device.setLight(value);
99
83
  },
100
- requestUpdate: ()=>device.requestUpdate()
84
+ requestUpdate: () => device.requestUpdate(),
101
85
  });
102
86
  }
103
87
  if (device.hasSiren && !config.hideCameraSirenSwitch) {
@@ -106,15 +90,15 @@ class Camera extends _baseDataAccessory.BaseDataAccessory {
106
90
  serviceType: Service.Switch,
107
91
  serviceSubType: 'Siren',
108
92
  name: device.name + ' Siren',
109
- getValue: (data)=>{
93
+ getValue: (data) => {
110
94
  return Boolean(data.siren_status && data.siren_status.seconds_remaining);
111
95
  },
112
- setValue: (value)=>device.setSiren(value),
113
- requestUpdate: ()=>device.requestUpdate()
96
+ setValue: (value) => device.setSiren(value),
97
+ requestUpdate: () => device.requestUpdate(),
114
98
  });
115
99
  }
116
100
  if (device.hasInHomeDoorbell && !config.hideInHomeDoorbellSwitch) {
117
- this.device.onInHomeDoorbellStatus.subscribe((data)=>{
101
+ this.device.onInHomeDoorbellStatus.subscribe((data) => {
118
102
  this.inHomeDoorbellStatus = data;
119
103
  });
120
104
  this.registerObservableCharacteristic({
@@ -123,57 +107,80 @@ class Camera extends _baseDataAccessory.BaseDataAccessory {
123
107
  serviceSubType: 'In-Home Doorbell',
124
108
  name: device.name + ' In-Home Doorbell',
125
109
  onValue: device.onInHomeDoorbellStatus,
126
- setValue: (value)=>device.setInHomeDoorbell(value),
127
- requestUpdate: ()=>device.requestUpdate()
110
+ setValue: (value) => device.setInHomeDoorbell(value),
111
+ requestUpdate: () => device.requestUpdate(),
128
112
  });
129
113
  }
130
114
  this.registerCharacteristic({
131
115
  characteristicType: Characteristic.Manufacturer,
132
116
  serviceType: Service.AccessoryInformation,
133
- getValue: (data)=>{
117
+ getValue: (data) => {
134
118
  if ('metadata' in data && 'third_party_manufacturer' in data.metadata) {
135
119
  return data.metadata.third_party_manufacturer;
136
120
  }
137
121
  return 'Ring';
138
- }
122
+ },
139
123
  });
140
124
  this.registerCharacteristic({
141
125
  characteristicType: Characteristic.Model,
142
126
  serviceType: Service.AccessoryInformation,
143
- getValue: (data)=>{
127
+ getValue: (data) => {
144
128
  if ('metadata' in data && 'third_party_model' in data.metadata) {
145
129
  return data.metadata.third_party_model;
146
130
  }
147
131
  return `${device.model} (${data.kind})`;
148
- }
132
+ },
149
133
  });
150
134
  this.registerCharacteristic({
151
135
  characteristicType: Characteristic.SerialNumber,
152
136
  serviceType: Service.AccessoryInformation,
153
- getValue: (data)=>data.device_id
137
+ getValue: (data) => data.device_id,
154
138
  });
155
139
  if (device.hasBattery) {
156
140
  this.registerCharacteristic({
157
141
  characteristicType: Characteristic.StatusLowBattery,
158
142
  serviceType: Service.BatteryService,
159
- getValue: ()=>{
160
- return device.hasLowBattery ? StatusLowBattery.BATTERY_LEVEL_LOW : StatusLowBattery.BATTERY_LEVEL_NORMAL;
161
- }
143
+ getValue: () => {
144
+ return device.hasLowBattery
145
+ ? StatusLowBattery.BATTERY_LEVEL_LOW
146
+ : StatusLowBattery.BATTERY_LEVEL_NORMAL;
147
+ },
162
148
  });
163
149
  this.registerCharacteristic({
164
150
  characteristicType: Characteristic.ChargingState,
165
151
  serviceType: Service.BatteryService,
166
- getValue: ()=>{
167
- return device.isCharging ? ChargingState.CHARGING : ChargingState.NOT_CHARGING;
168
- }
152
+ getValue: () => {
153
+ return device.isCharging
154
+ ? ChargingState.CHARGING
155
+ : ChargingState.NOT_CHARGING;
156
+ },
169
157
  });
170
158
  this.registerObservableCharacteristic({
171
159
  characteristicType: Characteristic.BatteryLevel,
172
160
  serviceType: Service.BatteryService,
173
- onValue: device.onBatteryLevel.pipe((0, _operators.map)((batteryLevel)=>{
161
+ onValue: device.onBatteryLevel.pipe((0, operators_1.map)((batteryLevel) => {
174
162
  return batteryLevel === null ? 100 : batteryLevel;
175
- }))
163
+ })),
176
164
  });
177
165
  }
178
166
  }
167
+ async loadSnapshotForEvent(eventDescription, characteristicValue) {
168
+ const latestNotification = this.device.latestNotification, imageUuid = latestNotification?.ding.image_uuid;
169
+ if (this.device.operatingOnBattery && !imageUuid) {
170
+ // battery cameras cannot fetch a new snapshot while recording is in progress
171
+ (0, util_1.logInfo)(this.device.name + ' ' + eventDescription);
172
+ return characteristicValue;
173
+ }
174
+ (0, util_1.logInfo)(this.device.name +
175
+ ` ${eventDescription}. Loading snapshot before sending event to HomeKit`);
176
+ try {
177
+ await this.cameraSource.loadSnapshot(imageUuid);
178
+ }
179
+ catch (e) {
180
+ (0, util_1.logInfo)(this.device.name +
181
+ ' Failed to load snapshot. Sending event to HomeKit without new snapshot');
182
+ }
183
+ return characteristicValue;
184
+ }
179
185
  }
186
+ exports.Camera = Camera;
package/lib/chime.js CHANGED
@@ -1,101 +1,103 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- Object.defineProperty(exports, "Chime", {
6
- enumerable: true,
7
- get: ()=>Chime
8
- });
9
- const _hap = require("./hap");
10
- const _baseDataAccessory = require("./base-data-accessory");
11
- const _util = require("ring-client-api/util");
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Chime = 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");
12
7
  const minutesFor24Hours = 24 * 60;
13
- class Chime extends _baseDataAccessory.BaseDataAccessory {
14
- constructor(device, accessory, config){
8
+ class Chime extends base_data_accessory_1.BaseDataAccessory {
9
+ constructor(device, accessory, config) {
15
10
  super();
16
11
  this.device = device;
17
12
  this.accessory = accessory;
18
13
  this.config = config;
19
- const { Characteristic , Service } = _hap.hap, snoozeService = this.getService(Service.Switch, device.name + ' Snooze', 'snooze'), playDingService = this.getService(Service.Switch, device.name + ' Play Ding', 'play-ding'), playMotionService = this.getService(Service.Switch, device.name + ' Play Motion', 'play-motion');
14
+ const { Characteristic, Service } = hap_1.hap, snoozeService = this.getService(Service.Switch, device.name + ' Snooze', 'snooze'), playDingService = this.getService(Service.Switch, device.name + ' Play Ding', 'play-ding'), playMotionService = this.getService(Service.Switch, device.name + ' Play Motion', 'play-motion');
20
15
  // Snooze Switch
21
16
  this.registerCharacteristic({
22
17
  characteristicType: Characteristic.On,
23
18
  serviceType: snoozeService,
24
- getValue: (data)=>Boolean(data.do_not_disturb.seconds_left),
25
- setValue: (snooze)=>{
19
+ getValue: (data) => Boolean(data.do_not_disturb.seconds_left),
20
+ setValue: (snooze) => {
26
21
  if (snooze) {
27
- (0, _util.logInfo)(device.name + ' snoozed for 24 hours');
22
+ (0, util_1.logInfo)(device.name + ' snoozed for 24 hours');
28
23
  return device.snooze(minutesFor24Hours);
29
24
  }
30
- (0, _util.logInfo)(device.name + ' snooze cleared');
25
+ (0, util_1.logInfo)(device.name + ' snooze cleared');
31
26
  return device.clearSnooze();
32
27
  },
33
- requestUpdate: ()=>device.requestUpdate()
28
+ requestUpdate: () => device.requestUpdate(),
34
29
  });
35
30
  snoozeService.setPrimaryService(true);
36
31
  // Speaker Service
37
32
  this.registerCharacteristic({
38
33
  characteristicType: Characteristic.Mute,
39
34
  serviceType: Service.Speaker,
40
- getValue: ()=>false
35
+ getValue: () => false,
41
36
  });
42
37
  this.registerLevelCharacteristic({
43
38
  characteristicType: Characteristic.Volume,
44
39
  serviceType: Service.Speaker,
45
- getValue: (data)=>data.settings.volume,
46
- setValue: (volume)=>device.setVolume(volume),
47
- requestUpdate: ()=>device.requestUpdate()
40
+ getValue: (data) => data.settings.volume,
41
+ setValue: (volume) => device.setVolume(volume),
42
+ requestUpdate: () => device.requestUpdate(),
48
43
  });
49
- this.getService(Service.Speaker).getCharacteristic(Characteristic.Volume).setProps({
44
+ this.getService(Service.Speaker)
45
+ .getCharacteristic(Characteristic.Volume)
46
+ .setProps({
50
47
  minValue: 0,
51
- maxValue: 11
48
+ maxValue: 11,
52
49
  });
53
50
  // Play Sound Switches
54
51
  this.registerCharacteristic({
55
52
  characteristicType: Characteristic.On,
56
53
  serviceType: playDingService,
57
- getValue: ()=>false,
58
- setValue: (play)=>{
54
+ getValue: () => false,
55
+ setValue: (play) => {
59
56
  if (!play) {
60
57
  return;
61
58
  }
62
- setTimeout(()=>{
63
- playDingService.getCharacteristic(Characteristic.On).updateValue(false);
59
+ setTimeout(() => {
60
+ playDingService
61
+ .getCharacteristic(Characteristic.On)
62
+ .updateValue(false);
64
63
  }, 1000);
65
64
  return this.device.playSound('ding');
66
65
  },
67
- requestUpdate: ()=>device.requestUpdate()
66
+ requestUpdate: () => device.requestUpdate(),
68
67
  });
69
68
  this.registerCharacteristic({
70
69
  characteristicType: Characteristic.On,
71
70
  serviceType: playMotionService,
72
- getValue: ()=>false,
73
- setValue: (play)=>{
71
+ getValue: () => false,
72
+ setValue: (play) => {
74
73
  if (!play) {
75
74
  return;
76
75
  }
77
- setTimeout(()=>{
78
- playMotionService.getCharacteristic(Characteristic.On).updateValue(false);
76
+ setTimeout(() => {
77
+ playMotionService
78
+ .getCharacteristic(Characteristic.On)
79
+ .updateValue(false);
79
80
  }, 1000);
80
81
  return this.device.playSound('motion');
81
82
  },
82
- requestUpdate: ()=>device.requestUpdate()
83
+ requestUpdate: () => device.requestUpdate(),
83
84
  });
84
85
  // Accessory Information Service
85
86
  this.registerCharacteristic({
86
87
  characteristicType: Characteristic.Manufacturer,
87
88
  serviceType: Service.AccessoryInformation,
88
- getValue: ()=>'Ring'
89
+ getValue: () => 'Ring',
89
90
  });
90
91
  this.registerCharacteristic({
91
92
  characteristicType: Characteristic.Model,
92
93
  serviceType: Service.AccessoryInformation,
93
- getValue: ()=>device.model
94
+ getValue: () => device.model,
94
95
  });
95
96
  this.registerCharacteristic({
96
97
  characteristicType: Characteristic.SerialNumber,
97
98
  serviceType: Service.AccessoryInformation,
98
- getValue: (data)=>data.device_id || 'Unknown'
99
+ getValue: (data) => data.device_id || 'Unknown',
99
100
  });
100
101
  }
101
102
  }
103
+ exports.Chime = Chime;
package/lib/co-alarm.js CHANGED
@@ -1,27 +1,25 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- Object.defineProperty(exports, "CoAlarm", {
6
- enumerable: true,
7
- get: ()=>CoAlarm
8
- });
9
- const _baseDeviceAccessory = require("./base-device-accessory");
10
- const _hap = require("./hap");
11
- class CoAlarm extends _baseDeviceAccessory.BaseDeviceAccessory {
12
- constructor(device, accessory, config){
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CoAlarm = void 0;
4
+ const base_device_accessory_1 = require("./base-device-accessory");
5
+ const hap_1 = require("./hap");
6
+ class CoAlarm extends base_device_accessory_1.BaseDeviceAccessory {
7
+ constructor(device, accessory, config) {
13
8
  super();
14
9
  this.device = device;
15
10
  this.accessory = accessory;
16
11
  this.config = config;
17
- const { Characteristic: { CarbonMonoxideDetected } , Service: { CarbonMonoxideSensor } } = _hap.hap;
12
+ const { Characteristic: { CarbonMonoxideDetected }, Service: { CarbonMonoxideSensor }, } = hap_1.hap;
18
13
  this.registerCharacteristic({
19
14
  characteristicType: CarbonMonoxideDetected,
20
15
  serviceType: CarbonMonoxideSensor,
21
- getValue: (data)=>{
22
- return data.alarmStatus === 'active' ? CarbonMonoxideDetected.CO_LEVELS_ABNORMAL : CarbonMonoxideDetected.CO_LEVELS_NORMAL;
23
- }
16
+ getValue: (data) => {
17
+ return data.alarmStatus === 'active'
18
+ ? CarbonMonoxideDetected.CO_LEVELS_ABNORMAL
19
+ : CarbonMonoxideDetected.CO_LEVELS_NORMAL;
20
+ },
24
21
  });
25
22
  this.initSensorService(CarbonMonoxideSensor);
26
23
  }
27
24
  }
25
+ exports.CoAlarm = CoAlarm;
package/lib/config.js CHANGED
@@ -1,47 +1,36 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- function _export(target, all) {
6
- for(var name in all)Object.defineProperty(target, name, {
7
- enumerable: true,
8
- get: all[name]
9
- });
10
- }
11
- _export(exports, {
12
- updateHomebridgeConfig: ()=>updateHomebridgeConfig,
13
- getSystemId: ()=>getSystemId,
14
- debug: ()=>debug
15
- });
16
- const _fs = require("fs");
17
- const _crypto = require("crypto");
18
- const _path = require("path");
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.debug = exports.getSystemId = exports.updateHomebridgeConfig = void 0;
4
+ const fs_1 = require("fs");
5
+ const crypto_1 = require("crypto");
6
+ const path_1 = require("path");
19
7
  const systemIdFileName = '.ring.json';
20
8
  function updateHomebridgeConfig(homebridge, update) {
21
- const configPath = homebridge.user.configPath(), config = (0, _fs.readFileSync)(configPath).toString(), updatedConfig = update(config);
9
+ const configPath = homebridge.user.configPath(), config = (0, fs_1.readFileSync)(configPath).toString(), updatedConfig = update(config);
22
10
  if (config !== updatedConfig) {
23
- (0, _fs.writeFileSync)(configPath, updatedConfig);
11
+ (0, fs_1.writeFileSync)(configPath, updatedConfig);
24
12
  return true;
25
13
  }
26
14
  return false;
27
15
  }
16
+ exports.updateHomebridgeConfig = updateHomebridgeConfig;
28
17
  function createSystemId() {
29
- return (0, _crypto.createHash)('sha256').update((0, _crypto.randomBytes)(32)).digest('hex');
18
+ return (0, crypto_1.createHash)('sha256').update((0, crypto_1.randomBytes)(32)).digest('hex');
30
19
  }
31
20
  function getSystemId(homebridge) {
32
- const storagePath = homebridge.user.storagePath(), filePath = (0, _path.join)(storagePath, systemIdFileName);
21
+ const storagePath = homebridge.user.storagePath(), filePath = (0, path_1.join)(storagePath, systemIdFileName);
33
22
  try {
34
- const ringContext = JSON.parse((0, _fs.readFileSync)(filePath).toString());
23
+ const ringContext = JSON.parse((0, fs_1.readFileSync)(filePath).toString());
35
24
  if (ringContext.systemId) {
36
25
  return ringContext.systemId;
37
26
  }
38
- } catch (_) {
39
- // expect errors if file doesn't exist or is in a bad format
40
27
  }
41
- const systemId = createSystemId(), ringContext1 = {
42
- systemId
43
- };
44
- (0, _fs.writeFileSync)(filePath, JSON.stringify(ringContext1));
28
+ catch (_) {
29
+ // expect errors if file doesn't exist or is in a bad format
30
+ }
31
+ const systemId = createSystemId(), ringContext = { systemId };
32
+ (0, fs_1.writeFileSync)(filePath, JSON.stringify(ringContext));
45
33
  return systemId;
46
34
  }
47
- const debug = process.env.RING_DEBUG === 'true';
35
+ exports.getSystemId = getSystemId;
36
+ exports.debug = process.env.RING_DEBUG === 'true';
@@ -1,27 +1,25 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- Object.defineProperty(exports, "ContactSensor", {
6
- enumerable: true,
7
- get: ()=>ContactSensor
8
- });
9
- const _baseDeviceAccessory = require("./base-device-accessory");
10
- const _hap = require("./hap");
11
- class ContactSensor extends _baseDeviceAccessory.BaseDeviceAccessory {
12
- constructor(device, accessory, config){
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ContactSensor = void 0;
4
+ const base_device_accessory_1 = require("./base-device-accessory");
5
+ const hap_1 = require("./hap");
6
+ class ContactSensor extends base_device_accessory_1.BaseDeviceAccessory {
7
+ constructor(device, accessory, config) {
13
8
  super();
14
9
  this.device = device;
15
10
  this.accessory = accessory;
16
11
  this.config = config;
17
- const { Characteristic: { ContactSensorState } , Service } = _hap.hap;
12
+ const { Characteristic: { ContactSensorState }, Service, } = hap_1.hap;
18
13
  this.registerCharacteristic({
19
14
  characteristicType: ContactSensorState,
20
15
  serviceType: Service.ContactSensor,
21
- getValue: (data)=>{
22
- return data.faulted ? ContactSensorState.CONTACT_NOT_DETECTED : ContactSensorState.CONTACT_DETECTED;
23
- }
16
+ getValue: (data) => {
17
+ return data.faulted
18
+ ? ContactSensorState.CONTACT_NOT_DETECTED
19
+ : ContactSensorState.CONTACT_DETECTED;
20
+ },
24
21
  });
25
22
  this.initSensorService(Service.ContactSensor);
26
23
  }
27
24
  }
25
+ exports.ContactSensor = ContactSensor;
package/lib/fan.js CHANGED
@@ -1,56 +1,42 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- Object.defineProperty(exports, "Fan", {
6
- enumerable: true,
7
- get: ()=>Fan
8
- });
9
- const _baseDeviceAccessory = require("./base-device-accessory");
10
- const _hap = require("./hap");
11
- const _util = require("ring-client-api/util");
12
- class Fan extends _baseDeviceAccessory.BaseDeviceAccessory {
13
- setOnState(on) {
14
- (0, _util.logInfo)(`Turning ${this.device.name} ${on ? 'On' : 'Off'}`);
15
- return this.device.setInfo({
16
- device: {
17
- v1: {
18
- on
19
- }
20
- }
21
- });
22
- }
23
- setLevelState(level) {
24
- (0, _util.logInfo)(`Setting speed of ${this.device.name} to ${level}%`);
25
- return this.device.setInfo({
26
- device: {
27
- v1: {
28
- level: level / 100
29
- }
30
- }
31
- });
32
- }
33
- constructor(device, accessory, config){
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Fan = void 0;
4
+ const base_device_accessory_1 = require("./base-device-accessory");
5
+ const hap_1 = require("./hap");
6
+ const util_1 = require("ring-client-api/util");
7
+ class Fan extends base_device_accessory_1.BaseDeviceAccessory {
8
+ constructor(device, accessory, config) {
34
9
  super();
35
10
  this.device = device;
36
11
  this.accessory = accessory;
37
12
  this.config = config;
38
- const { Characteristic , Service } = _hap.hap, { data: initialData } = this.device;
13
+ const { Characteristic, Service } = hap_1.hap, { data: initialData } = this.device;
39
14
  this.registerCharacteristic({
40
15
  characteristicType: Characteristic.On,
41
16
  serviceType: Service.Fan,
42
- getValue: (data)=>Boolean(data.on),
43
- setValue: (value)=>this.setOnState(value)
17
+ getValue: (data) => Boolean(data.on),
18
+ setValue: (value) => this.setOnState(value),
44
19
  });
45
20
  if (initialData.level !== undefined) {
46
21
  this.registerLevelCharacteristic({
47
22
  characteristicType: Characteristic.RotationSpeed,
48
23
  serviceType: Service.Fan,
49
- getValue: (data)=>{
24
+ getValue: (data) => {
50
25
  return data.level && !isNaN(data.level) ? 100 * data.level : 0;
51
26
  },
52
- setValue: (value)=>this.setLevelState(value)
27
+ setValue: (value) => this.setLevelState(value),
53
28
  });
54
29
  }
55
30
  }
31
+ setOnState(on) {
32
+ (0, util_1.logInfo)(`Turning ${this.device.name} ${on ? 'On' : 'Off'}`);
33
+ return this.device.setInfo({ device: { v1: { on } } });
34
+ }
35
+ setLevelState(level) {
36
+ (0, util_1.logInfo)(`Setting speed of ${this.device.name} to ${level}%`);
37
+ return this.device.setInfo({
38
+ device: { v1: { level: level / 100 } },
39
+ });
40
+ }
56
41
  }
42
+ exports.Fan = Fan;