homebridge-ring 11.4.0-beta.1 → 11.4.0-beta.3
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/base-accessory.js +55 -216
- package/lib/base-data-accessory.js +35 -111
- package/lib/base-device-accessory.js +41 -151
- package/lib/beam.js +56 -135
- package/lib/brightness-only.js +38 -111
- package/lib/camera-source.js +354 -758
- package/lib/camera.js +82 -333
- package/lib/chime.js +51 -147
- package/lib/co-alarm.js +22 -92
- package/lib/config.js +30 -15
- package/lib/contact-sensor.js +21 -91
- package/lib/fan.js +43 -120
- package/lib/flood-freeze-sensor.js +30 -104
- package/lib/freeze-sensor.js +25 -97
- package/lib/hap.js +16 -2
- package/lib/homebridge-ui/server.js +48 -313
- package/lib/index.js +13 -5
- package/lib/location-mode-switch.js +76 -380
- package/lib/lock.js +42 -120
- package/lib/motion-sensor.js +22 -94
- package/lib/multi-level-switch.js +44 -120
- package/lib/opus-repacketizer.js +29 -111
- package/lib/outlet.js +33 -110
- package/lib/panic-buttons.js +64 -170
- package/lib/ring-platform.js +227 -491
- package/lib/security-panel.js +93 -399
- package/lib/server.js +48 -313
- package/lib/smoke-alarm.js +22 -92
- package/lib/smoke-co-listener.js +26 -96
- package/lib/switch.js +30 -105
- package/lib/target-value-timer.js +20 -24
- package/lib/temperature-sensor.js +23 -93
- package/lib/thermostat.js +74 -197
- package/lib/unknown-zwave-switch.js +29 -104
- package/lib/util.js +14 -8
- package/lib/water-sensor.js +25 -97
- package/package.json +2 -2
package/lib/base-accessory.js
CHANGED
|
@@ -1,243 +1,82 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
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";
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "BaseAccessory", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: ()=>BaseAccessory
|
|
8
|
+
});
|
|
9
|
+
const _hap = require("./hap");
|
|
10
|
+
const _operators = require("rxjs/operators");
|
|
11
|
+
const _rxjs = require("rxjs");
|
|
12
|
+
const _config = require("./config");
|
|
13
|
+
const _homebridge = require("homebridge");
|
|
14
|
+
const _util = require("ring-client-api/util");
|
|
136
15
|
function isServiceInstance(serviceType) {
|
|
137
|
-
return typeof serviceType ===
|
|
16
|
+
return typeof serviceType === 'object';
|
|
138
17
|
}
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
function BaseAccessory() {
|
|
142
|
-
_classCallCheck(this, BaseAccessory);
|
|
143
|
-
this.servicesInUse = [];
|
|
144
|
-
}
|
|
145
|
-
var _proto = BaseAccessory.prototype;
|
|
146
|
-
_proto.initBase = function initBase() {
|
|
18
|
+
class BaseAccessory {
|
|
19
|
+
initBase() {
|
|
147
20
|
this.pruneUnusedServices();
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
var name = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : this.device.name, subType = arguments.length > 2 ? arguments[2] : void 0;
|
|
21
|
+
}
|
|
22
|
+
getService(serviceType, name = this.device.name, subType) {
|
|
151
23
|
if (isServiceInstance(serviceType)) {
|
|
152
24
|
return serviceType;
|
|
153
25
|
}
|
|
154
|
-
if (debug) {
|
|
155
|
-
name =
|
|
26
|
+
if (_config.debug) {
|
|
27
|
+
name = 'TEST ' + name;
|
|
156
28
|
}
|
|
157
|
-
|
|
158
|
-
if (debug && existingService && existingService.displayName && name !== existingService.displayName) {
|
|
159
|
-
throw new Error(
|
|
29
|
+
const existingService = subType ? this.accessory.getServiceById(serviceType, subType) : this.accessory.getService(serviceType), service = existingService || this.accessory.addService(serviceType, name, subType);
|
|
30
|
+
if (_config.debug && existingService && existingService.displayName && name !== existingService.displayName) {
|
|
31
|
+
throw new Error(`Overlapping services for device ${this.device.name} - ${name} != ${existingService.displayName} - ${serviceType}`);
|
|
160
32
|
}
|
|
161
33
|
if (!this.servicesInUse.includes(service)) {
|
|
162
34
|
this.servicesInUse.push(service);
|
|
163
35
|
}
|
|
164
36
|
return service;
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
onCachedValue.subscribe(function(value) {
|
|
37
|
+
}
|
|
38
|
+
registerObservableCharacteristic({ characteristicType , serviceType , serviceSubType , onValue , setValue , name , requestUpdate }) {
|
|
39
|
+
const service = this.getService(serviceType, name, serviceSubType), characteristic = service.getCharacteristic(characteristicType), onCachedValue = onValue.pipe((0, _operators.shareReplay)(1));
|
|
40
|
+
onCachedValue.subscribe((value)=>{
|
|
170
41
|
characteristic.updateValue(value);
|
|
171
42
|
});
|
|
172
43
|
if (requestUpdate) {
|
|
173
44
|
// Only register for GET if an async request should be made to get an updated value
|
|
174
|
-
onCachedValue.pipe(take(1)).subscribe(
|
|
45
|
+
onCachedValue.pipe((0, _operators.take)(1)).subscribe(()=>{
|
|
175
46
|
// allow GET once a value is cached
|
|
176
|
-
characteristic.on(CharacteristicEventTypes.GET,
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
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
|
-
}());
|
|
47
|
+
characteristic.on(_homebridge.CharacteristicEventTypes.GET, async (callback)=>{
|
|
48
|
+
try {
|
|
49
|
+
const value = await (0, _rxjs.firstValueFrom)(onCachedValue);
|
|
50
|
+
callback(null, value);
|
|
51
|
+
requestUpdate();
|
|
52
|
+
} catch (e) {
|
|
53
|
+
callback(e);
|
|
54
|
+
}
|
|
55
|
+
});
|
|
218
56
|
});
|
|
219
57
|
}
|
|
220
58
|
if (setValue) {
|
|
221
|
-
characteristic.on(CharacteristicEventTypes.SET,
|
|
222
|
-
Promise.resolve(setValue(newValue)).catch(
|
|
223
|
-
logError(e);
|
|
59
|
+
characteristic.on(_homebridge.CharacteristicEventTypes.SET, (newValue, callback)=>{
|
|
60
|
+
Promise.resolve(setValue(newValue)).catch((e)=>{
|
|
61
|
+
(0, _util.logError)(e);
|
|
224
62
|
});
|
|
225
63
|
callback();
|
|
226
64
|
});
|
|
227
65
|
}
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
hap.Service.
|
|
233
|
-
hap.Service.CameraControl.UUID
|
|
66
|
+
}
|
|
67
|
+
pruneUnusedServices() {
|
|
68
|
+
const safeServiceUUIDs = [
|
|
69
|
+
_hap.hap.Service.CameraRTPStreamManagement.UUID,
|
|
70
|
+
_hap.hap.Service.CameraControl.UUID
|
|
234
71
|
];
|
|
235
|
-
this.accessory.services.forEach(
|
|
236
|
-
if (!
|
|
237
|
-
logInfo(
|
|
238
|
-
|
|
72
|
+
this.accessory.services.forEach((service)=>{
|
|
73
|
+
if (!this.servicesInUse.includes(service) && !safeServiceUUIDs.includes(service.UUID)) {
|
|
74
|
+
(0, _util.logInfo)('Pruning unused service', service.UUID, service.displayName || service.name, 'from', this.device.name);
|
|
75
|
+
this.accessory.removeService(service);
|
|
239
76
|
}
|
|
240
77
|
});
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
|
|
78
|
+
}
|
|
79
|
+
constructor(){
|
|
80
|
+
this.servicesInUse = [];
|
|
81
|
+
}
|
|
82
|
+
}
|
|
@@ -1,96 +1,24 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
}
|
|
16
|
-
|
|
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;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "BaseDataAccessory", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: ()=>BaseDataAccessory
|
|
8
|
+
});
|
|
9
|
+
const _baseAccessory = require("./base-accessory");
|
|
10
|
+
const _rxjs = require("rxjs");
|
|
11
|
+
const _operators = require("rxjs/operators");
|
|
12
|
+
const _homebridge = require("homebridge");
|
|
13
|
+
const _util = require("ring-client-api/util");
|
|
14
|
+
class BaseDataAccessory extends _baseAccessory.BaseAccessory {
|
|
15
|
+
registerCharacteristic({ characteristicType , serviceType , getValue , setValue , setValueDebounceTime =0 , name , requestUpdate , serviceSubType }) {
|
|
16
|
+
const service = this.getService(serviceType, name, serviceSubType), characteristic = service.getCharacteristic(characteristicType), { device } = this;
|
|
89
17
|
if (requestUpdate) {
|
|
90
18
|
// Only register for GET if an async request should be made to get an updated value
|
|
91
|
-
characteristic.on(CharacteristicEventTypes.GET,
|
|
19
|
+
characteristic.on(_homebridge.CharacteristicEventTypes.GET, (callback)=>{
|
|
92
20
|
try {
|
|
93
|
-
|
|
21
|
+
const value = getValue(device.data);
|
|
94
22
|
callback(null, value);
|
|
95
23
|
requestUpdate();
|
|
96
24
|
} catch (e) {
|
|
@@ -99,42 +27,38 @@ export var BaseDataAccessory = /*#__PURE__*/ function(BaseAccessory) {
|
|
|
99
27
|
});
|
|
100
28
|
}
|
|
101
29
|
if (setValue && setValueDebounceTime) {
|
|
102
|
-
|
|
103
|
-
characteristic.on(CharacteristicEventTypes.SET,
|
|
30
|
+
const onValueToSet = new _rxjs.Subject();
|
|
31
|
+
characteristic.on(_homebridge.CharacteristicEventTypes.SET, (newValue, callback)=>{
|
|
104
32
|
onValueToSet.next(newValue);
|
|
105
33
|
callback();
|
|
106
34
|
});
|
|
107
|
-
onValueToSet.pipe(debounceTime(setValueDebounceTime)).subscribe(setValue);
|
|
35
|
+
onValueToSet.pipe((0, _operators.debounceTime)(setValueDebounceTime)).subscribe(setValue);
|
|
108
36
|
} else if (setValue) {
|
|
109
|
-
characteristic.on(CharacteristicEventTypes.SET,
|
|
110
|
-
Promise.resolve(setValue(newValue)).catch(logError);
|
|
37
|
+
characteristic.on(_homebridge.CharacteristicEventTypes.SET, (newValue, callback)=>{
|
|
38
|
+
Promise.resolve(setValue(newValue)).catch(_util.logError);
|
|
111
39
|
callback();
|
|
112
40
|
});
|
|
113
41
|
}
|
|
114
|
-
this.device.onData.pipe(map(getValue), distinctUntilChanged()).subscribe(
|
|
115
|
-
|
|
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;
|
|
42
|
+
this.device.onData.pipe((0, _operators.map)(getValue), (0, _operators.distinctUntilChanged)()).subscribe((value)=>characteristic.updateValue(value));
|
|
43
|
+
}
|
|
44
|
+
registerLevelCharacteristic({ characteristicType , serviceType , getValue , setValue , requestUpdate }) {
|
|
45
|
+
let targetLevel;
|
|
121
46
|
this.registerCharacteristic({
|
|
122
|
-
characteristicType
|
|
123
|
-
serviceType
|
|
124
|
-
getValue:
|
|
125
|
-
|
|
47
|
+
characteristicType,
|
|
48
|
+
serviceType,
|
|
49
|
+
getValue: (data)=>{
|
|
50
|
+
const newLevel = getValue(data);
|
|
126
51
|
if (newLevel === targetLevel) {
|
|
127
52
|
targetLevel = undefined;
|
|
128
53
|
}
|
|
129
54
|
return targetLevel === undefined ? newLevel : targetLevel;
|
|
130
55
|
},
|
|
131
|
-
setValue:
|
|
56
|
+
setValue: (level)=>{
|
|
132
57
|
targetLevel = level;
|
|
133
58
|
setValue(level);
|
|
134
59
|
},
|
|
135
60
|
setValueDebounceTime: 500,
|
|
136
|
-
requestUpdate
|
|
61
|
+
requestUpdate
|
|
137
62
|
});
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
}(BaseAccessory);
|
|
63
|
+
}
|
|
64
|
+
}
|