homebridge-ring 11.5.0 → 11.5.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/base-accessory.js +36 -34
- package/lib/base-data-accessory.js +28 -28
- package/lib/base-device-accessory.js +40 -34
- package/lib/beam.js +38 -48
- package/lib/brightness-only.js +23 -30
- package/lib/camera-source.js +229 -263
- package/lib/camera.js +74 -67
- package/lib/chime.js +39 -37
- package/lib/co-alarm.js +13 -15
- package/lib/config.js +18 -29
- package/lib/contact-sensor.js +13 -15
- package/lib/fan.js +23 -37
- package/lib/flood-freeze-sensor.js +28 -24
- package/lib/freeze-sensor.js +19 -19
- package/lib/hap.js +4 -15
- package/lib/homebridge-ui/server.js +21 -32
- package/lib/index.js +7 -12
- package/lib/location-mode-switch.js +39 -42
- package/lib/lock.js +28 -29
- package/lib/motion-sensor.js +10 -14
- package/lib/multi-level-switch.js +24 -38
- package/lib/opus-repacketizer.js +66 -23
- package/lib/outlet.js +16 -26
- package/lib/panic-buttons.js +41 -45
- package/lib/ring-platform.js +186 -175
- package/lib/security-panel.js +84 -74
- package/lib/smoke-alarm.js +13 -15
- package/lib/smoke-co-listener.js +18 -18
- package/lib/switch.js +15 -25
- package/lib/target-value-timer.js +4 -8
- package/lib/temperature-sensor.js +11 -15
- package/lib/thermostat.js +60 -77
- package/lib/unknown-zwave-switch.js +15 -25
- package/lib/util.js +6 -10
- package/lib/water-sensor.js +19 -19
- package/package.json +9 -6
- package/lib/server.js +0 -58
package/lib/security-panel.js
CHANGED
|
@@ -1,30 +1,71 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
});
|
|
9
|
-
const _baseDeviceAccessory = require("./base-device-accessory");
|
|
10
|
-
const _ringClientApi = require("ring-client-api");
|
|
11
|
-
const _hap = require("./hap");
|
|
12
|
-
const _util = require("ring-client-api/util");
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SecurityPanel = void 0;
|
|
4
|
+
const base_device_accessory_1 = require("./base-device-accessory");
|
|
5
|
+
const ring_client_api_1 = require("ring-client-api");
|
|
6
|
+
const hap_1 = require("./hap");
|
|
7
|
+
const util_1 = require("ring-client-api/util");
|
|
13
8
|
function isValidNightModeBypass(mode) {
|
|
14
9
|
return mode && (mode === 'all' || mode === 'some');
|
|
15
10
|
}
|
|
16
|
-
class SecurityPanel extends
|
|
11
|
+
class SecurityPanel extends base_device_accessory_1.BaseDeviceAccessory {
|
|
12
|
+
constructor(device, accessory, config) {
|
|
13
|
+
super();
|
|
14
|
+
this.device = device;
|
|
15
|
+
this.accessory = accessory;
|
|
16
|
+
this.config = config;
|
|
17
|
+
this.alarmStates = this.config.alarmOnEntryDelay
|
|
18
|
+
? ring_client_api_1.allAlarmStates
|
|
19
|
+
: ring_client_api_1.allAlarmStates.filter((x) => x !== 'entry-delay');
|
|
20
|
+
const { Characteristic, Service } = hap_1.hap, validValues = [
|
|
21
|
+
Characteristic.SecuritySystemTargetState.AWAY_ARM,
|
|
22
|
+
Characteristic.SecuritySystemTargetState.STAY_ARM,
|
|
23
|
+
Characteristic.SecuritySystemTargetState.DISARM,
|
|
24
|
+
];
|
|
25
|
+
if (isValidNightModeBypass(config.nightModeBypassFor)) {
|
|
26
|
+
validValues.push(Characteristic.SecuritySystemTargetState.NIGHT_ARM);
|
|
27
|
+
}
|
|
28
|
+
this.registerCharacteristic({
|
|
29
|
+
characteristicType: Characteristic.SecuritySystemCurrentState,
|
|
30
|
+
serviceType: Service.SecuritySystem,
|
|
31
|
+
getValue: (data) => this.getCurrentState(data),
|
|
32
|
+
});
|
|
33
|
+
this.registerCharacteristic({
|
|
34
|
+
characteristicType: Characteristic.SecuritySystemTargetState,
|
|
35
|
+
serviceType: Service.SecuritySystem,
|
|
36
|
+
getValue: (data) => this.getTargetState(data),
|
|
37
|
+
setValue: (value) => this.setTargetState(value),
|
|
38
|
+
});
|
|
39
|
+
this.getService(Service.SecuritySystem)
|
|
40
|
+
.getCharacteristic(Characteristic.SecuritySystemTargetState)
|
|
41
|
+
.setProps({ validValues });
|
|
42
|
+
if (!config.hideAlarmSirenSwitch) {
|
|
43
|
+
this.registerCharacteristic({
|
|
44
|
+
characteristicType: Characteristic.On,
|
|
45
|
+
serviceType: Service.Switch,
|
|
46
|
+
name: this.device.name + ' Siren',
|
|
47
|
+
getValue: (data) => data.siren && data.siren.state === 'on',
|
|
48
|
+
setValue: (value) => {
|
|
49
|
+
if (value) {
|
|
50
|
+
return this.device.location.soundSiren();
|
|
51
|
+
}
|
|
52
|
+
return this.device.location.silenceSiren();
|
|
53
|
+
},
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
this.getService(Service.SecuritySystem).setPrimaryService(true);
|
|
57
|
+
}
|
|
17
58
|
getTargetNightMode() {
|
|
18
59
|
return this.targetingNightMode && this.config.nightModeBypassFor;
|
|
19
60
|
}
|
|
20
|
-
getTargetState({ mode
|
|
21
|
-
const { Characteristic: { SecuritySystemTargetState: State
|
|
61
|
+
getTargetState({ mode }) {
|
|
62
|
+
const { Characteristic: { SecuritySystemTargetState: State }, } = hap_1.hap;
|
|
22
63
|
if (mode === this.getTargetNightMode()) {
|
|
23
64
|
return State.NIGHT_ARM;
|
|
24
65
|
}
|
|
25
66
|
// current mode does not match night mode target, so we are no longer targeting night mode
|
|
26
67
|
this.targetingNightMode = false;
|
|
27
|
-
switch(mode){
|
|
68
|
+
switch (mode) {
|
|
28
69
|
case 'all':
|
|
29
70
|
return State.AWAY_ARM;
|
|
30
71
|
case 'some':
|
|
@@ -36,9 +77,9 @@ class SecurityPanel extends _baseDeviceAccessory.BaseDeviceAccessory {
|
|
|
36
77
|
}
|
|
37
78
|
}
|
|
38
79
|
getCurrentState(data) {
|
|
39
|
-
const { alarmInfo
|
|
80
|
+
const { alarmInfo } = data;
|
|
40
81
|
if (alarmInfo && this.alarmStates.includes(alarmInfo.state)) {
|
|
41
|
-
return
|
|
82
|
+
return hap_1.hap.Characteristic.SecuritySystemCurrentState.ALARM_TRIGGERED;
|
|
42
83
|
}
|
|
43
84
|
return this.getTargetState(data);
|
|
44
85
|
}
|
|
@@ -49,79 +90,48 @@ class SecurityPanel extends _baseDeviceAccessory.BaseDeviceAccessory {
|
|
|
49
90
|
this.accessory.context.targetingNightMode = value;
|
|
50
91
|
}
|
|
51
92
|
async setTargetState(state) {
|
|
52
|
-
const { Characteristic: { SecuritySystemTargetState: State
|
|
93
|
+
const { Characteristic: { SecuritySystemTargetState: State }, } = hap_1.hap, { location } = this.device, { nightModeBypassFor } = this.config;
|
|
53
94
|
let bypass = false;
|
|
54
95
|
this.targetingNightMode = state === State.NIGHT_ARM;
|
|
55
96
|
if (state === State.NIGHT_ARM) {
|
|
56
|
-
if (nightModeBypassFor &&
|
|
97
|
+
if (nightModeBypassFor &&
|
|
98
|
+
(nightModeBypassFor === 'all' || nightModeBypassFor === 'some')) {
|
|
57
99
|
state = nightModeBypassFor === 'all' ? State.AWAY_ARM : State.STAY_ARM;
|
|
58
100
|
bypass = true;
|
|
59
|
-
}
|
|
101
|
+
}
|
|
102
|
+
else {
|
|
60
103
|
// Switch to Home since we don't know which mode the user wanted
|
|
61
104
|
state = State.STAY_ARM;
|
|
62
105
|
}
|
|
63
106
|
}
|
|
64
|
-
const bypassContactSensors = bypass
|
|
65
|
-
|
|
66
|
-
|
|
107
|
+
const bypassContactSensors = bypass
|
|
108
|
+
? (await location.getDevices()).filter((device) => {
|
|
109
|
+
return (device.deviceType === ring_client_api_1.RingDeviceType.ContactSensor &&
|
|
110
|
+
device.data.faulted);
|
|
111
|
+
})
|
|
112
|
+
: [], bypassSensorZids = bypassContactSensors.map((sensor) => sensor.id), bypassSensorNames = bypassContactSensors.map((sensor) => sensor.name), bypassLog = bypassSensorNames.length
|
|
113
|
+
? ' - Bypassing Sensors: ' + bypassSensorNames.join(', ')
|
|
114
|
+
: '';
|
|
67
115
|
try {
|
|
68
116
|
if (state === State.AWAY_ARM) {
|
|
69
|
-
(0,
|
|
117
|
+
(0, util_1.logInfo)(`Arming (Away) ${this.device.name}${bypassLog}`);
|
|
70
118
|
await location.armAway(bypassSensorZids);
|
|
71
|
-
}
|
|
72
|
-
|
|
119
|
+
}
|
|
120
|
+
else if (state === State.DISARM) {
|
|
121
|
+
(0, util_1.logInfo)(`Disarming ${this.device.name}`);
|
|
73
122
|
await location.disarm();
|
|
74
|
-
}
|
|
75
|
-
|
|
123
|
+
}
|
|
124
|
+
else {
|
|
125
|
+
(0, util_1.logInfo)(`Arming (Home) ${this.device.name}${bypassLog}`);
|
|
76
126
|
await location.armHome(bypassSensorZids);
|
|
77
127
|
}
|
|
78
|
-
} catch (e) {
|
|
79
|
-
(0, _util.logError)(e);
|
|
80
|
-
this.getService(_hap.hap.Service.SecuritySystem).getCharacteristic(_hap.hap.Characteristic.SecuritySystemTargetState).updateValue(this.getTargetState(this.device.data));
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
constructor(device, accessory, config){
|
|
84
|
-
super();
|
|
85
|
-
this.device = device;
|
|
86
|
-
this.accessory = accessory;
|
|
87
|
-
this.config = config;
|
|
88
|
-
this.alarmStates = this.config.alarmOnEntryDelay ? _ringClientApi.allAlarmStates : _ringClientApi.allAlarmStates.filter((x)=>x !== 'entry-delay');
|
|
89
|
-
const { Characteristic , Service } = _hap.hap, validValues = [
|
|
90
|
-
Characteristic.SecuritySystemTargetState.AWAY_ARM,
|
|
91
|
-
Characteristic.SecuritySystemTargetState.STAY_ARM,
|
|
92
|
-
Characteristic.SecuritySystemTargetState.DISARM
|
|
93
|
-
];
|
|
94
|
-
if (isValidNightModeBypass(config.nightModeBypassFor)) {
|
|
95
|
-
validValues.push(Characteristic.SecuritySystemTargetState.NIGHT_ARM);
|
|
96
128
|
}
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
this.registerCharacteristic({
|
|
103
|
-
characteristicType: Characteristic.SecuritySystemTargetState,
|
|
104
|
-
serviceType: Service.SecuritySystem,
|
|
105
|
-
getValue: (data)=>this.getTargetState(data),
|
|
106
|
-
setValue: (value)=>this.setTargetState(value)
|
|
107
|
-
});
|
|
108
|
-
this.getService(Service.SecuritySystem).getCharacteristic(Characteristic.SecuritySystemTargetState).setProps({
|
|
109
|
-
validValues
|
|
110
|
-
});
|
|
111
|
-
if (!config.hideAlarmSirenSwitch) {
|
|
112
|
-
this.registerCharacteristic({
|
|
113
|
-
characteristicType: Characteristic.On,
|
|
114
|
-
serviceType: Service.Switch,
|
|
115
|
-
name: this.device.name + ' Siren',
|
|
116
|
-
getValue: (data)=>data.siren && data.siren.state === 'on',
|
|
117
|
-
setValue: (value)=>{
|
|
118
|
-
if (value) {
|
|
119
|
-
return this.device.location.soundSiren();
|
|
120
|
-
}
|
|
121
|
-
return this.device.location.silenceSiren();
|
|
122
|
-
}
|
|
123
|
-
});
|
|
129
|
+
catch (e) {
|
|
130
|
+
(0, util_1.logError)(e);
|
|
131
|
+
this.getService(hap_1.hap.Service.SecuritySystem)
|
|
132
|
+
.getCharacteristic(hap_1.hap.Characteristic.SecuritySystemTargetState)
|
|
133
|
+
.updateValue(this.getTargetState(this.device.data));
|
|
124
134
|
}
|
|
125
|
-
this.getService(Service.SecuritySystem).setPrimaryService(true);
|
|
126
135
|
}
|
|
127
136
|
}
|
|
137
|
+
exports.SecurityPanel = SecurityPanel;
|
package/lib/smoke-alarm.js
CHANGED
|
@@ -1,27 +1,25 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
});
|
|
9
|
-
const _baseDeviceAccessory = require("./base-device-accessory");
|
|
10
|
-
const _hap = require("./hap");
|
|
11
|
-
class SmokeAlarm extends _baseDeviceAccessory.BaseDeviceAccessory {
|
|
12
|
-
constructor(device, accessory, config){
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SmokeAlarm = void 0;
|
|
4
|
+
const base_device_accessory_1 = require("./base-device-accessory");
|
|
5
|
+
const hap_1 = require("./hap");
|
|
6
|
+
class SmokeAlarm extends base_device_accessory_1.BaseDeviceAccessory {
|
|
7
|
+
constructor(device, accessory, config) {
|
|
13
8
|
super();
|
|
14
9
|
this.device = device;
|
|
15
10
|
this.accessory = accessory;
|
|
16
11
|
this.config = config;
|
|
17
|
-
const { Characteristic: { SmokeDetected
|
|
12
|
+
const { Characteristic: { SmokeDetected }, Service: { SmokeSensor }, } = hap_1.hap;
|
|
18
13
|
this.registerCharacteristic({
|
|
19
14
|
characteristicType: SmokeDetected,
|
|
20
15
|
serviceType: SmokeSensor,
|
|
21
|
-
getValue: (data)=>{
|
|
22
|
-
return data.alarmStatus === 'active'
|
|
23
|
-
|
|
16
|
+
getValue: (data) => {
|
|
17
|
+
return data.alarmStatus === 'active'
|
|
18
|
+
? SmokeDetected.SMOKE_DETECTED
|
|
19
|
+
: SmokeDetected.SMOKE_NOT_DETECTED;
|
|
20
|
+
},
|
|
24
21
|
});
|
|
25
22
|
this.initSensorService(SmokeSensor);
|
|
26
23
|
}
|
|
27
24
|
}
|
|
25
|
+
exports.SmokeAlarm = SmokeAlarm;
|
package/lib/smoke-co-listener.js
CHANGED
|
@@ -1,35 +1,35 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
});
|
|
9
|
-
const _baseDeviceAccessory = require("./base-device-accessory");
|
|
10
|
-
const _hap = require("./hap");
|
|
11
|
-
class SmokeCoListener extends _baseDeviceAccessory.BaseDeviceAccessory {
|
|
12
|
-
constructor(device, accessory, config){
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SmokeCoListener = void 0;
|
|
4
|
+
const base_device_accessory_1 = require("./base-device-accessory");
|
|
5
|
+
const hap_1 = require("./hap");
|
|
6
|
+
class SmokeCoListener extends base_device_accessory_1.BaseDeviceAccessory {
|
|
7
|
+
constructor(device, accessory, config) {
|
|
13
8
|
super();
|
|
14
9
|
this.device = device;
|
|
15
10
|
this.accessory = accessory;
|
|
16
11
|
this.config = config;
|
|
17
|
-
const { Characteristic: { SmokeDetected
|
|
12
|
+
const { Characteristic: { SmokeDetected, CarbonMonoxideDetected }, Service: { SmokeSensor, CarbonMonoxideSensor }, } = hap_1.hap;
|
|
18
13
|
this.registerCharacteristic({
|
|
19
14
|
characteristicType: SmokeDetected,
|
|
20
15
|
serviceType: SmokeSensor,
|
|
21
|
-
getValue: (data)=>{
|
|
22
|
-
return data.smoke && data.smoke.alarmStatus === 'active'
|
|
23
|
-
|
|
16
|
+
getValue: (data) => {
|
|
17
|
+
return data.smoke && data.smoke.alarmStatus === 'active'
|
|
18
|
+
? SmokeDetected.SMOKE_DETECTED
|
|
19
|
+
: SmokeDetected.SMOKE_NOT_DETECTED;
|
|
20
|
+
},
|
|
24
21
|
});
|
|
25
22
|
this.registerCharacteristic({
|
|
26
23
|
characteristicType: CarbonMonoxideDetected,
|
|
27
24
|
serviceType: CarbonMonoxideSensor,
|
|
28
|
-
getValue: (data)=>{
|
|
29
|
-
return data.co && data.co.alarmStatus === 'active'
|
|
30
|
-
|
|
25
|
+
getValue: (data) => {
|
|
26
|
+
return data.co && data.co.alarmStatus === 'active'
|
|
27
|
+
? CarbonMonoxideDetected.CO_LEVELS_ABNORMAL
|
|
28
|
+
: CarbonMonoxideDetected.CO_LEVELS_NORMAL;
|
|
29
|
+
},
|
|
31
30
|
});
|
|
32
31
|
this.initSensorService(SmokeSensor);
|
|
33
32
|
this.initSensorService(CarbonMonoxideSensor);
|
|
34
33
|
}
|
|
35
34
|
}
|
|
35
|
+
exports.SmokeCoListener = SmokeCoListener;
|
package/lib/switch.js
CHANGED
|
@@ -1,36 +1,26 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
const _baseDeviceAccessory = require("./base-device-accessory");
|
|
10
|
-
const _hap = require("./hap");
|
|
11
|
-
const _util = require("ring-client-api/util");
|
|
12
|
-
class Switch 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
|
-
constructor(device, accessory, config){
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Switch = 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 Switch extends base_device_accessory_1.BaseDeviceAccessory {
|
|
8
|
+
constructor(device, accessory, config) {
|
|
24
9
|
super();
|
|
25
10
|
this.device = device;
|
|
26
11
|
this.accessory = accessory;
|
|
27
12
|
this.config = config;
|
|
28
|
-
const { Characteristic
|
|
13
|
+
const { Characteristic, Service } = hap_1.hap;
|
|
29
14
|
this.registerCharacteristic({
|
|
30
15
|
characteristicType: Characteristic.On,
|
|
31
16
|
serviceType: Service.Switch,
|
|
32
|
-
getValue: (data)=>Boolean(data.on),
|
|
33
|
-
setValue: (value)=>this.setOnState(value)
|
|
17
|
+
getValue: (data) => Boolean(data.on),
|
|
18
|
+
setValue: (value) => this.setOnState(value),
|
|
34
19
|
});
|
|
35
20
|
}
|
|
21
|
+
setOnState(on) {
|
|
22
|
+
(0, util_1.logInfo)(`Turning ${this.device.name} ${on ? 'On' : 'Off'}`);
|
|
23
|
+
return this.device.setInfo({ device: { v1: { on } } });
|
|
24
|
+
}
|
|
36
25
|
}
|
|
26
|
+
exports.Switch = Switch;
|
|
@@ -1,16 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
|
|
4
|
-
});
|
|
5
|
-
Object.defineProperty(exports, "TargetValueTimer", {
|
|
6
|
-
enumerable: true,
|
|
7
|
-
get: ()=>TargetValueTimer
|
|
8
|
-
});
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TargetValueTimer = void 0;
|
|
9
4
|
class TargetValueTimer {
|
|
10
5
|
setTarget(value, duration) {
|
|
11
6
|
this.reset();
|
|
12
7
|
this.targetValue = value;
|
|
13
|
-
this.timeout = setTimeout(()=>{
|
|
8
|
+
this.timeout = setTimeout(() => {
|
|
14
9
|
this.reset();
|
|
15
10
|
}, duration);
|
|
16
11
|
}
|
|
@@ -28,3 +23,4 @@ class TargetValueTimer {
|
|
|
28
23
|
this.timeout = undefined;
|
|
29
24
|
}
|
|
30
25
|
}
|
|
26
|
+
exports.TargetValueTimer = TargetValueTimer;
|
|
@@ -1,28 +1,24 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
const _baseDeviceAccessory = require("./base-device-accessory");
|
|
10
|
-
const _hap = require("./hap");
|
|
11
|
-
const _operators = require("rxjs/operators");
|
|
12
|
-
class TemperatureSensor extends _baseDeviceAccessory.BaseDeviceAccessory {
|
|
13
|
-
constructor(device, accessory, config){
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TemperatureSensor = 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
|
+
class TemperatureSensor extends base_device_accessory_1.BaseDeviceAccessory {
|
|
8
|
+
constructor(device, accessory, config) {
|
|
14
9
|
super();
|
|
15
10
|
this.device = device;
|
|
16
11
|
this.accessory = accessory;
|
|
17
12
|
this.config = config;
|
|
18
|
-
const { Characteristic: { CurrentTemperature
|
|
13
|
+
const { Characteristic: { CurrentTemperature }, Service: { TemperatureSensor: TempSensorService }, } = hap_1.hap;
|
|
19
14
|
this.registerObservableCharacteristic({
|
|
20
15
|
characteristicType: CurrentTemperature,
|
|
21
16
|
serviceType: TempSensorService,
|
|
22
|
-
onValue: device.onData.pipe((0,
|
|
17
|
+
onValue: device.onData.pipe((0, operators_1.map)((data) => {
|
|
23
18
|
return data.celsius;
|
|
24
|
-
}), (0,
|
|
19
|
+
}), (0, operators_1.distinctUntilChanged)()),
|
|
25
20
|
});
|
|
26
21
|
this.initSensorService(TempSensorService);
|
|
27
22
|
}
|
|
28
23
|
}
|
|
24
|
+
exports.TemperatureSensor = TemperatureSensor;
|