homebridge-ring 11.4.0-beta.0 → 11.4.0-beta.1

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 (81) hide show
  1. package/README.md +1 -1
  2. package/config.schema.json +1 -1
  3. package/lib/base-accessory.js +214 -55
  4. package/lib/base-data-accessory.js +113 -37
  5. package/lib/base-device-accessory.js +156 -52
  6. package/lib/beam.js +134 -45
  7. package/lib/brightness-only.js +112 -32
  8. package/lib/camera-source.js +788 -350
  9. package/lib/camera.js +345 -101
  10. package/lib/chime.js +150 -56
  11. package/lib/co-alarm.js +93 -21
  12. package/lib/config.js +18 -22
  13. package/lib/contact-sensor.js +93 -21
  14. package/lib/fan.js +120 -29
  15. package/lib/flood-freeze-sensor.js +108 -38
  16. package/lib/freeze-sensor.js +99 -27
  17. package/lib/hap.js +3 -6
  18. package/{homebridge-ui → lib/homebridge-ui}/public/asset-manifest.json +0 -0
  19. package/{homebridge-ui → lib/homebridge-ui}/public/index.html +0 -0
  20. package/{homebridge-ui → lib/homebridge-ui}/public/static/js/main.e295b510.js +0 -0
  21. package/{homebridge-ui → lib/homebridge-ui}/public/static/js/main.e295b510.js.LICENSE.txt +0 -0
  22. package/{homebridge-ui → lib/homebridge-ui}/public/static/js/main.e295b510.js.map +0 -0
  23. package/lib/homebridge-ui/server.js +313 -37
  24. package/lib/index.js +5 -8
  25. package/lib/location-mode-switch.js +384 -77
  26. package/lib/lock.js +121 -42
  27. package/lib/motion-sensor.js +94 -18
  28. package/lib/multi-level-switch.js +120 -30
  29. package/lib/opus-repacketizer.js +60 -21
  30. package/lib/outlet.js +111 -24
  31. package/lib/panic-buttons.js +160 -50
  32. package/lib/ring-platform.js +493 -240
  33. package/lib/security-panel.js +394 -98
  34. package/lib/server.js +323 -0
  35. package/lib/smoke-alarm.js +93 -21
  36. package/lib/smoke-co-listener.js +98 -28
  37. package/lib/switch.js +107 -22
  38. package/lib/target-value-timer.js +24 -16
  39. package/lib/temperature-sensor.js +93 -19
  40. package/lib/thermostat.js +225 -85
  41. package/lib/unknown-zwave-switch.js +107 -22
  42. package/lib/util.js +8 -10
  43. package/lib/water-sensor.js +99 -27
  44. package/package.json +6 -5
  45. package/homebridge-ui/server.js +0 -47
  46. package/homebridge-ui/server.ts +0 -72
  47. package/lib/base-accessory.d.ts +0 -27
  48. package/lib/base-data-accessory.d.ts +0 -26
  49. package/lib/base-device-accessory.d.ts +0 -12
  50. package/lib/beam.d.ts +0 -14
  51. package/lib/brightness-only.d.ts +0 -11
  52. package/lib/camera-source.d.ts +0 -18
  53. package/lib/camera.d.ts +0 -13
  54. package/lib/chime.d.ts +0 -10
  55. package/lib/co-alarm.d.ts +0 -10
  56. package/lib/config.d.ts +0 -23
  57. package/lib/contact-sensor.d.ts +0 -10
  58. package/lib/fan.d.ts +0 -12
  59. package/lib/flood-freeze-sensor.d.ts +0 -10
  60. package/lib/freeze-sensor.d.ts +0 -10
  61. package/lib/hap.d.ts +0 -3
  62. package/lib/homebridge-ui/server.d.ts +0 -1
  63. package/lib/index.d.ts +0 -1
  64. package/lib/location-mode-switch.d.ts +0 -12
  65. package/lib/lock.d.ts +0 -13
  66. package/lib/motion-sensor.d.ts +0 -10
  67. package/lib/multi-level-switch.d.ts +0 -12
  68. package/lib/opus-repacketizer.d.ts +0 -7
  69. package/lib/outlet.d.ts +0 -11
  70. package/lib/panic-buttons.d.ts +0 -11
  71. package/lib/ring-platform.d.ts +0 -14
  72. package/lib/security-panel.d.ts +0 -17
  73. package/lib/smoke-alarm.d.ts +0 -10
  74. package/lib/smoke-co-listener.d.ts +0 -10
  75. package/lib/switch.d.ts +0 -11
  76. package/lib/target-value-timer.d.ts +0 -8
  77. package/lib/temperature-sensor.d.ts +0 -10
  78. package/lib/thermostat.d.ts +0 -11
  79. package/lib/unknown-zwave-switch.d.ts +0 -11
  80. package/lib/util.d.ts +0 -1
  81. package/lib/water-sensor.d.ts +0 -10
package/README.md CHANGED
@@ -1,5 +1,5 @@
1
1
  <p align="center">
2
- <a href="https://github.com/homebridge/verified/blob/master/verified-plugins.json"><img alt="Homebridge Verified" src="https://raw.githubusercontent.com/dgreif/ring/master/branding/Homebridge_x_Ring.svg?sanitize=true" width="500px"></a>
2
+ <a href="https://github.com/homebridge/verified/blob/master/verified-plugins.json"><img alt="Homebridge Verified" src="https://raw.githubusercontent.com/dgreif/ring/main/packages/homebridge-ring/branding/Homebridge_x_Ring.svg?sanitize=true" width="500px"></a>
3
3
  </p>
4
4
 
5
5
  # homebridge-ring
@@ -3,7 +3,7 @@
3
3
  "pluginType": "platform",
4
4
  "singular": true,
5
5
  "customUi": true,
6
- "customUiPath": "./lib/homebridge/homebridge-ui",
6
+ "customUiPath": "./lib/homebridge-ui",
7
7
  "customUiDevServer": "http://localhost:3000/api/plugins/settings-ui/homebridge-ring",
8
8
  "headerDisplay": "See [the wiki](https://github.com/dgreif/ring/wiki/Refresh-Tokens) for details on generating a refresh token",
9
9
  "accountLinkingHeader": "Please supply your Ring credentials. These will be used to contact the Ring servers and generate a unique access token for your account. Your email and password will be sent directly to Ring and will not be stored anywhere.",
@@ -1,84 +1,243 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.BaseAccessory = void 0;
4
- const hap_1 = require("./hap");
5
- const operators_1 = require("rxjs/operators");
6
- const rxjs_1 = require("rxjs");
7
- const config_1 = require("./config");
8
- const util_1 = require("ring-client-api/util");
1
+ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
2
+ try {
3
+ var info = gen[key](arg);
4
+ var value = info.value;
5
+ } catch (error) {
6
+ reject(error);
7
+ return;
8
+ }
9
+ if (info.done) {
10
+ resolve(value);
11
+ } else {
12
+ Promise.resolve(value).then(_next, _throw);
13
+ }
14
+ }
15
+ function _asyncToGenerator(fn) {
16
+ return function() {
17
+ var self = this, args = arguments;
18
+ return new Promise(function(resolve, reject) {
19
+ var gen = fn.apply(self, args);
20
+ function _next(value) {
21
+ asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
22
+ }
23
+ function _throw(err) {
24
+ asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
25
+ }
26
+ _next(undefined);
27
+ });
28
+ };
29
+ }
30
+ function _classCallCheck(instance, Constructor) {
31
+ if (!(instance instanceof Constructor)) {
32
+ throw new TypeError("Cannot call a class as a function");
33
+ }
34
+ }
35
+ var __generator = this && this.__generator || function(thisArg, body) {
36
+ var f, y, t, g, _ = {
37
+ label: 0,
38
+ sent: function() {
39
+ if (t[0] & 1) throw t[1];
40
+ return t[1];
41
+ },
42
+ trys: [],
43
+ ops: []
44
+ };
45
+ return(g = {
46
+ next: verb(0),
47
+ "throw": verb(1),
48
+ "return": verb(2)
49
+ }, typeof Symbol === "function" && (g[Symbol.iterator] = function() {
50
+ return this;
51
+ }), g);
52
+ function verb(n) {
53
+ return function(v) {
54
+ return step([
55
+ n,
56
+ v
57
+ ]);
58
+ };
59
+ }
60
+ function step(op) {
61
+ if (f) throw new TypeError("Generator is already executing.");
62
+ while(_)try {
63
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
64
+ if (y = 0, t) op = [
65
+ op[0] & 2,
66
+ t.value
67
+ ];
68
+ switch(op[0]){
69
+ case 0:
70
+ case 1:
71
+ t = op;
72
+ break;
73
+ case 4:
74
+ _.label++;
75
+ return {
76
+ value: op[1],
77
+ done: false
78
+ };
79
+ case 5:
80
+ _.label++;
81
+ y = op[1];
82
+ op = [
83
+ 0
84
+ ];
85
+ continue;
86
+ case 7:
87
+ op = _.ops.pop();
88
+ _.trys.pop();
89
+ continue;
90
+ default:
91
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
92
+ _ = 0;
93
+ continue;
94
+ }
95
+ if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
96
+ _.label = op[1];
97
+ break;
98
+ }
99
+ if (op[0] === 6 && _.label < t[1]) {
100
+ _.label = t[1];
101
+ t = op;
102
+ break;
103
+ }
104
+ if (t && _.label < t[2]) {
105
+ _.label = t[2];
106
+ _.ops.push(op);
107
+ break;
108
+ }
109
+ if (t[2]) _.ops.pop();
110
+ _.trys.pop();
111
+ continue;
112
+ }
113
+ op = body.call(thisArg, _);
114
+ } catch (e) {
115
+ op = [
116
+ 6,
117
+ e
118
+ ];
119
+ y = 0;
120
+ } finally{
121
+ f = t = 0;
122
+ }
123
+ if (op[0] & 5) throw op[1];
124
+ return {
125
+ value: op[0] ? op[1] : void 0,
126
+ done: true
127
+ };
128
+ }
129
+ };
130
+ import { hap } from "./hap";
131
+ import { shareReplay, take } from "rxjs/operators";
132
+ import { firstValueFrom } from "rxjs";
133
+ import { debug } from "./config";
134
+ import { CharacteristicEventTypes } from "homebridge";
135
+ import { logError, logInfo } from "ring-client-api/util";
9
136
  function isServiceInstance(serviceType) {
10
- return typeof serviceType === 'object';
137
+ return typeof serviceType === "object";
11
138
  }
12
- class BaseAccessory {
13
- constructor() {
139
+ export var BaseAccessory = /*#__PURE__*/ function() {
140
+ "use strict";
141
+ function BaseAccessory() {
142
+ _classCallCheck(this, BaseAccessory);
14
143
  this.servicesInUse = [];
15
144
  }
16
- initBase() {
145
+ var _proto = BaseAccessory.prototype;
146
+ _proto.initBase = function initBase() {
17
147
  this.pruneUnusedServices();
18
- }
19
- getService(serviceType, name = this.device.name, subType) {
148
+ };
149
+ _proto.getService = function getService(serviceType) {
150
+ var name = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : this.device.name, subType = arguments.length > 2 ? arguments[2] : void 0;
20
151
  if (isServiceInstance(serviceType)) {
21
152
  return serviceType;
22
153
  }
23
- if (config_1.debug) {
24
- name = 'TEST ' + name;
154
+ if (debug) {
155
+ name = "TEST " + name;
25
156
  }
26
- const existingService = subType
27
- ? this.accessory.getServiceById(serviceType, subType)
28
- : this.accessory.getService(serviceType), service = existingService || this.accessory.addService(serviceType, name, subType);
29
- if (config_1.debug &&
30
- existingService &&
31
- existingService.displayName &&
32
- name !== existingService.displayName) {
33
- throw new Error(`Overlapping services for device ${this.device.name} - ${name} != ${existingService.displayName} - ${serviceType}`);
157
+ var existingService = subType ? this.accessory.getServiceById(serviceType, subType) : this.accessory.getService(serviceType), service = existingService || this.accessory.addService(serviceType, name, subType);
158
+ if (debug && existingService && existingService.displayName && name !== existingService.displayName) {
159
+ throw new Error("Overlapping services for device ".concat(this.device.name, " - ").concat(name, " != ").concat(existingService.displayName, " - ").concat(serviceType));
34
160
  }
35
161
  if (!this.servicesInUse.includes(service)) {
36
162
  this.servicesInUse.push(service);
37
163
  }
38
164
  return service;
39
- }
40
- registerObservableCharacteristic({ characteristicType, serviceType, serviceSubType, onValue, setValue, name, requestUpdate, }) {
41
- const service = this.getService(serviceType, name, serviceSubType), characteristic = service.getCharacteristic(characteristicType), onCachedValue = onValue.pipe((0, operators_1.shareReplay)(1));
42
- onCachedValue.subscribe((value) => {
165
+ };
166
+ _proto.registerObservableCharacteristic = function registerObservableCharacteristic(param) {
167
+ var characteristicType = param.characteristicType, serviceType = param.serviceType, serviceSubType = param.serviceSubType, onValue = param.onValue, setValue = param.setValue, name = param.name, requestUpdate = param.requestUpdate;
168
+ var service = this.getService(serviceType, name, serviceSubType), characteristic = service.getCharacteristic(characteristicType), onCachedValue = onValue.pipe(shareReplay(1));
169
+ onCachedValue.subscribe(function(value) {
43
170
  characteristic.updateValue(value);
44
171
  });
45
172
  if (requestUpdate) {
46
173
  // Only register for GET if an async request should be made to get an updated value
47
- onCachedValue.pipe((0, operators_1.take)(1)).subscribe(() => {
174
+ onCachedValue.pipe(take(1)).subscribe(function() {
48
175
  // allow GET once a value is cached
49
- characteristic.on("get" /* CharacteristicEventTypes.GET */, async (callback) => {
50
- try {
51
- const value = await (0, rxjs_1.firstValueFrom)(onCachedValue);
52
- callback(null, value);
53
- requestUpdate();
54
- }
55
- catch (e) {
56
- callback(e);
57
- }
58
- });
176
+ characteristic.on(CharacteristicEventTypes.GET, function() {
177
+ var _ref = _asyncToGenerator(function(callback) {
178
+ var value, e;
179
+ return __generator(this, function(_state) {
180
+ switch(_state.label){
181
+ case 0:
182
+ _state.trys.push([
183
+ 0,
184
+ 2,
185
+ ,
186
+ 3
187
+ ]);
188
+ return [
189
+ 4,
190
+ firstValueFrom(onCachedValue)
191
+ ];
192
+ case 1:
193
+ value = _state.sent();
194
+ callback(null, value);
195
+ requestUpdate();
196
+ return [
197
+ 3,
198
+ 3
199
+ ];
200
+ case 2:
201
+ e = _state.sent();
202
+ callback(e);
203
+ return [
204
+ 3,
205
+ 3
206
+ ];
207
+ case 3:
208
+ return [
209
+ 2
210
+ ];
211
+ }
212
+ });
213
+ });
214
+ return function(callback) {
215
+ return _ref.apply(this, arguments);
216
+ };
217
+ }());
59
218
  });
60
219
  }
61
220
  if (setValue) {
62
- characteristic.on("set" /* CharacteristicEventTypes.SET */, (newValue, callback) => {
63
- Promise.resolve(setValue(newValue)).catch((e) => {
64
- (0, util_1.logError)(e);
221
+ characteristic.on(CharacteristicEventTypes.SET, function(newValue, callback) {
222
+ Promise.resolve(setValue(newValue)).catch(function(e) {
223
+ logError(e);
65
224
  });
66
225
  callback();
67
226
  });
68
227
  }
69
- }
70
- pruneUnusedServices() {
71
- const safeServiceUUIDs = [
72
- hap_1.hap.Service.CameraRTPStreamManagement.UUID,
73
- hap_1.hap.Service.CameraControl.UUID,
228
+ };
229
+ _proto.pruneUnusedServices = function pruneUnusedServices() {
230
+ var _this = this;
231
+ var safeServiceUUIDs = [
232
+ hap.Service.CameraRTPStreamManagement.UUID,
233
+ hap.Service.CameraControl.UUID
74
234
  ];
75
- this.accessory.services.forEach((service) => {
76
- if (!this.servicesInUse.includes(service) &&
77
- !safeServiceUUIDs.includes(service.UUID)) {
78
- (0, util_1.logInfo)('Pruning unused service', service.UUID, service.displayName || service.name, 'from', this.device.name);
79
- this.accessory.removeService(service);
235
+ this.accessory.services.forEach(function(service) {
236
+ if (!_this.servicesInUse.includes(service) && !safeServiceUUIDs.includes(service.UUID)) {
237
+ logInfo("Pruning unused service", service.UUID, service.displayName || service.name, "from", _this.device.name);
238
+ _this.accessory.removeService(service);
80
239
  }
81
240
  });
82
- }
83
- }
84
- exports.BaseAccessory = BaseAccessory;
241
+ };
242
+ return BaseAccessory;
243
+ }();
@@ -1,64 +1,140 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.BaseDataAccessory = void 0;
4
- const base_accessory_1 = require("./base-accessory");
5
- const rxjs_1 = require("rxjs");
6
- const operators_1 = require("rxjs/operators");
7
- const util_1 = require("ring-client-api/util");
8
- class BaseDataAccessory extends base_accessory_1.BaseAccessory {
9
- registerCharacteristic({ characteristicType, serviceType, getValue, setValue, setValueDebounceTime = 0, name, requestUpdate, serviceSubType, }) {
10
- const service = this.getService(serviceType, name, serviceSubType), characteristic = service.getCharacteristic(characteristicType), { device } = this;
1
+ function _assertThisInitialized(self) {
2
+ if (self === void 0) {
3
+ throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
4
+ }
5
+ return self;
6
+ }
7
+ function _classCallCheck(instance, Constructor) {
8
+ if (!(instance instanceof Constructor)) {
9
+ throw new TypeError("Cannot call a class as a function");
10
+ }
11
+ }
12
+ function _getPrototypeOf(o) {
13
+ _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
14
+ return o.__proto__ || Object.getPrototypeOf(o);
15
+ };
16
+ return _getPrototypeOf(o);
17
+ }
18
+ function _inherits(subClass, superClass) {
19
+ if (typeof superClass !== "function" && superClass !== null) {
20
+ throw new TypeError("Super expression must either be null or a function");
21
+ }
22
+ subClass.prototype = Object.create(superClass && superClass.prototype, {
23
+ constructor: {
24
+ value: subClass,
25
+ writable: true,
26
+ configurable: true
27
+ }
28
+ });
29
+ if (superClass) _setPrototypeOf(subClass, superClass);
30
+ }
31
+ function _possibleConstructorReturn(self, call) {
32
+ if (call && (_typeof(call) === "object" || typeof call === "function")) {
33
+ return call;
34
+ }
35
+ return _assertThisInitialized(self);
36
+ }
37
+ function _setPrototypeOf(o, p) {
38
+ _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
39
+ o.__proto__ = p;
40
+ return o;
41
+ };
42
+ return _setPrototypeOf(o, p);
43
+ }
44
+ var _typeof = function(obj) {
45
+ "@swc/helpers - typeof";
46
+ return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
47
+ };
48
+ function _isNativeReflectConstruct() {
49
+ if (typeof Reflect === "undefined" || !Reflect.construct) return false;
50
+ if (Reflect.construct.sham) return false;
51
+ if (typeof Proxy === "function") return true;
52
+ try {
53
+ Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {}));
54
+ return true;
55
+ } catch (e) {
56
+ return false;
57
+ }
58
+ }
59
+ function _createSuper(Derived) {
60
+ var hasNativeReflectConstruct = _isNativeReflectConstruct();
61
+ return function _createSuperInternal() {
62
+ var Super = _getPrototypeOf(Derived), result;
63
+ if (hasNativeReflectConstruct) {
64
+ var NewTarget = _getPrototypeOf(this).constructor;
65
+ result = Reflect.construct(Super, arguments, NewTarget);
66
+ } else {
67
+ result = Super.apply(this, arguments);
68
+ }
69
+ return _possibleConstructorReturn(this, result);
70
+ };
71
+ }
72
+ import { BaseAccessory } from "./base-accessory";
73
+ import { Subject } from "rxjs";
74
+ import { debounceTime, distinctUntilChanged, map } from "rxjs/operators";
75
+ import { CharacteristicEventTypes } from "homebridge";
76
+ import { logError } from "ring-client-api/util";
77
+ export var BaseDataAccessory = /*#__PURE__*/ function(BaseAccessory) {
78
+ "use strict";
79
+ _inherits(BaseDataAccessory, BaseAccessory);
80
+ var _super = _createSuper(BaseDataAccessory);
81
+ function BaseDataAccessory() {
82
+ _classCallCheck(this, BaseDataAccessory);
83
+ return _super.apply(this, arguments);
84
+ }
85
+ var _proto = BaseDataAccessory.prototype;
86
+ _proto.registerCharacteristic = function registerCharacteristic(param) {
87
+ var characteristicType = param.characteristicType, serviceType = param.serviceType, getValue = param.getValue, setValue = param.setValue, _param_setValueDebounceTime = param.setValueDebounceTime, setValueDebounceTime = _param_setValueDebounceTime === void 0 ? 0 : _param_setValueDebounceTime, name = param.name, requestUpdate = param.requestUpdate, serviceSubType = param.serviceSubType;
88
+ var service = this.getService(serviceType, name, serviceSubType), characteristic = service.getCharacteristic(characteristicType), device = this.device;
11
89
  if (requestUpdate) {
12
90
  // Only register for GET if an async request should be made to get an updated value
13
- characteristic.on("get" /* CharacteristicEventTypes.GET */, (callback) => {
91
+ characteristic.on(CharacteristicEventTypes.GET, function(callback) {
14
92
  try {
15
- const value = getValue(device.data);
93
+ var value = getValue(device.data);
16
94
  callback(null, value);
17
95
  requestUpdate();
18
- }
19
- catch (e) {
96
+ } catch (e) {
20
97
  callback(e);
21
98
  }
22
99
  });
23
100
  }
24
101
  if (setValue && setValueDebounceTime) {
25
- const onValueToSet = new rxjs_1.Subject();
26
- characteristic.on("set" /* CharacteristicEventTypes.SET */, (newValue, callback) => {
102
+ var onValueToSet = new Subject();
103
+ characteristic.on(CharacteristicEventTypes.SET, function(newValue, callback) {
27
104
  onValueToSet.next(newValue);
28
105
  callback();
29
106
  });
30
- onValueToSet.pipe((0, operators_1.debounceTime)(setValueDebounceTime)).subscribe(setValue);
31
- }
32
- else if (setValue) {
33
- characteristic.on("set" /* CharacteristicEventTypes.SET */, (newValue, callback) => {
34
- Promise.resolve(setValue(newValue)).catch(util_1.logError);
107
+ onValueToSet.pipe(debounceTime(setValueDebounceTime)).subscribe(setValue);
108
+ } else if (setValue) {
109
+ characteristic.on(CharacteristicEventTypes.SET, function(newValue, callback) {
110
+ Promise.resolve(setValue(newValue)).catch(logError);
35
111
  callback();
36
112
  });
37
113
  }
38
- ;
39
- this.device.onData
40
- .pipe((0, operators_1.map)(getValue), (0, operators_1.distinctUntilChanged)())
41
- .subscribe((value) => characteristic.updateValue(value));
42
- }
43
- registerLevelCharacteristic({ characteristicType, serviceType, getValue, setValue, requestUpdate, }) {
44
- let targetLevel;
114
+ this.device.onData.pipe(map(getValue), distinctUntilChanged()).subscribe(function(value) {
115
+ return characteristic.updateValue(value);
116
+ });
117
+ };
118
+ _proto.registerLevelCharacteristic = function registerLevelCharacteristic(param) {
119
+ var characteristicType = param.characteristicType, serviceType = param.serviceType, getValue = param.getValue, setValue = param.setValue, requestUpdate = param.requestUpdate;
120
+ var targetLevel;
45
121
  this.registerCharacteristic({
46
- characteristicType,
47
- serviceType,
48
- getValue: (data) => {
49
- const newLevel = getValue(data);
122
+ characteristicType: characteristicType,
123
+ serviceType: serviceType,
124
+ getValue: function(data) {
125
+ var newLevel = getValue(data);
50
126
  if (newLevel === targetLevel) {
51
127
  targetLevel = undefined;
52
128
  }
53
129
  return targetLevel === undefined ? newLevel : targetLevel;
54
130
  },
55
- setValue: (level) => {
131
+ setValue: function(level) {
56
132
  targetLevel = level;
57
133
  setValue(level);
58
134
  },
59
135
  setValueDebounceTime: 500,
60
- requestUpdate,
136
+ requestUpdate: requestUpdate
61
137
  });
62
- }
63
- }
64
- exports.BaseDataAccessory = BaseDataAccessory;
138
+ };
139
+ return BaseDataAccessory;
140
+ }(BaseAccessory);