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.
@@ -1,43 +1,47 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- Object.defineProperty(exports, "FloodFreezeSensor", {
6
- enumerable: true,
7
- get: ()=>FloodFreezeSensor
8
- });
9
- const _baseDeviceAccessory = require("./base-device-accessory");
10
- const _hap = require("./hap");
11
- const _operators = require("rxjs/operators");
12
- const _util = require("ring-client-api/util");
13
- class FloodFreezeSensor extends _baseDeviceAccessory.BaseDeviceAccessory {
14
- constructor(device, accessory, config){
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FloodFreezeSensor = void 0;
4
+ const base_device_accessory_1 = require("./base-device-accessory");
5
+ const hap_1 = require("./hap");
6
+ const operators_1 = require("rxjs/operators");
7
+ const util_1 = require("ring-client-api/util");
8
+ class FloodFreezeSensor extends base_device_accessory_1.BaseDeviceAccessory {
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: { LeakDetected , OccupancyDetected } , Service: { LeakSensor , OccupancySensor } } = _hap.hap, leakService = this.getService(LeakSensor, `${device.name} Flood Sensor`), freezeService = this.getService(OccupancySensor, `${device.name} Freeze Sensor`), onFloodDetected = device.onData.pipe((0, _operators.map)((data)=>{
20
- return data.flood && data.flood.faulted ? LeakDetected.LEAK_DETECTED : LeakDetected.LEAK_NOT_DETECTED;
21
- }), (0, _operators.distinctUntilChanged)()), onFreezeDetected = device.onData.pipe((0, _operators.map)((data)=>{
22
- return data.freeze && data.freeze.faulted ? OccupancyDetected.OCCUPANCY_DETECTED : OccupancyDetected.OCCUPANCY_NOT_DETECTED;
23
- }), (0, _operators.distinctUntilChanged)());
14
+ const { Characteristic: { LeakDetected, OccupancyDetected }, Service: { LeakSensor, OccupancySensor }, } = hap_1.hap, leakService = this.getService(LeakSensor, `${device.name} Flood Sensor`), freezeService = this.getService(OccupancySensor, `${device.name} Freeze Sensor`), onFloodDetected = device.onData.pipe((0, operators_1.map)((data) => {
15
+ return data.flood && data.flood.faulted
16
+ ? LeakDetected.LEAK_DETECTED
17
+ : LeakDetected.LEAK_NOT_DETECTED;
18
+ }), (0, operators_1.distinctUntilChanged)()), onFreezeDetected = device.onData.pipe((0, operators_1.map)((data) => {
19
+ return data.freeze && data.freeze.faulted
20
+ ? OccupancyDetected.OCCUPANCY_DETECTED
21
+ : OccupancyDetected.OCCUPANCY_NOT_DETECTED;
22
+ }), (0, operators_1.distinctUntilChanged)());
24
23
  this.initSensorService(leakService);
25
24
  this.registerObservableCharacteristic({
26
25
  characteristicType: LeakDetected,
27
26
  serviceType: leakService,
28
- onValue: onFloodDetected
27
+ onValue: onFloodDetected,
29
28
  });
30
- onFloodDetected.pipe((0, _operators.filter)((faulted)=>Boolean(faulted))).subscribe(()=>{
31
- (0, _util.logInfo)(device.name + ' Detected Flooding');
29
+ onFloodDetected
30
+ .pipe((0, operators_1.filter)((faulted) => Boolean(faulted)))
31
+ .subscribe(() => {
32
+ (0, util_1.logInfo)(device.name + ' Detected Flooding');
32
33
  });
33
34
  this.initSensorService(freezeService);
34
35
  this.registerObservableCharacteristic({
35
36
  characteristicType: OccupancyDetected,
36
37
  serviceType: freezeService,
37
- onValue: onFreezeDetected
38
+ onValue: onFreezeDetected,
38
39
  });
39
- onFreezeDetected.pipe((0, _operators.filter)((faulted)=>Boolean(faulted))).subscribe(()=>{
40
- (0, _util.logInfo)(device.name + ' Detected Freezing');
40
+ onFreezeDetected
41
+ .pipe((0, operators_1.filter)((faulted) => Boolean(faulted)))
42
+ .subscribe(() => {
43
+ (0, util_1.logInfo)(device.name + ' Detected Freezing');
41
44
  });
42
45
  }
43
46
  }
47
+ exports.FloodFreezeSensor = FloodFreezeSensor;
@@ -1,32 +1,32 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- Object.defineProperty(exports, "FreezeSensor", {
6
- enumerable: true,
7
- get: ()=>FreezeSensor
8
- });
9
- const _baseDeviceAccessory = require("./base-device-accessory");
10
- const _hap = require("./hap");
11
- const _operators = require("rxjs/operators");
12
- const _util = require("ring-client-api/util");
13
- class FreezeSensor extends _baseDeviceAccessory.BaseDeviceAccessory {
14
- constructor(device, accessory, config){
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FreezeSensor = void 0;
4
+ const base_device_accessory_1 = require("./base-device-accessory");
5
+ const hap_1 = require("./hap");
6
+ const operators_1 = require("rxjs/operators");
7
+ const util_1 = require("ring-client-api/util");
8
+ class FreezeSensor extends base_device_accessory_1.BaseDeviceAccessory {
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: { OccupancyDetected } , Service: { OccupancySensor } } = _hap.hap, onFreezeDetected = device.onData.pipe((0, _operators.map)((data)=>{
20
- return data.faulted ? OccupancyDetected.OCCUPANCY_DETECTED : OccupancyDetected.OCCUPANCY_NOT_DETECTED;
21
- }), (0, _operators.distinctUntilChanged)());
14
+ const { Characteristic: { OccupancyDetected }, Service: { OccupancySensor }, } = hap_1.hap, onFreezeDetected = device.onData.pipe((0, operators_1.map)((data) => {
15
+ return data.faulted
16
+ ? OccupancyDetected.OCCUPANCY_DETECTED
17
+ : OccupancyDetected.OCCUPANCY_NOT_DETECTED;
18
+ }), (0, operators_1.distinctUntilChanged)());
22
19
  this.initSensorService(OccupancySensor);
23
20
  this.registerObservableCharacteristic({
24
21
  characteristicType: OccupancyDetected,
25
22
  serviceType: OccupancySensor,
26
- onValue: onFreezeDetected
23
+ onValue: onFreezeDetected,
27
24
  });
28
- onFreezeDetected.pipe((0, _operators.filter)((faulted)=>Boolean(faulted))).subscribe(()=>{
29
- (0, _util.logInfo)(device.name + ' Detected Freezing');
25
+ onFreezeDetected
26
+ .pipe((0, operators_1.filter)((faulted) => Boolean(faulted)))
27
+ .subscribe(() => {
28
+ (0, util_1.logInfo)(device.name + ' Detected Freezing');
30
29
  });
31
30
  }
32
31
  }
32
+ exports.FreezeSensor = FreezeSensor;
package/lib/hap.js CHANGED
@@ -1,18 +1,7 @@
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
- hap: ()=>hap,
13
- setHap: ()=>setHap
14
- });
15
- let hap;
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.setHap = exports.hap = void 0;
16
4
  function setHap(hapInstance) {
17
- hap = hapInstance;
5
+ exports.hap = hapInstance;
18
6
  }
7
+ exports.setHap = setHap;
@@ -1,50 +1,39 @@
1
- /* eslint-disable no-console */ "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- const _pluginUiUtils = require("@homebridge/plugin-ui-utils");
6
- const _restClient = require("ring-client-api/rest-client");
7
- class PluginUiServer extends _pluginUiUtils.HomebridgePluginUiServer {
8
- constructor(){
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ /* eslint-disable no-console */
4
+ const plugin_ui_utils_1 = require("@homebridge/plugin-ui-utils");
5
+ const rest_client_1 = require("ring-client-api/rest-client");
6
+ class PluginUiServer extends plugin_ui_utils_1.HomebridgePluginUiServer {
7
+ constructor() {
9
8
  super();
10
- this.generateCode = async ({ email , password })=>{
9
+ this.generateCode = async ({ email, password }) => {
11
10
  console.log(`Logging in with email '${email}'`);
12
- this.restClient = new _restClient.RingRestClient({
13
- email,
14
- password
15
- });
11
+ this.restClient = new rest_client_1.RingRestClient({ email, password });
16
12
  try {
17
- const { refresh_token } = await this.restClient.getCurrentAuth();
13
+ const { refresh_token } = await this.restClient.getCurrentAuth();
18
14
  // If we get here, 2fa was not required. I'm not sure this is possible anymore, but it's here just in case
19
- return {
20
- refreshToken: refresh_token
21
- };
22
- } catch (e) {
15
+ return { refreshToken: refresh_token };
16
+ }
17
+ catch (e) {
23
18
  if (this.restClient.promptFor2fa) {
24
19
  console.log(this.restClient.promptFor2fa);
25
- return {
26
- codePrompt: this.restClient.promptFor2fa
27
- };
20
+ return { codePrompt: this.restClient.promptFor2fa };
28
21
  }
29
22
  console.error(e);
30
- throw new _pluginUiUtils.RequestError(e.message, e);
23
+ throw new plugin_ui_utils_1.RequestError(e.message, e);
31
24
  }
32
25
  };
33
- this.generateToken = async ({ email , password , code })=>{
26
+ this.generateToken = async ({ email, password, code }) => {
34
27
  // use the existing restClient to avoid sending a token again
35
- this.restClient = this.restClient || new _restClient.RingRestClient({
36
- email,
37
- password
38
- });
28
+ this.restClient = this.restClient || new rest_client_1.RingRestClient({ email, password });
39
29
  console.log(`Getting token for ${email} with code ${code}`);
40
30
  try {
41
31
  const authResponse = await this.restClient.getAuth(code);
42
- return {
43
- refreshToken: authResponse.refresh_token
44
- };
45
- } catch (e) {
32
+ return { refreshToken: authResponse.refresh_token };
33
+ }
34
+ catch (e) {
46
35
  console.error('Incorrect 2fa Code');
47
- throw new _pluginUiUtils.RequestError('Please check the code and try again', e);
36
+ throw new plugin_ui_utils_1.RequestError('Please check the code and try again', e);
48
37
  }
49
38
  };
50
39
  this.onRequest('/send-code', this.generateCode);
package/lib/index.js CHANGED
@@ -1,14 +1,9 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- Object.defineProperty(exports, "default", {
6
- enumerable: true,
7
- get: ()=>_default
8
- });
9
- const _ringPlatform = require("./ring-platform");
10
- const _hap = require("./hap");
11
- function _default(homebridge) {
12
- (0, _hap.setHap)(homebridge.hap);
13
- homebridge.registerPlatform(_ringPlatform.pluginName, _ringPlatform.platformName, _ringPlatform.RingPlatform, true);
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const ring_platform_1 = require("./ring-platform");
4
+ const hap_1 = require("./hap");
5
+ function default_1(homebridge) {
6
+ (0, hap_1.setHap)(homebridge.hap);
7
+ homebridge.registerPlatform(ring_platform_1.pluginName, ring_platform_1.platformName, ring_platform_1.RingPlatform, true);
14
8
  }
9
+ exports.default = default_1;
@@ -1,20 +1,14 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- Object.defineProperty(exports, "LocationModeSwitch", {
6
- enumerable: true,
7
- get: ()=>LocationModeSwitch
8
- });
9
- const _operators = require("rxjs/operators");
10
- const _hap = require("./hap");
11
- const _util = require("ring-client-api/util");
12
- const _baseAccessory = require("./base-accessory");
13
- const _rxjs = require("rxjs");
14
- const _homebridge = require("homebridge");
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.LocationModeSwitch = void 0;
4
+ const operators_1 = require("rxjs/operators");
5
+ const hap_1 = require("./hap");
6
+ const util_1 = require("ring-client-api/util");
7
+ const base_accessory_1 = require("./base-accessory");
8
+ const rxjs_1 = require("rxjs");
15
9
  function getStateFromMode(mode) {
16
- const { Characteristic: { SecuritySystemCurrentState: State } } = _hap.hap;
17
- switch(mode){
10
+ const { Characteristic: { SecuritySystemCurrentState: State }, } = hap_1.hap;
11
+ switch (mode) {
18
12
  case 'away':
19
13
  return State.AWAY_ARM;
20
14
  case 'home':
@@ -25,18 +19,17 @@ function getStateFromMode(mode) {
25
19
  return State.DISARMED;
26
20
  }
27
21
  }
28
- class LocationModeSwitch extends _baseAccessory.BaseAccessory {
29
- constructor(location, accessory, config){
22
+ class LocationModeSwitch extends base_accessory_1.BaseAccessory {
23
+ constructor(location, accessory, config) {
30
24
  super();
31
25
  this.location = location;
32
26
  this.accessory = accessory;
33
27
  this.config = config;
34
- this.device = this.location // for use in BaseAccessory
35
- ;
36
- const { Characteristic , Service: { SecuritySystem , AccessoryInformation } } = _hap.hap, accessoryName = location.name + ' Mode', service = this.getService(SecuritySystem, accessoryName), currentState = service.getCharacteristic(Characteristic.SecuritySystemCurrentState), targetState = service.getCharacteristic(Characteristic.SecuritySystemTargetState), getCurrentMode = ()=>{
37
- return (0, _rxjs.firstValueFrom)(location.onLocationMode);
38
- }, getCurrentState = async ()=>getStateFromMode(await getCurrentMode());
39
- location.onLocationMode.pipe((0, _operators.distinctUntilChanged)()).subscribe((mode)=>{
28
+ this.device = this.location; // for use in BaseAccessory
29
+ const { Characteristic, Service: { SecuritySystem, AccessoryInformation }, } = hap_1.hap, accessoryName = location.name + ' Mode', service = this.getService(SecuritySystem, accessoryName), currentState = service.getCharacteristic(Characteristic.SecuritySystemCurrentState), targetState = service.getCharacteristic(Characteristic.SecuritySystemTargetState), getCurrentMode = () => {
30
+ return (0, rxjs_1.firstValueFrom)(location.onLocationMode);
31
+ }, getCurrentState = async () => getStateFromMode(await getCurrentMode());
32
+ location.onLocationMode.pipe((0, operators_1.distinctUntilChanged)()).subscribe((mode) => {
40
33
  const state = getStateFromMode(mode);
41
34
  if (state === this.targetState) {
42
35
  this.targetState = undefined;
@@ -46,10 +39,10 @@ class LocationModeSwitch extends _baseAccessory.BaseAccessory {
46
39
  }
47
40
  currentState.updateValue(state);
48
41
  });
49
- currentState.on(_homebridge.CharacteristicEventTypes.GET, async (callback)=>{
50
- location.getLocationMode().catch((e)=>{
51
- (0, _util.logError)('Failed to retrieve location mode for ' + location.name);
52
- (0, _util.logError)(e);
42
+ currentState.on("get" /* CharacteristicEventTypes.GET */, async (callback) => {
43
+ location.getLocationMode().catch((e) => {
44
+ (0, util_1.logError)('Failed to retrieve location mode for ' + location.name);
45
+ (0, util_1.logError)(e);
53
46
  });
54
47
  const state = await getCurrentState();
55
48
  if (state === this.targetState) {
@@ -57,53 +50,57 @@ class LocationModeSwitch extends _baseAccessory.BaseAccessory {
57
50
  }
58
51
  callback(null, state);
59
52
  });
60
- targetState.on(_homebridge.CharacteristicEventTypes.GET, async (callback)=>{
61
- callback(null, this.targetState !== undefined ? this.targetState : await getCurrentState());
53
+ targetState.on("get" /* CharacteristicEventTypes.GET */, async (callback) => {
54
+ callback(null, this.targetState !== undefined
55
+ ? this.targetState
56
+ : await getCurrentState());
62
57
  });
63
- targetState.on(_homebridge.CharacteristicEventTypes.SET, async (state, callback)=>{
64
- const { Characteristic: { SecuritySystemTargetState: State } } = _hap.hap;
58
+ targetState.on("set" /* CharacteristicEventTypes.SET */, async (state, callback) => {
59
+ const { Characteristic: { SecuritySystemTargetState: State }, } = hap_1.hap;
65
60
  callback();
66
61
  if (state === State.NIGHT_ARM) {
67
62
  state = State.STAY_ARM;
68
63
  // Ring doesn't have night mode, so switch over to stay mode
69
- setTimeout(()=>targetState.updateValue(state), 100);
64
+ setTimeout(() => targetState.updateValue(state), 100);
70
65
  }
71
- if (state === await getCurrentState()) {
66
+ if (state === (await getCurrentState())) {
72
67
  this.targetState = undefined;
73
68
  return;
74
69
  }
75
70
  this.targetState = state;
76
71
  if (state === State.AWAY_ARM) {
77
- (0, _util.logInfo)(`Setting ${this.location.name} Mode to away`);
72
+ (0, util_1.logInfo)(`Setting ${this.location.name} Mode to away`);
78
73
  return this.location.setLocationMode('away');
79
- } else if (state === State.DISARM) {
80
- (0, _util.logInfo)(`Setting ${this.location.name} Mode to disarmed`);
74
+ }
75
+ else if (state === State.DISARM) {
76
+ (0, util_1.logInfo)(`Setting ${this.location.name} Mode to disarmed`);
81
77
  return this.location.setLocationMode('disarmed');
82
78
  }
83
- (0, _util.logInfo)(`Setting ${this.location.name} Mode to home`);
79
+ (0, util_1.logInfo)(`Setting ${this.location.name} Mode to home`);
84
80
  return this.location.setLocationMode('home');
85
81
  });
86
82
  targetState.setProps({
87
83
  validValues: [
88
84
  Characteristic.SecuritySystemTargetState.AWAY_ARM,
89
85
  Characteristic.SecuritySystemTargetState.STAY_ARM,
90
- Characteristic.SecuritySystemTargetState.DISARM
91
- ]
86
+ Characteristic.SecuritySystemTargetState.DISARM,
87
+ ],
92
88
  });
93
89
  this.registerObservableCharacteristic({
94
90
  characteristicType: Characteristic.Manufacturer,
95
91
  serviceType: AccessoryInformation,
96
- onValue: (0, _rxjs.of)('Ring')
92
+ onValue: (0, rxjs_1.of)('Ring'),
97
93
  });
98
94
  this.registerObservableCharacteristic({
99
95
  characteristicType: Characteristic.Model,
100
96
  serviceType: AccessoryInformation,
101
- onValue: (0, _rxjs.of)('Location Mode')
97
+ onValue: (0, rxjs_1.of)('Location Mode'),
102
98
  });
103
99
  this.registerObservableCharacteristic({
104
100
  characteristicType: Characteristic.SerialNumber,
105
101
  serviceType: AccessoryInformation,
106
- onValue: (0, _rxjs.of)('N/A')
102
+ onValue: (0, rxjs_1.of)('N/A'),
107
103
  });
108
104
  }
109
105
  }
106
+ exports.LocationModeSwitch = LocationModeSwitch;
package/lib/lock.js CHANGED
@@ -1,17 +1,12 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- Object.defineProperty(exports, "Lock", {
6
- enumerable: true,
7
- get: ()=>Lock
8
- });
9
- const _baseDeviceAccessory = require("./base-device-accessory");
10
- const _operators = require("rxjs/operators");
11
- const _hap = require("./hap");
12
- function getCurrentState({ locked }) {
13
- const { Characteristic: { LockCurrentState: State } } = _hap.hap;
14
- switch(locked){
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Lock = void 0;
4
+ const base_device_accessory_1 = require("./base-device-accessory");
5
+ const operators_1 = require("rxjs/operators");
6
+ const hap_1 = require("./hap");
7
+ function getCurrentState({ locked }) {
8
+ const { Characteristic: { LockCurrentState: State }, } = hap_1.hap;
9
+ switch (locked) {
15
10
  case 'unlocked':
16
11
  return State.UNSECURED;
17
12
  case 'locked':
@@ -22,40 +17,44 @@ function getCurrentState({ locked }) {
22
17
  return State.UNKNOWN;
23
18
  }
24
19
  }
25
- class Lock extends _baseDeviceAccessory.BaseDeviceAccessory {
26
- setTargetState(state) {
27
- const { Characteristic: { LockTargetState: State } } = _hap.hap, command = state === State.SECURED ? 'lock' : 'unlock';
28
- this.targetState = state === getCurrentState(this.device.data) ? undefined : state;
29
- return this.device.sendCommand(`lock.${command}`);
30
- }
31
- getTargetState(data) {
32
- return this.targetState || getCurrentState(data);
33
- }
34
- constructor(device, accessory, config){
20
+ class Lock extends base_device_accessory_1.BaseDeviceAccessory {
21
+ constructor(device, accessory, config) {
35
22
  super();
36
23
  this.device = device;
37
24
  this.accessory = accessory;
38
25
  this.config = config;
39
- const { Characteristic , Service } = _hap.hap;
40
- this.device.onData.pipe((0, _operators.distinctUntilChanged)((a, b)=>a.locked === b.locked)).subscribe((data)=>{
26
+ const { Characteristic, Service } = hap_1.hap;
27
+ this.device.onData
28
+ .pipe((0, operators_1.distinctUntilChanged)((a, b) => a.locked === b.locked))
29
+ .subscribe((data) => {
41
30
  this.targetState = this.getTargetState(data);
42
31
  });
43
32
  this.registerCharacteristic({
44
33
  characteristicType: Characteristic.LockCurrentState,
45
34
  serviceType: Service.LockMechanism,
46
- getValue: (data)=>{
35
+ getValue: (data) => {
47
36
  const state = getCurrentState(data);
48
37
  if (state === this.targetState) {
49
38
  this.targetState = undefined;
50
39
  }
51
40
  return state;
52
- }
41
+ },
53
42
  });
54
43
  this.registerCharacteristic({
55
44
  characteristicType: Characteristic.LockTargetState,
56
45
  serviceType: Service.LockMechanism,
57
- getValue: (data)=>this.getTargetState(data),
58
- setValue: (value)=>this.setTargetState(value)
46
+ getValue: (data) => this.getTargetState(data),
47
+ setValue: (value) => this.setTargetState(value),
59
48
  });
60
49
  }
50
+ setTargetState(state) {
51
+ const { Characteristic: { LockTargetState: State }, } = hap_1.hap, command = state === State.SECURED ? 'lock' : 'unlock';
52
+ this.targetState =
53
+ state === getCurrentState(this.device.data) ? undefined : state;
54
+ return this.device.sendCommand(`lock.${command}`);
55
+ }
56
+ getTargetState(data) {
57
+ return this.targetState || getCurrentState(data);
58
+ }
61
59
  }
60
+ exports.Lock = Lock;
@@ -1,25 +1,21 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- Object.defineProperty(exports, "MotionSensor", {
6
- enumerable: true,
7
- get: ()=>MotionSensor
8
- });
9
- const _baseDeviceAccessory = require("./base-device-accessory");
10
- const _hap = require("./hap");
11
- class MotionSensor extends _baseDeviceAccessory.BaseDeviceAccessory {
12
- constructor(device, accessory, config){
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.MotionSensor = void 0;
4
+ const base_device_accessory_1 = require("./base-device-accessory");
5
+ const hap_1 = require("./hap");
6
+ class MotionSensor 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 { Service } = _hap.hap;
12
+ const { Service } = hap_1.hap;
18
13
  this.registerCharacteristic({
19
- characteristicType: _hap.hap.Characteristic.MotionDetected,
14
+ characteristicType: hap_1.hap.Characteristic.MotionDetected,
20
15
  serviceType: Service.MotionSensor,
21
- getValue: (data)=>data.faulted
16
+ getValue: (data) => data.faulted,
22
17
  });
23
18
  this.initSensorService(Service.MotionSensor);
24
19
  }
25
20
  }
21
+ exports.MotionSensor = MotionSensor;
@@ -1,57 +1,43 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- Object.defineProperty(exports, "MultiLevelSwitch", {
6
- enumerable: true,
7
- get: ()=>MultiLevelSwitch
8
- });
9
- const _baseDeviceAccessory = require("./base-device-accessory");
10
- const _hap = require("./hap");
11
- const _util = require("ring-client-api/util");
12
- class MultiLevelSwitch 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 brightness 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.MultiLevelSwitch = 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 MultiLevelSwitch 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.Lightbulb,
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.Brightness,
48
23
  serviceType: Service.Lightbulb,
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
- // SOMEDAY: Hue/Sat/Color Temp
30
+ // SOMEDAY: Hue/Sat/Color Temp
31
+ }
32
+ setOnState(on) {
33
+ (0, util_1.logInfo)(`Turning ${this.device.name} ${on ? 'On' : 'Off'}`);
34
+ return this.device.setInfo({ device: { v1: { on } } });
35
+ }
36
+ setLevelState(level) {
37
+ (0, util_1.logInfo)(`Setting brightness of ${this.device.name} to ${level}%`);
38
+ return this.device.setInfo({
39
+ device: { v1: { level: level / 100 } },
40
+ });
56
41
  }
57
42
  }
43
+ exports.MultiLevelSwitch = MultiLevelSwitch;