homebridge-ring 11.3.1 → 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.
- package/LICENSE +1 -1
- package/README.md +1 -1
- package/config.schema.json +1 -1
- package/lib/base-accessory.js +243 -0
- package/lib/base-data-accessory.js +140 -0
- package/lib/base-device-accessory.js +217 -0
- package/lib/beam.js +153 -0
- package/lib/brightness-only.js +133 -0
- package/lib/camera-source.js +889 -0
- package/lib/camera.js +420 -0
- package/lib/chime.js +197 -0
- package/lib/co-alarm.js +97 -0
- package/lib/config.js +32 -0
- package/lib/contact-sensor.js +97 -0
- package/lib/fan.js +133 -0
- package/lib/flood-freeze-sensor.js +117 -0
- package/lib/freeze-sensor.js +104 -0
- package/lib/hap.js +4 -0
- package/lib/homebridge-ui/public/asset-manifest.json +10 -0
- package/lib/homebridge-ui/public/index.html +1 -0
- package/lib/homebridge-ui/public/static/js/main.e295b510.js +3 -0
- package/lib/{homebridge/homebridge-ui/public/static/js/main.ec51472f.js.LICENSE.txt → homebridge-ui/public/static/js/main.e295b510.js.LICENSE.txt} +0 -0
- package/lib/homebridge-ui/public/static/js/main.e295b510.js.map +1 -0
- package/lib/homebridge-ui/server.js +323 -0
- package/lib/index.js +6 -0
- package/lib/location-mode-switch.js +413 -0
- package/lib/lock.js +139 -0
- package/lib/motion-sensor.js +97 -0
- package/lib/multi-level-switch.js +133 -0
- package/lib/{homebridge/opus-repacketizer.js → opus-repacketizer.js} +60 -21
- package/lib/outlet.js +118 -0
- package/lib/panic-buttons.js +187 -0
- package/lib/ring-platform.js +527 -0
- package/lib/security-panel.js +433 -0
- package/lib/server.js +323 -0
- package/lib/smoke-alarm.js +97 -0
- package/lib/smoke-co-listener.js +105 -0
- package/lib/switch.js +111 -0
- package/lib/target-value-timer.js +34 -0
- package/lib/temperature-sensor.js +98 -0
- package/lib/thermostat.js +319 -0
- package/lib/unknown-zwave-switch.js +111 -0
- package/lib/util.js +10 -0
- package/lib/water-sensor.js +104 -0
- package/package.json +43 -75
- package/CHANGELOG.md +0 -1574
- package/lib/api/api.d.ts +0 -45
- package/lib/api/api.js +0 -198
- package/lib/api/device-data.d.ts +0 -1
- package/lib/api/device-data.js +0 -75
- package/lib/api/ffmpeg.d.ts +0 -2
- package/lib/api/ffmpeg.js +0 -12
- package/lib/api/index.d.ts +0 -6
- package/lib/api/index.js +0 -22
- package/lib/api/location.d.ts +0 -86
- package/lib/api/location.js +0 -374
- package/lib/api/refresh-token.d.ts +0 -2
- package/lib/api/refresh-token.js +0 -36
- package/lib/api/rest-client.d.ts +0 -55
- package/lib/api/rest-client.js +0 -299
- package/lib/api/ring-camera.d.ts +0 -111
- package/lib/api/ring-camera.js +0 -422
- package/lib/api/ring-chime.d.ts +0 -36
- package/lib/api/ring-chime.js +0 -108
- package/lib/api/ring-device.d.ts +0 -26
- package/lib/api/ring-device.js +0 -84
- package/lib/api/ring-types.d.ts +0 -880
- package/lib/api/ring-types.js +0 -186
- package/lib/api/streaming/peer-connection.d.ts +0 -45
- package/lib/api/streaming/peer-connection.js +0 -135
- package/lib/api/streaming/ring-edge-connection.d.ts +0 -65
- package/lib/api/streaming/ring-edge-connection.js +0 -140
- package/lib/api/streaming/simple-webrtc-session.d.ts +0 -11
- package/lib/api/streaming/simple-webrtc-session.js +0 -48
- package/lib/api/streaming/streaming-connection-base.d.ts +0 -34
- package/lib/api/streaming/streaming-connection-base.js +0 -120
- package/lib/api/streaming/streaming-session.d.ts +0 -45
- package/lib/api/streaming/streaming-session.js +0 -180
- package/lib/api/streaming/webrtc-connection.d.ts +0 -23
- package/lib/api/streaming/webrtc-connection.js +0 -49
- package/lib/api/subscribed.d.ts +0 -6
- package/lib/api/subscribed.js +0 -15
- package/lib/api/util.d.ts +0 -21
- package/lib/api/util.js +0 -125
- package/lib/build/github-releaser.d.ts +0 -1
- package/lib/build/github-releaser.js +0 -19
- package/lib/build/package-homebridge.d.ts +0 -1
- package/lib/build/package-homebridge.js +0 -6
- package/lib/homebridge/base-accessory.d.ts +0 -27
- package/lib/homebridge/base-accessory.js +0 -84
- package/lib/homebridge/base-data-accessory.d.ts +0 -26
- package/lib/homebridge/base-data-accessory.js +0 -64
- package/lib/homebridge/base-device-accessory.d.ts +0 -12
- package/lib/homebridge/base-device-accessory.js +0 -113
- package/lib/homebridge/beam.d.ts +0 -14
- package/lib/homebridge/beam.js +0 -64
- package/lib/homebridge/brightness-only.d.ts +0 -11
- package/lib/homebridge/brightness-only.js +0 -53
- package/lib/homebridge/camera-source.d.ts +0 -18
- package/lib/homebridge/camera-source.js +0 -451
- package/lib/homebridge/camera.d.ts +0 -13
- package/lib/homebridge/camera.js +0 -176
- package/lib/homebridge/chime.d.ts +0 -10
- package/lib/homebridge/chime.js +0 -103
- package/lib/homebridge/co-alarm.d.ts +0 -10
- package/lib/homebridge/co-alarm.js +0 -25
- package/lib/homebridge/config.d.ts +0 -22
- package/lib/homebridge/config.js +0 -35
- package/lib/homebridge/contact-sensor.d.ts +0 -10
- package/lib/homebridge/contact-sensor.js +0 -25
- package/lib/homebridge/fan.d.ts +0 -12
- package/lib/homebridge/fan.js +0 -42
- package/lib/homebridge/flood-freeze-sensor.d.ts +0 -10
- package/lib/homebridge/flood-freeze-sensor.js +0 -47
- package/lib/homebridge/freeze-sensor.d.ts +0 -10
- package/lib/homebridge/freeze-sensor.js +0 -32
- package/lib/homebridge/hap.d.ts +0 -3
- package/lib/homebridge/hap.js +0 -7
- package/lib/homebridge/homebridge-ui/public/asset-manifest.json +0 -10
- package/lib/homebridge/homebridge-ui/public/index.html +0 -1
- package/lib/homebridge/homebridge-ui/public/static/js/main.ec51472f.js +0 -3
- package/lib/homebridge/homebridge-ui/public/static/js/main.ec51472f.js.map +0 -1
- package/lib/homebridge/homebridge-ui/server.d.ts +0 -1
- package/lib/homebridge/homebridge-ui/server.js +0 -47
- package/lib/homebridge/index.d.ts +0 -1
- package/lib/homebridge/index.js +0 -9
- package/lib/homebridge/location-mode-switch.d.ts +0 -12
- package/lib/homebridge/location-mode-switch.js +0 -106
- package/lib/homebridge/lock.d.ts +0 -13
- package/lib/homebridge/lock.js +0 -60
- package/lib/homebridge/motion-sensor.d.ts +0 -10
- package/lib/homebridge/motion-sensor.js +0 -21
- package/lib/homebridge/multi-level-switch.d.ts +0 -12
- package/lib/homebridge/multi-level-switch.js +0 -43
- package/lib/homebridge/opus-repacketizer.d.ts +0 -7
- package/lib/homebridge/outlet.d.ts +0 -11
- package/lib/homebridge/outlet.js +0 -31
- package/lib/homebridge/panic-buttons.d.ts +0 -11
- package/lib/homebridge/panic-buttons.js +0 -77
- package/lib/homebridge/ring-platform.d.ts +0 -14
- package/lib/homebridge/ring-platform.js +0 -275
- package/lib/homebridge/security-panel.d.ts +0 -17
- package/lib/homebridge/security-panel.js +0 -137
- package/lib/homebridge/smoke-alarm.d.ts +0 -10
- package/lib/homebridge/smoke-alarm.js +0 -25
- package/lib/homebridge/smoke-co-listener.d.ts +0 -10
- package/lib/homebridge/smoke-co-listener.js +0 -35
- package/lib/homebridge/switch.d.ts +0 -11
- package/lib/homebridge/switch.js +0 -26
- package/lib/homebridge/target-value-timer.d.ts +0 -8
- package/lib/homebridge/target-value-timer.js +0 -26
- package/lib/homebridge/temperature-sensor.d.ts +0 -10
- package/lib/homebridge/temperature-sensor.js +0 -24
- package/lib/homebridge/thermostat.d.ts +0 -11
- package/lib/homebridge/thermostat.js +0 -179
- package/lib/homebridge/unknown-zwave-switch.d.ts +0 -11
- package/lib/homebridge/unknown-zwave-switch.js +0 -26
- package/lib/homebridge/util.d.ts +0 -1
- package/lib/homebridge/util.js +0 -12
- package/lib/homebridge/water-sensor.d.ts +0 -10
- package/lib/homebridge/water-sensor.js +0 -32
- package/lib/jest.config.d.ts +0 -3
- package/lib/jest.config.js +0 -6
- package/lib/ring-auth-cli.d.ts +0 -2
- package/lib/ring-auth-cli.js +0 -3
- package/lib/ring-device-data-cli.d.ts +0 -2
- package/lib/ring-device-data-cli.js +0 -3
- package/lib/test/api/ring-camera.spec.d.ts +0 -1
- package/lib/test/api/ring-camera.spec.js +0 -25
- package/ring-auth-cli.js +0 -2
- package/ring-device-data-cli.js +0 -2
package/LICENSE
CHANGED
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/
|
|
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
|
package/config.schema.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"pluginType": "platform",
|
|
4
4
|
"singular": true,
|
|
5
5
|
"customUi": true,
|
|
6
|
-
"customUiPath": "./lib/homebridge
|
|
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.",
|
|
@@ -0,0 +1,243 @@
|
|
|
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";
|
|
136
|
+
function isServiceInstance(serviceType) {
|
|
137
|
+
return typeof serviceType === "object";
|
|
138
|
+
}
|
|
139
|
+
export var BaseAccessory = /*#__PURE__*/ function() {
|
|
140
|
+
"use strict";
|
|
141
|
+
function BaseAccessory() {
|
|
142
|
+
_classCallCheck(this, BaseAccessory);
|
|
143
|
+
this.servicesInUse = [];
|
|
144
|
+
}
|
|
145
|
+
var _proto = BaseAccessory.prototype;
|
|
146
|
+
_proto.initBase = function initBase() {
|
|
147
|
+
this.pruneUnusedServices();
|
|
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;
|
|
151
|
+
if (isServiceInstance(serviceType)) {
|
|
152
|
+
return serviceType;
|
|
153
|
+
}
|
|
154
|
+
if (debug) {
|
|
155
|
+
name = "TEST " + name;
|
|
156
|
+
}
|
|
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));
|
|
160
|
+
}
|
|
161
|
+
if (!this.servicesInUse.includes(service)) {
|
|
162
|
+
this.servicesInUse.push(service);
|
|
163
|
+
}
|
|
164
|
+
return service;
|
|
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) {
|
|
170
|
+
characteristic.updateValue(value);
|
|
171
|
+
});
|
|
172
|
+
if (requestUpdate) {
|
|
173
|
+
// Only register for GET if an async request should be made to get an updated value
|
|
174
|
+
onCachedValue.pipe(take(1)).subscribe(function() {
|
|
175
|
+
// allow GET once a value is cached
|
|
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
|
+
}());
|
|
218
|
+
});
|
|
219
|
+
}
|
|
220
|
+
if (setValue) {
|
|
221
|
+
characteristic.on(CharacteristicEventTypes.SET, function(newValue, callback) {
|
|
222
|
+
Promise.resolve(setValue(newValue)).catch(function(e) {
|
|
223
|
+
logError(e);
|
|
224
|
+
});
|
|
225
|
+
callback();
|
|
226
|
+
});
|
|
227
|
+
}
|
|
228
|
+
};
|
|
229
|
+
_proto.pruneUnusedServices = function pruneUnusedServices() {
|
|
230
|
+
var _this = this;
|
|
231
|
+
var safeServiceUUIDs = [
|
|
232
|
+
hap.Service.CameraRTPStreamManagement.UUID,
|
|
233
|
+
hap.Service.CameraControl.UUID
|
|
234
|
+
];
|
|
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);
|
|
239
|
+
}
|
|
240
|
+
});
|
|
241
|
+
};
|
|
242
|
+
return BaseAccessory;
|
|
243
|
+
}();
|
|
@@ -0,0 +1,140 @@
|
|
|
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;
|
|
89
|
+
if (requestUpdate) {
|
|
90
|
+
// Only register for GET if an async request should be made to get an updated value
|
|
91
|
+
characteristic.on(CharacteristicEventTypes.GET, function(callback) {
|
|
92
|
+
try {
|
|
93
|
+
var value = getValue(device.data);
|
|
94
|
+
callback(null, value);
|
|
95
|
+
requestUpdate();
|
|
96
|
+
} catch (e) {
|
|
97
|
+
callback(e);
|
|
98
|
+
}
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
if (setValue && setValueDebounceTime) {
|
|
102
|
+
var onValueToSet = new Subject();
|
|
103
|
+
characteristic.on(CharacteristicEventTypes.SET, function(newValue, callback) {
|
|
104
|
+
onValueToSet.next(newValue);
|
|
105
|
+
callback();
|
|
106
|
+
});
|
|
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);
|
|
111
|
+
callback();
|
|
112
|
+
});
|
|
113
|
+
}
|
|
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;
|
|
121
|
+
this.registerCharacteristic({
|
|
122
|
+
characteristicType: characteristicType,
|
|
123
|
+
serviceType: serviceType,
|
|
124
|
+
getValue: function(data) {
|
|
125
|
+
var newLevel = getValue(data);
|
|
126
|
+
if (newLevel === targetLevel) {
|
|
127
|
+
targetLevel = undefined;
|
|
128
|
+
}
|
|
129
|
+
return targetLevel === undefined ? newLevel : targetLevel;
|
|
130
|
+
},
|
|
131
|
+
setValue: function(level) {
|
|
132
|
+
targetLevel = level;
|
|
133
|
+
setValue(level);
|
|
134
|
+
},
|
|
135
|
+
setValueDebounceTime: 500,
|
|
136
|
+
requestUpdate: requestUpdate
|
|
137
|
+
});
|
|
138
|
+
};
|
|
139
|
+
return BaseDataAccessory;
|
|
140
|
+
}(BaseAccessory);
|
|
@@ -0,0 +1,217 @@
|
|
|
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 _get(target, property, receiver) {
|
|
13
|
+
if (typeof Reflect !== "undefined" && Reflect.get) {
|
|
14
|
+
_get = Reflect.get;
|
|
15
|
+
} else {
|
|
16
|
+
_get = function _get(target, property, receiver) {
|
|
17
|
+
var base = _superPropBase(target, property);
|
|
18
|
+
if (!base) return;
|
|
19
|
+
var desc = Object.getOwnPropertyDescriptor(base, property);
|
|
20
|
+
if (desc.get) {
|
|
21
|
+
return desc.get.call(receiver);
|
|
22
|
+
}
|
|
23
|
+
return desc.value;
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
return _get(target, property, receiver || target);
|
|
27
|
+
}
|
|
28
|
+
function _getPrototypeOf(o) {
|
|
29
|
+
_getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
|
|
30
|
+
return o.__proto__ || Object.getPrototypeOf(o);
|
|
31
|
+
};
|
|
32
|
+
return _getPrototypeOf(o);
|
|
33
|
+
}
|
|
34
|
+
function _inherits(subClass, superClass) {
|
|
35
|
+
if (typeof superClass !== "function" && superClass !== null) {
|
|
36
|
+
throw new TypeError("Super expression must either be null or a function");
|
|
37
|
+
}
|
|
38
|
+
subClass.prototype = Object.create(superClass && superClass.prototype, {
|
|
39
|
+
constructor: {
|
|
40
|
+
value: subClass,
|
|
41
|
+
writable: true,
|
|
42
|
+
configurable: true
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
if (superClass) _setPrototypeOf(subClass, superClass);
|
|
46
|
+
}
|
|
47
|
+
function _possibleConstructorReturn(self, call) {
|
|
48
|
+
if (call && (_typeof(call) === "object" || typeof call === "function")) {
|
|
49
|
+
return call;
|
|
50
|
+
}
|
|
51
|
+
return _assertThisInitialized(self);
|
|
52
|
+
}
|
|
53
|
+
function _setPrototypeOf(o, p) {
|
|
54
|
+
_setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
|
|
55
|
+
o.__proto__ = p;
|
|
56
|
+
return o;
|
|
57
|
+
};
|
|
58
|
+
return _setPrototypeOf(o, p);
|
|
59
|
+
}
|
|
60
|
+
function _superPropBase(object, property) {
|
|
61
|
+
while(!Object.prototype.hasOwnProperty.call(object, property)){
|
|
62
|
+
object = _getPrototypeOf(object);
|
|
63
|
+
if (object === null) break;
|
|
64
|
+
}
|
|
65
|
+
return object;
|
|
66
|
+
}
|
|
67
|
+
var _typeof = function(obj) {
|
|
68
|
+
"@swc/helpers - typeof";
|
|
69
|
+
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
|
|
70
|
+
};
|
|
71
|
+
function _isNativeReflectConstruct() {
|
|
72
|
+
if (typeof Reflect === "undefined" || !Reflect.construct) return false;
|
|
73
|
+
if (Reflect.construct.sham) return false;
|
|
74
|
+
if (typeof Proxy === "function") return true;
|
|
75
|
+
try {
|
|
76
|
+
Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {}));
|
|
77
|
+
return true;
|
|
78
|
+
} catch (e) {
|
|
79
|
+
return false;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
function _createSuper(Derived) {
|
|
83
|
+
var hasNativeReflectConstruct = _isNativeReflectConstruct();
|
|
84
|
+
return function _createSuperInternal() {
|
|
85
|
+
var Super = _getPrototypeOf(Derived), result;
|
|
86
|
+
if (hasNativeReflectConstruct) {
|
|
87
|
+
var NewTarget = _getPrototypeOf(this).constructor;
|
|
88
|
+
result = Reflect.construct(Super, arguments, NewTarget);
|
|
89
|
+
} else {
|
|
90
|
+
result = Super.apply(this, arguments);
|
|
91
|
+
}
|
|
92
|
+
return _possibleConstructorReturn(this, result);
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
import { hap } from "./hap";
|
|
96
|
+
import { BaseDataAccessory } from "./base-data-accessory";
|
|
97
|
+
function getBatteryLevel(param) {
|
|
98
|
+
var batteryLevel = param.batteryLevel, batteryStatus = param.batteryStatus;
|
|
99
|
+
if (batteryLevel !== undefined) {
|
|
100
|
+
return batteryLevel;
|
|
101
|
+
} else if (batteryStatus === "full" || batteryStatus === "charged") {
|
|
102
|
+
return 100;
|
|
103
|
+
} else if (batteryStatus === "ok" || batteryStatus === "charging") {
|
|
104
|
+
return 50;
|
|
105
|
+
}
|
|
106
|
+
return 0;
|
|
107
|
+
}
|
|
108
|
+
function getStatusLowBattery(data) {
|
|
109
|
+
var StatusLowBattery = hap.Characteristic.StatusLowBattery, batteryLevel = getBatteryLevel(data);
|
|
110
|
+
return batteryLevel > 20 ? StatusLowBattery.BATTERY_LEVEL_NORMAL : StatusLowBattery.BATTERY_LEVEL_LOW;
|
|
111
|
+
}
|
|
112
|
+
function getBatteryChargingState(param) {
|
|
113
|
+
var batteryStatus = param.batteryStatus, batteryBackup = param.batteryBackup, acStatus = param.acStatus;
|
|
114
|
+
var ChargingState = hap.Characteristic.ChargingState;
|
|
115
|
+
if (batteryStatus === "charging" || batteryStatus === "charged" || batteryBackup === "charged" || batteryBackup === "charging" || acStatus === "ok") {
|
|
116
|
+
return ChargingState.CHARGING;
|
|
117
|
+
}
|
|
118
|
+
if (batteryBackup === "inUse" || acStatus === "error") {
|
|
119
|
+
return ChargingState.NOT_CHARGING;
|
|
120
|
+
}
|
|
121
|
+
return ChargingState.NOT_CHARGEABLE;
|
|
122
|
+
}
|
|
123
|
+
function hasBatteryStatus(param) {
|
|
124
|
+
var batteryStatus = param.batteryStatus;
|
|
125
|
+
return batteryStatus !== "none";
|
|
126
|
+
}
|
|
127
|
+
export var BaseDeviceAccessory = /*#__PURE__*/ function(BaseDataAccessory) {
|
|
128
|
+
"use strict";
|
|
129
|
+
_inherits(BaseDeviceAccessory, BaseDataAccessory);
|
|
130
|
+
var _super = _createSuper(BaseDeviceAccessory);
|
|
131
|
+
function BaseDeviceAccessory() {
|
|
132
|
+
_classCallCheck(this, BaseDeviceAccessory);
|
|
133
|
+
return _super.apply(this, arguments);
|
|
134
|
+
}
|
|
135
|
+
var _proto = BaseDeviceAccessory.prototype;
|
|
136
|
+
_proto.initBase = function initBase() {
|
|
137
|
+
var _this = this, _this_device = _this.device, initialData = _this_device.data, device = _this.device, Characteristic = hap.Characteristic, Service = hap.Service;
|
|
138
|
+
this.registerCharacteristic({
|
|
139
|
+
characteristicType: Characteristic.Manufacturer,
|
|
140
|
+
serviceType: Service.AccessoryInformation,
|
|
141
|
+
getValue: function(data) {
|
|
142
|
+
return data.manufacturerName || "Ring";
|
|
143
|
+
}
|
|
144
|
+
});
|
|
145
|
+
this.registerCharacteristic({
|
|
146
|
+
characteristicType: Characteristic.Model,
|
|
147
|
+
serviceType: Service.AccessoryInformation,
|
|
148
|
+
getValue: function(data) {
|
|
149
|
+
return data.deviceType;
|
|
150
|
+
}
|
|
151
|
+
});
|
|
152
|
+
this.registerCharacteristic({
|
|
153
|
+
characteristicType: Characteristic.SerialNumber,
|
|
154
|
+
serviceType: Service.AccessoryInformation,
|
|
155
|
+
getValue: function(data) {
|
|
156
|
+
return data.serialNumber || "Unknown";
|
|
157
|
+
}
|
|
158
|
+
});
|
|
159
|
+
if ("volume" in initialData && "setVolume" in device) {
|
|
160
|
+
this.registerCharacteristic({
|
|
161
|
+
characteristicType: Characteristic.Mute,
|
|
162
|
+
serviceType: Service.Speaker,
|
|
163
|
+
getValue: function() {
|
|
164
|
+
return false;
|
|
165
|
+
}
|
|
166
|
+
});
|
|
167
|
+
this.registerLevelCharacteristic({
|
|
168
|
+
characteristicType: Characteristic.Volume,
|
|
169
|
+
serviceType: Service.Speaker,
|
|
170
|
+
getValue: function(data) {
|
|
171
|
+
return data.volume ? data.volume * 100 : 0;
|
|
172
|
+
},
|
|
173
|
+
setValue: function(volume) {
|
|
174
|
+
return device.setVolume(volume / 100);
|
|
175
|
+
}
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
if (hasBatteryStatus(initialData)) {
|
|
179
|
+
this.registerCharacteristic({
|
|
180
|
+
characteristicType: Characteristic.BatteryLevel,
|
|
181
|
+
serviceType: Service.BatteryService,
|
|
182
|
+
getValue: getBatteryLevel
|
|
183
|
+
});
|
|
184
|
+
this.registerCharacteristic({
|
|
185
|
+
characteristicType: Characteristic.StatusLowBattery,
|
|
186
|
+
serviceType: Service.BatteryService,
|
|
187
|
+
getValue: getStatusLowBattery
|
|
188
|
+
});
|
|
189
|
+
this.registerCharacteristic({
|
|
190
|
+
characteristicType: Characteristic.ChargingState,
|
|
191
|
+
serviceType: Service.BatteryService,
|
|
192
|
+
getValue: getBatteryChargingState
|
|
193
|
+
});
|
|
194
|
+
}
|
|
195
|
+
_get(_getPrototypeOf(BaseDeviceAccessory.prototype), "initBase", this).call(this);
|
|
196
|
+
};
|
|
197
|
+
_proto.initSensorService = function initSensorService(serviceType) {
|
|
198
|
+
var Characteristic = hap.Characteristic;
|
|
199
|
+
this.registerCharacteristic({
|
|
200
|
+
characteristicType: Characteristic.StatusTampered,
|
|
201
|
+
serviceType: serviceType,
|
|
202
|
+
getValue: function(data) {
|
|
203
|
+
return data.tamperStatus === "ok" ? Characteristic.StatusTampered.NOT_TAMPERED : Characteristic.StatusTampered.TAMPERED;
|
|
204
|
+
}
|
|
205
|
+
});
|
|
206
|
+
if (hasBatteryStatus(this.device.data)) {
|
|
207
|
+
this.registerCharacteristic({
|
|
208
|
+
characteristicType: Characteristic.StatusLowBattery,
|
|
209
|
+
serviceType: serviceType,
|
|
210
|
+
getValue: function(data) {
|
|
211
|
+
return getStatusLowBattery(data);
|
|
212
|
+
}
|
|
213
|
+
});
|
|
214
|
+
}
|
|
215
|
+
};
|
|
216
|
+
return BaseDeviceAccessory;
|
|
217
|
+
}(BaseDataAccessory);
|