@switchbot/homebridge-switchbot 2.14.0 → 3.0.0-beta.0
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/.github/npm-version-script.cjs +81 -0
- package/.github/workflows/dependabot.yml +10 -11
- package/CHANGELOG.md +11 -2
- package/LICENSE +1 -1
- package/config.schema.json +1 -0
- package/dist/device/blindtilt.d.ts +9 -5
- package/dist/device/blindtilt.d.ts.map +1 -1
- package/dist/device/blindtilt.js +151 -91
- package/dist/device/blindtilt.js.map +1 -1
- package/dist/device/bot.d.ts +9 -5
- package/dist/device/bot.d.ts.map +1 -1
- package/dist/device/bot.js +234 -184
- package/dist/device/bot.js.map +1 -1
- package/dist/device/ceilinglight.d.ts +9 -5
- package/dist/device/ceilinglight.d.ts.map +1 -1
- package/dist/device/ceilinglight.js +110 -64
- package/dist/device/ceilinglight.js.map +1 -1
- package/dist/device/colorbulb.d.ts +9 -5
- package/dist/device/colorbulb.d.ts.map +1 -1
- package/dist/device/colorbulb.js +121 -69
- package/dist/device/colorbulb.js.map +1 -1
- package/dist/device/contact.d.ts +9 -5
- package/dist/device/contact.d.ts.map +1 -1
- package/dist/device/contact.js +111 -66
- package/dist/device/contact.js.map +1 -1
- package/dist/device/curtain.d.ts +9 -5
- package/dist/device/curtain.d.ts.map +1 -1
- package/dist/device/curtain.js +164 -107
- package/dist/device/curtain.js.map +1 -1
- package/dist/device/hub.d.ts +9 -5
- package/dist/device/hub.d.ts.map +1 -1
- package/dist/device/hub.js +87 -51
- package/dist/device/hub.js.map +1 -1
- package/dist/device/humidifier.d.ts +9 -5
- package/dist/device/humidifier.d.ts.map +1 -1
- package/dist/device/humidifier.js +133 -90
- package/dist/device/humidifier.js.map +1 -1
- package/dist/device/iosensor.d.ts +9 -5
- package/dist/device/iosensor.d.ts.map +1 -1
- package/dist/device/iosensor.js +108 -66
- package/dist/device/iosensor.js.map +1 -1
- package/dist/device/lightstrip.d.ts +9 -5
- package/dist/device/lightstrip.d.ts.map +1 -1
- package/dist/device/lightstrip.js +110 -65
- package/dist/device/lightstrip.js.map +1 -1
- package/dist/device/lock.d.ts +10 -6
- package/dist/device/lock.d.ts.map +1 -1
- package/dist/device/lock.js +125 -84
- package/dist/device/lock.js.map +1 -1
- package/dist/device/meter.d.ts +9 -5
- package/dist/device/meter.d.ts.map +1 -1
- package/dist/device/meter.js +102 -63
- package/dist/device/meter.js.map +1 -1
- package/dist/device/meterplus.d.ts +9 -5
- package/dist/device/meterplus.d.ts.map +1 -1
- package/dist/device/meterplus.js +102 -63
- package/dist/device/meterplus.js.map +1 -1
- package/dist/device/motion.d.ts +9 -5
- package/dist/device/motion.d.ts.map +1 -1
- package/dist/device/motion.js +95 -54
- package/dist/device/motion.js.map +1 -1
- package/dist/device/plug.d.ts +9 -5
- package/dist/device/plug.d.ts.map +1 -1
- package/dist/device/plug.js +68 -40
- package/dist/device/plug.js.map +1 -1
- package/dist/device/robotvacuumcleaner.d.ts +9 -5
- package/dist/device/robotvacuumcleaner.d.ts.map +1 -1
- package/dist/device/robotvacuumcleaner.js +86 -52
- package/dist/device/robotvacuumcleaner.js.map +1 -1
- package/dist/homebridge-ui/server.d.ts +2 -0
- package/dist/homebridge-ui/server.d.ts.map +1 -0
- package/dist/homebridge-ui/server.js +44 -0
- package/dist/homebridge-ui/server.js.map +1 -0
- package/dist/index.d.ts +1 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +9 -5
- package/dist/index.js.map +1 -1
- package/dist/irdevice/airconditioner.d.ts +8 -4
- package/dist/irdevice/airconditioner.d.ts.map +1 -1
- package/dist/irdevice/airconditioner.js +105 -71
- package/dist/irdevice/airconditioner.js.map +1 -1
- package/dist/irdevice/airpurifier.d.ts +8 -4
- package/dist/irdevice/airpurifier.d.ts.map +1 -1
- package/dist/irdevice/airpurifier.js +78 -46
- package/dist/irdevice/airpurifier.js.map +1 -1
- package/dist/irdevice/camera.d.ts +8 -4
- package/dist/irdevice/camera.d.ts.map +1 -1
- package/dist/irdevice/camera.js +41 -25
- package/dist/irdevice/camera.js.map +1 -1
- package/dist/irdevice/fan.d.ts +8 -4
- package/dist/irdevice/fan.d.ts.map +1 -1
- package/dist/irdevice/fan.js +62 -39
- package/dist/irdevice/fan.js.map +1 -1
- package/dist/irdevice/light.d.ts +8 -4
- package/dist/irdevice/light.d.ts.map +1 -1
- package/dist/irdevice/light.js +67 -45
- package/dist/irdevice/light.js.map +1 -1
- package/dist/irdevice/other.d.ts +8 -4
- package/dist/irdevice/other.d.ts.map +1 -1
- package/dist/irdevice/other.js +176 -150
- package/dist/irdevice/other.js.map +1 -1
- package/dist/irdevice/tv.d.ts +8 -4
- package/dist/irdevice/tv.d.ts.map +1 -1
- package/dist/irdevice/tv.js +81 -62
- package/dist/irdevice/tv.js.map +1 -1
- package/dist/irdevice/vacuumcleaner.d.ts +8 -4
- package/dist/irdevice/vacuumcleaner.d.ts.map +1 -1
- package/dist/irdevice/vacuumcleaner.js +41 -25
- package/dist/irdevice/vacuumcleaner.js.map +1 -1
- package/dist/irdevice/waterheater.d.ts +8 -4
- package/dist/irdevice/waterheater.d.ts.map +1 -1
- package/dist/irdevice/waterheater.js +48 -32
- package/dist/irdevice/waterheater.js.map +1 -1
- package/dist/platform.d.ts +8 -9
- package/dist/platform.d.ts.map +1 -1
- package/dist/platform.js +147 -162
- package/dist/platform.js.map +1 -1
- package/dist/settings.js +7 -14
- package/dist/settings.js.map +1 -1
- package/dist/utils.js +1 -5
- package/dist/utils.js.map +1 -1
- package/package.json +28 -16
- package/src/device/blindtilt.ts +80 -69
- package/src/device/bot.ts +189 -178
- package/src/device/ceilinglight.ts +55 -42
- package/src/device/colorbulb.ts +51 -38
- package/src/device/contact.ts +69 -58
- package/src/device/curtain.ts +94 -83
- package/src/device/hub.ts +54 -43
- package/src/device/humidifier.ts +86 -75
- package/src/device/iosensor.ts +63 -52
- package/src/device/lightstrip.ts +54 -41
- package/src/device/lock.ts +89 -79
- package/src/device/meter.ts +59 -48
- package/src/device/meterplus.ts +63 -52
- package/src/device/motion.ts +56 -45
- package/src/device/plug.ts +36 -25
- package/src/device/robotvacuumcleaner.ts +47 -36
- package/src/homebridge-ui/public/index.html +240 -0
- package/src/homebridge-ui/server.ts +48 -0
- package/src/index.ts +10 -7
- package/src/irdevice/airconditioner.ts +70 -62
- package/src/irdevice/airpurifier.ts +47 -39
- package/src/irdevice/camera.ts +27 -19
- package/src/irdevice/fan.ts +41 -33
- package/src/irdevice/light.ts +47 -39
- package/src/irdevice/other.ts +163 -155
- package/src/irdevice/tv.ts +65 -57
- package/src/irdevice/vacuumcleaner.ts +27 -19
- package/src/irdevice/waterheater.ts +34 -26
- package/src/platform.ts +35 -21
- package/tsconfig.json +11 -13
- package/homebridge-ui/server.js +0 -50
- /package/{homebridge-ui → dist/homebridge-ui}/public/index.html +0 -0
package/src/irdevice/other.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { CharacteristicValue, PlatformAccessory, Service } from 'homebridge';
|
|
1
|
+
import { CharacteristicValue, PlatformAccessory, Service, API, Logging, HAP } from 'homebridge';
|
|
2
2
|
import { request } from 'undici';
|
|
3
3
|
import { SwitchBotPlatform } from '../platform';
|
|
4
|
-
import { Devices, irDevicesConfig, irdevice } from '../settings';
|
|
4
|
+
import { Devices, irDevicesConfig, irdevice, SwitchBotPlatformConfig } from '../settings';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Platform Accessory
|
|
@@ -9,6 +9,10 @@ import { Devices, irDevicesConfig, irdevice } from '../settings';
|
|
|
9
9
|
* Each accessory may expose multiple services of different service types.
|
|
10
10
|
*/
|
|
11
11
|
export class Others {
|
|
12
|
+
public readonly api: API;
|
|
13
|
+
public readonly log: Logging;
|
|
14
|
+
public readonly config!: SwitchBotPlatformConfig;
|
|
15
|
+
protected readonly hap: HAP;
|
|
12
16
|
// Services
|
|
13
17
|
fanService?: Service;
|
|
14
18
|
doorService?: Service;
|
|
@@ -36,21 +40,25 @@ export class Others {
|
|
|
36
40
|
private accessory: PlatformAccessory,
|
|
37
41
|
public device: irdevice & irDevicesConfig,
|
|
38
42
|
) {
|
|
43
|
+
this.api = this.platform.api;
|
|
44
|
+
this.log = this.platform.log;
|
|
45
|
+
this.config = this.platform.config;
|
|
46
|
+
this.hap = this.api.hap;
|
|
39
47
|
// default placeholders
|
|
40
|
-
this.
|
|
48
|
+
this.deviceLogs(device);
|
|
41
49
|
this.deviceType(device);
|
|
42
50
|
this.context();
|
|
43
51
|
this.disablePushOnChanges(device);
|
|
44
52
|
this.disablePushOffChanges(device);
|
|
45
|
-
this.
|
|
53
|
+
this.deviceConfig(device);
|
|
46
54
|
|
|
47
55
|
// set accessory information
|
|
48
56
|
accessory
|
|
49
|
-
.getService(this.
|
|
50
|
-
.setCharacteristic(this.
|
|
51
|
-
.setCharacteristic(this.
|
|
52
|
-
.setCharacteristic(this.
|
|
53
|
-
.setCharacteristic(this.
|
|
57
|
+
.getService(this.hap.Service.AccessoryInformation)!
|
|
58
|
+
.setCharacteristic(this.hap.Characteristic.Manufacturer, 'SwitchBot')
|
|
59
|
+
.setCharacteristic(this.hap.Characteristic.Model, device.remoteType)
|
|
60
|
+
.setCharacteristic(this.hap.Characteristic.SerialNumber, device.deviceId)
|
|
61
|
+
.setCharacteristic(this.hap.Characteristic.FirmwareRevision, accessory.context.FirmwareRevision);
|
|
54
62
|
|
|
55
63
|
// deviceType
|
|
56
64
|
if (this.otherDeviceType === 'switch') {
|
|
@@ -66,15 +74,15 @@ export class Others {
|
|
|
66
74
|
|
|
67
75
|
// Add switchService
|
|
68
76
|
const switchService = `${accessory.displayName} Switch`;
|
|
69
|
-
(this.switchService = accessory.getService(this.
|
|
70
|
-
|| accessory.addService(this.
|
|
77
|
+
(this.switchService = accessory.getService(this.hap.Service.Switch)
|
|
78
|
+
|| accessory.addService(this.hap.Service.Switch)), switchService;
|
|
71
79
|
this.debugWarnLog(`${this.device.remoteType}: ${accessory.displayName} Displaying as Switch`);
|
|
72
80
|
|
|
73
|
-
this.switchService.setCharacteristic(this.
|
|
74
|
-
if (!this.switchService.testCharacteristic(this.
|
|
75
|
-
this.switchService.addCharacteristic(this.
|
|
81
|
+
this.switchService.setCharacteristic(this.hap.Characteristic.Name, accessory.displayName);
|
|
82
|
+
if (!this.switchService.testCharacteristic(this.hap.Characteristic.ConfiguredName)) {
|
|
83
|
+
this.switchService.addCharacteristic(this.hap.Characteristic.ConfiguredName, accessory.displayName);
|
|
76
84
|
}
|
|
77
|
-
this.switchService.getCharacteristic(this.
|
|
85
|
+
this.switchService.getCharacteristic(this.hap.Characteristic.On).onSet(this.OnSet.bind(this));
|
|
78
86
|
} else if (this.otherDeviceType === 'garagedoor') {
|
|
79
87
|
this.removeFanService(accessory);
|
|
80
88
|
this.removeLockService(accessory);
|
|
@@ -88,16 +96,16 @@ export class Others {
|
|
|
88
96
|
|
|
89
97
|
// Add garageDoorService
|
|
90
98
|
const garageDoorService = `${accessory.displayName} Garage Door Opener`;
|
|
91
|
-
(this.garageDoorService = accessory.getService(this.
|
|
92
|
-
|| accessory.addService(this.
|
|
99
|
+
(this.garageDoorService = accessory.getService(this.hap.Service.GarageDoorOpener)
|
|
100
|
+
|| accessory.addService(this.hap.Service.GarageDoorOpener)), garageDoorService;
|
|
93
101
|
this.debugWarnLog(`${this.device.remoteType}: ${accessory.displayName} Displaying as Garage Door Opener`);
|
|
94
102
|
|
|
95
|
-
this.garageDoorService.setCharacteristic(this.
|
|
96
|
-
if (!this.garageDoorService.testCharacteristic(this.
|
|
97
|
-
this.garageDoorService.addCharacteristic(this.
|
|
103
|
+
this.garageDoorService.setCharacteristic(this.hap.Characteristic.Name, accessory.displayName);
|
|
104
|
+
if (!this.garageDoorService.testCharacteristic(this.hap.Characteristic.ConfiguredName)) {
|
|
105
|
+
this.garageDoorService.addCharacteristic(this.hap.Characteristic.ConfiguredName, accessory.displayName);
|
|
98
106
|
}
|
|
99
|
-
this.garageDoorService.getCharacteristic(this.
|
|
100
|
-
this.garageDoorService.setCharacteristic(this.
|
|
107
|
+
this.garageDoorService.getCharacteristic(this.hap.Characteristic.TargetDoorState).onSet(this.OnSet.bind(this));
|
|
108
|
+
this.garageDoorService.setCharacteristic(this.hap.Characteristic.ObstructionDetected, false);
|
|
101
109
|
} else if (this.otherDeviceType === 'door') {
|
|
102
110
|
this.removeFanService(accessory);
|
|
103
111
|
this.removeLockService(accessory);
|
|
@@ -111,16 +119,16 @@ export class Others {
|
|
|
111
119
|
|
|
112
120
|
// Add doorService
|
|
113
121
|
const doorService = `${accessory.displayName} Door`;
|
|
114
|
-
(this.doorService = accessory.getService(this.
|
|
115
|
-
|| accessory.addService(this.
|
|
122
|
+
(this.doorService = accessory.getService(this.hap.Service.Door)
|
|
123
|
+
|| accessory.addService(this.hap.Service.Door)), doorService;
|
|
116
124
|
this.debugWarnLog(`${this.device.remoteType}: ${accessory.displayName} Displaying as Door`);
|
|
117
125
|
|
|
118
|
-
this.doorService.setCharacteristic(this.
|
|
119
|
-
if (!this.doorService.testCharacteristic(this.
|
|
120
|
-
this.doorService.addCharacteristic(this.
|
|
126
|
+
this.doorService.setCharacteristic(this.hap.Characteristic.Name, accessory.displayName);
|
|
127
|
+
if (!this.doorService.testCharacteristic(this.hap.Characteristic.ConfiguredName)) {
|
|
128
|
+
this.doorService.addCharacteristic(this.hap.Characteristic.ConfiguredName, accessory.displayName);
|
|
121
129
|
}
|
|
122
130
|
this.doorService
|
|
123
|
-
.getCharacteristic(this.
|
|
131
|
+
.getCharacteristic(this.hap.Characteristic.TargetPosition)
|
|
124
132
|
.setProps({
|
|
125
133
|
validValues: [0, 100],
|
|
126
134
|
minValue: 0,
|
|
@@ -128,7 +136,7 @@ export class Others {
|
|
|
128
136
|
minStep: 100,
|
|
129
137
|
})
|
|
130
138
|
.onSet(this.OnSet.bind(this));
|
|
131
|
-
this.doorService.setCharacteristic(this.
|
|
139
|
+
this.doorService.setCharacteristic(this.hap.Characteristic.PositionState, this.hap.Characteristic.PositionState.STOPPED);
|
|
132
140
|
} else if (this.otherDeviceType === 'window') {
|
|
133
141
|
this.removeFanService(accessory);
|
|
134
142
|
this.removeLockService(accessory);
|
|
@@ -142,16 +150,16 @@ export class Others {
|
|
|
142
150
|
|
|
143
151
|
// Add windowService
|
|
144
152
|
const windowService = `${accessory.displayName} Window`;
|
|
145
|
-
(this.windowService = accessory.getService(this.
|
|
146
|
-
|| accessory.addService(this.
|
|
153
|
+
(this.windowService = accessory.getService(this.hap.Service.Window)
|
|
154
|
+
|| accessory.addService(this.hap.Service.Window)), windowService;
|
|
147
155
|
this.debugWarnLog(`${this.device.remoteType}: ${accessory.displayName} Displaying as Window`);
|
|
148
156
|
|
|
149
|
-
this.windowService.setCharacteristic(this.
|
|
150
|
-
if (!this.windowService.testCharacteristic(this.
|
|
151
|
-
this.windowService.addCharacteristic(this.
|
|
157
|
+
this.windowService.setCharacteristic(this.hap.Characteristic.Name, accessory.displayName);
|
|
158
|
+
if (!this.windowService.testCharacteristic(this.hap.Characteristic.ConfiguredName)) {
|
|
159
|
+
this.windowService.addCharacteristic(this.hap.Characteristic.ConfiguredName, accessory.displayName);
|
|
152
160
|
}
|
|
153
161
|
this.windowService
|
|
154
|
-
.getCharacteristic(this.
|
|
162
|
+
.getCharacteristic(this.hap.Characteristic.TargetPosition)
|
|
155
163
|
.setProps({
|
|
156
164
|
validValues: [0, 100],
|
|
157
165
|
minValue: 0,
|
|
@@ -159,7 +167,7 @@ export class Others {
|
|
|
159
167
|
minStep: 100,
|
|
160
168
|
})
|
|
161
169
|
.onSet(this.OnSet.bind(this));
|
|
162
|
-
this.windowService.setCharacteristic(this.
|
|
170
|
+
this.windowService.setCharacteristic(this.hap.Characteristic.PositionState, this.hap.Characteristic.PositionState.STOPPED);
|
|
163
171
|
} else if (this.otherDeviceType === 'windowcovering') {
|
|
164
172
|
this.removeFanService(accessory);
|
|
165
173
|
this.removeLockService(accessory);
|
|
@@ -173,16 +181,16 @@ export class Others {
|
|
|
173
181
|
|
|
174
182
|
// Add windowCoveringService
|
|
175
183
|
const windowCoveringService = `${accessory.displayName} Window Covering`;
|
|
176
|
-
(this.windowCoveringService = accessory.getService(this.
|
|
177
|
-
|| accessory.addService(this.
|
|
184
|
+
(this.windowCoveringService = accessory.getService(this.hap.Service.WindowCovering)
|
|
185
|
+
|| accessory.addService(this.hap.Service.WindowCovering)), windowCoveringService;
|
|
178
186
|
this.debugWarnLog(`${this.device.remoteType}: ${accessory.displayName} Displaying as Window Covering`);
|
|
179
187
|
|
|
180
|
-
this.windowCoveringService.setCharacteristic(this.
|
|
181
|
-
if (!this.windowCoveringService.testCharacteristic(this.
|
|
182
|
-
this.windowCoveringService.addCharacteristic(this.
|
|
188
|
+
this.windowCoveringService.setCharacteristic(this.hap.Characteristic.Name, accessory.displayName);
|
|
189
|
+
if (!this.windowCoveringService.testCharacteristic(this.hap.Characteristic.ConfiguredName)) {
|
|
190
|
+
this.windowCoveringService.addCharacteristic(this.hap.Characteristic.ConfiguredName, accessory.displayName);
|
|
183
191
|
}
|
|
184
192
|
this.windowCoveringService
|
|
185
|
-
.getCharacteristic(this.
|
|
193
|
+
.getCharacteristic(this.hap.Characteristic.TargetPosition)
|
|
186
194
|
.setProps({
|
|
187
195
|
validValues: [0, 100],
|
|
188
196
|
minValue: 0,
|
|
@@ -190,7 +198,7 @@ export class Others {
|
|
|
190
198
|
minStep: 100,
|
|
191
199
|
})
|
|
192
200
|
.onSet(this.OnSet.bind(this));
|
|
193
|
-
this.windowCoveringService.setCharacteristic(this.
|
|
201
|
+
this.windowCoveringService.setCharacteristic(this.hap.Characteristic.PositionState, this.hap.Characteristic.PositionState.STOPPED);
|
|
194
202
|
} else if (this.otherDeviceType === 'lock') {
|
|
195
203
|
this.removeFanService(accessory);
|
|
196
204
|
this.removeDoorService(accessory);
|
|
@@ -204,15 +212,15 @@ export class Others {
|
|
|
204
212
|
|
|
205
213
|
// Add lockService
|
|
206
214
|
const lockService = `${accessory.displayName} Lock`;
|
|
207
|
-
(this.lockService = accessory.getService(this.
|
|
208
|
-
|| accessory.addService(this.
|
|
215
|
+
(this.lockService = accessory.getService(this.hap.Service.LockMechanism)
|
|
216
|
+
|| accessory.addService(this.hap.Service.LockMechanism)), lockService;
|
|
209
217
|
this.debugWarnLog(`${this.device.remoteType}: ${accessory.displayName} Displaying as Lock`);
|
|
210
218
|
|
|
211
|
-
this.lockService.setCharacteristic(this.
|
|
212
|
-
if (!this.lockService.testCharacteristic(this.
|
|
213
|
-
this.lockService.addCharacteristic(this.
|
|
219
|
+
this.lockService.setCharacteristic(this.hap.Characteristic.Name, accessory.displayName);
|
|
220
|
+
if (!this.lockService.testCharacteristic(this.hap.Characteristic.ConfiguredName)) {
|
|
221
|
+
this.lockService.addCharacteristic(this.hap.Characteristic.ConfiguredName, accessory.displayName);
|
|
214
222
|
}
|
|
215
|
-
this.lockService.getCharacteristic(this.
|
|
223
|
+
this.lockService.getCharacteristic(this.hap.Characteristic.LockTargetState).onSet(this.OnSet.bind(this));
|
|
216
224
|
} else if (this.otherDeviceType === 'faucet') {
|
|
217
225
|
this.removeFanService(accessory);
|
|
218
226
|
this.removeLockService(accessory);
|
|
@@ -226,15 +234,15 @@ export class Others {
|
|
|
226
234
|
|
|
227
235
|
// Add faucetService
|
|
228
236
|
const faucetService = `${accessory.displayName} Faucet`;
|
|
229
|
-
(this.faucetService = accessory.getService(this.
|
|
230
|
-
|| accessory.addService(this.
|
|
237
|
+
(this.faucetService = accessory.getService(this.hap.Service.Faucet)
|
|
238
|
+
|| accessory.addService(this.hap.Service.Faucet)), faucetService;
|
|
231
239
|
this.debugWarnLog(`${this.device.remoteType}: ${accessory.displayName} Displaying as Faucet`);
|
|
232
240
|
|
|
233
|
-
this.faucetService.setCharacteristic(this.
|
|
234
|
-
if (!this.faucetService.testCharacteristic(this.
|
|
235
|
-
this.faucetService.addCharacteristic(this.
|
|
241
|
+
this.faucetService.setCharacteristic(this.hap.Characteristic.Name, accessory.displayName);
|
|
242
|
+
if (!this.faucetService.testCharacteristic(this.hap.Characteristic.ConfiguredName)) {
|
|
243
|
+
this.faucetService.addCharacteristic(this.hap.Characteristic.ConfiguredName, accessory.displayName);
|
|
236
244
|
}
|
|
237
|
-
this.faucetService.getCharacteristic(this.
|
|
245
|
+
this.faucetService.getCharacteristic(this.hap.Characteristic.Active).onSet(this.OnSet.bind(this));
|
|
238
246
|
} else if (this.otherDeviceType === 'fan') {
|
|
239
247
|
this.removeLockService(accessory);
|
|
240
248
|
this.removeDoorService(accessory);
|
|
@@ -248,15 +256,15 @@ export class Others {
|
|
|
248
256
|
|
|
249
257
|
// Add fanService
|
|
250
258
|
const fanService = `${accessory.displayName} Fan`;
|
|
251
|
-
(this.fanService = accessory.getService(this.
|
|
252
|
-
|| accessory.addService(this.
|
|
259
|
+
(this.fanService = accessory.getService(this.hap.Service.Fan)
|
|
260
|
+
|| accessory.addService(this.hap.Service.Fan)), fanService;
|
|
253
261
|
this.debugWarnLog(`${this.device.remoteType}: ${accessory.displayName} Displaying as Fan`);
|
|
254
262
|
|
|
255
|
-
this.fanService.setCharacteristic(this.
|
|
256
|
-
if (!this.fanService.testCharacteristic(this.
|
|
257
|
-
this.fanService.addCharacteristic(this.
|
|
263
|
+
this.fanService.setCharacteristic(this.hap.Characteristic.Name, accessory.displayName);
|
|
264
|
+
if (!this.fanService.testCharacteristic(this.hap.Characteristic.ConfiguredName)) {
|
|
265
|
+
this.fanService.addCharacteristic(this.hap.Characteristic.ConfiguredName, accessory.displayName);
|
|
258
266
|
}
|
|
259
|
-
this.fanService.getCharacteristic(this.
|
|
267
|
+
this.fanService.getCharacteristic(this.hap.Characteristic.On).onSet(this.OnSet.bind(this));
|
|
260
268
|
} else if (this.otherDeviceType === 'stateful') {
|
|
261
269
|
this.removeFanService(accessory);
|
|
262
270
|
this.removeLockService(accessory);
|
|
@@ -270,16 +278,16 @@ export class Others {
|
|
|
270
278
|
|
|
271
279
|
// Add statefulProgrammableSwitchService
|
|
272
280
|
const statefulProgrammableSwitchService = `${accessory.displayName} Stateful Programmable Switch`;
|
|
273
|
-
(this.statefulProgrammableSwitchService = accessory.getService(this.
|
|
274
|
-
|| accessory.addService(this.
|
|
281
|
+
(this.statefulProgrammableSwitchService = accessory.getService(this.hap.Service.StatefulProgrammableSwitch)
|
|
282
|
+
|| accessory.addService(this.hap.Service.StatefulProgrammableSwitch)), statefulProgrammableSwitchService;
|
|
275
283
|
this.debugWarnLog(`${this.device.remoteType}: ${accessory.displayName} Displaying as Stateful Programmable Switch`);
|
|
276
284
|
|
|
277
|
-
this.statefulProgrammableSwitchService.setCharacteristic(this.
|
|
278
|
-
if (!this.statefulProgrammableSwitchService.testCharacteristic(this.
|
|
279
|
-
this.statefulProgrammableSwitchService.addCharacteristic(this.
|
|
285
|
+
this.statefulProgrammableSwitchService.setCharacteristic(this.hap.Characteristic.Name, accessory.displayName);
|
|
286
|
+
if (!this.statefulProgrammableSwitchService.testCharacteristic(this.hap.Characteristic.ConfiguredName)) {
|
|
287
|
+
this.statefulProgrammableSwitchService.addCharacteristic(this.hap.Characteristic.ConfiguredName, accessory.displayName);
|
|
280
288
|
}
|
|
281
289
|
this.statefulProgrammableSwitchService
|
|
282
|
-
.getCharacteristic(this.
|
|
290
|
+
.getCharacteristic(this.hap.Characteristic.ProgrammableSwitchOutputState)
|
|
283
291
|
.onSet(this.OnSet.bind(this));
|
|
284
292
|
} else {
|
|
285
293
|
this.removeFanService(accessory);
|
|
@@ -294,15 +302,15 @@ export class Others {
|
|
|
294
302
|
|
|
295
303
|
// Add outletService
|
|
296
304
|
const outletService = `${accessory.displayName} Outlet`;
|
|
297
|
-
(this.outletService = accessory.getService(this.
|
|
298
|
-
|| accessory.addService(this.
|
|
305
|
+
(this.outletService = accessory.getService(this.hap.Service.Outlet)
|
|
306
|
+
|| accessory.addService(this.hap.Service.Outlet)), outletService;
|
|
299
307
|
this.debugWarnLog(`${this.device.remoteType}: ${accessory.displayName} Displaying as Outlet`);
|
|
300
308
|
|
|
301
|
-
this.outletService.setCharacteristic(this.
|
|
302
|
-
if (!this.outletService.testCharacteristic(this.
|
|
303
|
-
this.outletService.addCharacteristic(this.
|
|
309
|
+
this.outletService.setCharacteristic(this.hap.Characteristic.Name, accessory.displayName);
|
|
310
|
+
if (!this.outletService.testCharacteristic(this.hap.Characteristic.ConfiguredName)) {
|
|
311
|
+
this.outletService.addCharacteristic(this.hap.Characteristic.ConfiguredName, accessory.displayName);
|
|
304
312
|
}
|
|
305
|
-
this.outletService.getCharacteristic(this.
|
|
313
|
+
this.outletService.getCharacteristic(this.hap.Characteristic.On).onSet(this.OnSet.bind(this));
|
|
306
314
|
}
|
|
307
315
|
}
|
|
308
316
|
|
|
@@ -312,7 +320,7 @@ export class Others {
|
|
|
312
320
|
async OnSet(value: CharacteristicValue): Promise<void> {
|
|
313
321
|
if (this.otherDeviceType === 'garagedoor') {
|
|
314
322
|
this.infoLog(`${this.device.remoteType}: ${this.accessory.displayName} Set TargetDoorState: ${value}`);
|
|
315
|
-
if (value === this.
|
|
323
|
+
if (value === this.hap.Characteristic.TargetDoorState.CLOSED) {
|
|
316
324
|
this.On = false;
|
|
317
325
|
} else {
|
|
318
326
|
this.On = true;
|
|
@@ -330,14 +338,14 @@ export class Others {
|
|
|
330
338
|
}
|
|
331
339
|
} else if (this.otherDeviceType === 'lock') {
|
|
332
340
|
this.infoLog(`${this.device.remoteType}: ${this.accessory.displayName} Set LockTargetState: ${value}`);
|
|
333
|
-
if (value === this.
|
|
341
|
+
if (value === this.hap.Characteristic.LockTargetState.SECURED) {
|
|
334
342
|
this.On = false;
|
|
335
343
|
} else {
|
|
336
344
|
this.On = true;
|
|
337
345
|
}
|
|
338
346
|
} else if (this.otherDeviceType === 'faucet') {
|
|
339
347
|
this.infoLog(`${this.device.remoteType}: ${this.accessory.displayName} Set Active: ${value}`);
|
|
340
|
-
if (value === this.
|
|
348
|
+
if (value === this.hap.Characteristic.Active.INACTIVE) {
|
|
341
349
|
this.On = false;
|
|
342
350
|
} else {
|
|
343
351
|
this.On = true;
|
|
@@ -461,24 +469,24 @@ export class Others {
|
|
|
461
469
|
} else {
|
|
462
470
|
if (this.On) {
|
|
463
471
|
this.garageDoorService?.updateCharacteristic(
|
|
464
|
-
this.
|
|
465
|
-
this.
|
|
472
|
+
this.hap.Characteristic.TargetDoorState,
|
|
473
|
+
this.hap.Characteristic.TargetDoorState.OPEN,
|
|
466
474
|
);
|
|
467
475
|
this.garageDoorService?.updateCharacteristic(
|
|
468
|
-
this.
|
|
469
|
-
this.
|
|
476
|
+
this.hap.Characteristic.CurrentDoorState,
|
|
477
|
+
this.hap.Characteristic.CurrentDoorState.OPEN,
|
|
470
478
|
);
|
|
471
479
|
this.debugLog(
|
|
472
480
|
`${this.device.remoteType}: ` + `${this.accessory.displayName} updateCharacteristic TargetDoorState: Open, CurrentDoorState: Open`,
|
|
473
481
|
);
|
|
474
482
|
} else {
|
|
475
483
|
this.garageDoorService?.updateCharacteristic(
|
|
476
|
-
this.
|
|
477
|
-
this.
|
|
484
|
+
this.hap.Characteristic.TargetDoorState,
|
|
485
|
+
this.hap.Characteristic.TargetDoorState.CLOSED,
|
|
478
486
|
);
|
|
479
487
|
this.garageDoorService?.updateCharacteristic(
|
|
480
|
-
this.
|
|
481
|
-
this.
|
|
488
|
+
this.hap.Characteristic.CurrentDoorState,
|
|
489
|
+
this.hap.Characteristic.CurrentDoorState.CLOSED,
|
|
482
490
|
);
|
|
483
491
|
this.debugLog(
|
|
484
492
|
`${this.device.remoteType}: ` + `${this.accessory.displayName} updateCharacteristic TargetDoorState: Open, CurrentDoorState: Open`,
|
|
@@ -491,14 +499,14 @@ export class Others {
|
|
|
491
499
|
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} On: ${this.On}`);
|
|
492
500
|
} else {
|
|
493
501
|
if (this.On) {
|
|
494
|
-
this.doorService?.updateCharacteristic(this.
|
|
495
|
-
this.doorService?.updateCharacteristic(this.
|
|
496
|
-
this.doorService?.updateCharacteristic(this.
|
|
502
|
+
this.doorService?.updateCharacteristic(this.hap.Characteristic.TargetPosition, 100);
|
|
503
|
+
this.doorService?.updateCharacteristic(this.hap.Characteristic.CurrentPosition, 100);
|
|
504
|
+
this.doorService?.updateCharacteristic(this.hap.Characteristic.PositionState, this.hap.Characteristic.PositionState.STOPPED);
|
|
497
505
|
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} updateCharacteristic TargetPosition: 100, CurrentPosition: 100`);
|
|
498
506
|
} else {
|
|
499
|
-
this.doorService?.updateCharacteristic(this.
|
|
500
|
-
this.doorService?.updateCharacteristic(this.
|
|
501
|
-
this.doorService?.updateCharacteristic(this.
|
|
507
|
+
this.doorService?.updateCharacteristic(this.hap.Characteristic.TargetPosition, 0);
|
|
508
|
+
this.doorService?.updateCharacteristic(this.hap.Characteristic.CurrentPosition, 0);
|
|
509
|
+
this.doorService?.updateCharacteristic(this.hap.Characteristic.PositionState, this.hap.Characteristic.PositionState.STOPPED);
|
|
502
510
|
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} updateCharacteristic TargetPosition: 0, CurrentPosition: 0`);
|
|
503
511
|
}
|
|
504
512
|
}
|
|
@@ -508,14 +516,14 @@ export class Others {
|
|
|
508
516
|
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} On: ${this.On}`);
|
|
509
517
|
} else {
|
|
510
518
|
if (this.On) {
|
|
511
|
-
this.windowService?.updateCharacteristic(this.
|
|
512
|
-
this.windowService?.updateCharacteristic(this.
|
|
513
|
-
this.windowService?.updateCharacteristic(this.
|
|
519
|
+
this.windowService?.updateCharacteristic(this.hap.Characteristic.TargetPosition, 100);
|
|
520
|
+
this.windowService?.updateCharacteristic(this.hap.Characteristic.CurrentPosition, 100);
|
|
521
|
+
this.windowService?.updateCharacteristic(this.hap.Characteristic.PositionState, this.hap.Characteristic.PositionState.STOPPED);
|
|
514
522
|
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} updateCharacteristic TargetPosition: 100, CurrentPosition: 100`);
|
|
515
523
|
} else {
|
|
516
|
-
this.windowService?.updateCharacteristic(this.
|
|
517
|
-
this.windowService?.updateCharacteristic(this.
|
|
518
|
-
this.windowService?.updateCharacteristic(this.
|
|
524
|
+
this.windowService?.updateCharacteristic(this.hap.Characteristic.TargetPosition, 0);
|
|
525
|
+
this.windowService?.updateCharacteristic(this.hap.Characteristic.CurrentPosition, 0);
|
|
526
|
+
this.windowService?.updateCharacteristic(this.hap.Characteristic.PositionState, this.hap.Characteristic.PositionState.STOPPED);
|
|
519
527
|
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} updateCharacteristic TargetPosition: 0, CurrentPosition: 0`);
|
|
520
528
|
}
|
|
521
529
|
}
|
|
@@ -525,19 +533,19 @@ export class Others {
|
|
|
525
533
|
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} On: ${this.On}`);
|
|
526
534
|
} else {
|
|
527
535
|
if (this.On) {
|
|
528
|
-
this.windowCoveringService?.updateCharacteristic(this.
|
|
529
|
-
this.windowCoveringService?.updateCharacteristic(this.
|
|
536
|
+
this.windowCoveringService?.updateCharacteristic(this.hap.Characteristic.TargetPosition, 100);
|
|
537
|
+
this.windowCoveringService?.updateCharacteristic(this.hap.Characteristic.CurrentPosition, 100);
|
|
530
538
|
this.windowCoveringService?.updateCharacteristic(
|
|
531
|
-
this.
|
|
532
|
-
this.
|
|
539
|
+
this.hap.Characteristic.PositionState,
|
|
540
|
+
this.hap.Characteristic.PositionState.STOPPED,
|
|
533
541
|
);
|
|
534
542
|
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} updateCharacteristic TargetPosition: 100, CurrentPosition: 100`);
|
|
535
543
|
} else {
|
|
536
|
-
this.windowCoveringService?.updateCharacteristic(this.
|
|
537
|
-
this.windowCoveringService?.updateCharacteristic(this.
|
|
544
|
+
this.windowCoveringService?.updateCharacteristic(this.hap.Characteristic.TargetPosition, 0);
|
|
545
|
+
this.windowCoveringService?.updateCharacteristic(this.hap.Characteristic.CurrentPosition, 0);
|
|
538
546
|
this.windowCoveringService?.updateCharacteristic(
|
|
539
|
-
this.
|
|
540
|
-
this.
|
|
547
|
+
this.hap.Characteristic.PositionState,
|
|
548
|
+
this.hap.Characteristic.PositionState.STOPPED,
|
|
541
549
|
);
|
|
542
550
|
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} updateCharacteristic TargetPosition: 0, CurrentPosition: 0`);
|
|
543
551
|
}
|
|
@@ -549,22 +557,22 @@ export class Others {
|
|
|
549
557
|
} else {
|
|
550
558
|
if (this.On) {
|
|
551
559
|
this.lockService?.updateCharacteristic(
|
|
552
|
-
this.
|
|
553
|
-
this.
|
|
560
|
+
this.hap.Characteristic.LockTargetState,
|
|
561
|
+
this.hap.Characteristic.LockTargetState.UNSECURED,
|
|
554
562
|
);
|
|
555
563
|
this.lockService?.updateCharacteristic(
|
|
556
|
-
this.
|
|
557
|
-
this.
|
|
564
|
+
this.hap.Characteristic.LockCurrentState,
|
|
565
|
+
this.hap.Characteristic.LockCurrentState.UNSECURED,
|
|
558
566
|
);
|
|
559
567
|
this.debugLog(
|
|
560
568
|
`${this.device.remoteType}: ` +
|
|
561
569
|
`${this.accessory.displayName} updateCharacteristic LockTargetState: UNSECURED, LockCurrentState: UNSECURED`,
|
|
562
570
|
);
|
|
563
571
|
} else {
|
|
564
|
-
this.lockService?.updateCharacteristic(this.
|
|
572
|
+
this.lockService?.updateCharacteristic(this.hap.Characteristic.LockTargetState, this.hap.Characteristic.LockTargetState.SECURED);
|
|
565
573
|
this.lockService?.updateCharacteristic(
|
|
566
|
-
this.
|
|
567
|
-
this.
|
|
574
|
+
this.hap.Characteristic.LockCurrentState,
|
|
575
|
+
this.hap.Characteristic.LockCurrentState.SECURED,
|
|
568
576
|
);
|
|
569
577
|
this.debugLog(
|
|
570
578
|
`${this.device.remoteType}: ` + `${this.accessory.displayName} updateCharacteristic LockTargetState: SECURED, LockCurrentState: SECURED`,
|
|
@@ -577,10 +585,10 @@ export class Others {
|
|
|
577
585
|
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} On: ${this.On}`);
|
|
578
586
|
} else {
|
|
579
587
|
if (this.On) {
|
|
580
|
-
this.faucetService?.updateCharacteristic(this.
|
|
588
|
+
this.faucetService?.updateCharacteristic(this.hap.Characteristic.Active, this.hap.Characteristic.Active.ACTIVE);
|
|
581
589
|
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} updateCharacteristic Active: ${this.On}`);
|
|
582
590
|
} else {
|
|
583
|
-
this.faucetService?.updateCharacteristic(this.
|
|
591
|
+
this.faucetService?.updateCharacteristic(this.hap.Characteristic.Active, this.hap.Characteristic.Active.INACTIVE);
|
|
584
592
|
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} updateCharacteristic Active: ${this.On}`);
|
|
585
593
|
}
|
|
586
594
|
}
|
|
@@ -590,10 +598,10 @@ export class Others {
|
|
|
590
598
|
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} On: ${this.On}`);
|
|
591
599
|
} else {
|
|
592
600
|
if (this.On) {
|
|
593
|
-
this.fanService?.updateCharacteristic(this.
|
|
601
|
+
this.fanService?.updateCharacteristic(this.hap.Characteristic.On, this.On);
|
|
594
602
|
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} updateCharacteristic On: ${this.On}`);
|
|
595
603
|
} else {
|
|
596
|
-
this.fanService?.updateCharacteristic(this.
|
|
604
|
+
this.fanService?.updateCharacteristic(this.hap.Characteristic.On, this.On);
|
|
597
605
|
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} updateCharacteristic On: ${this.On}`);
|
|
598
606
|
}
|
|
599
607
|
}
|
|
@@ -604,20 +612,20 @@ export class Others {
|
|
|
604
612
|
} else {
|
|
605
613
|
if (this.On) {
|
|
606
614
|
this.statefulProgrammableSwitchService?.updateCharacteristic(
|
|
607
|
-
this.
|
|
608
|
-
this.
|
|
615
|
+
this.hap.Characteristic.ProgrammableSwitchEvent,
|
|
616
|
+
this.hap.Characteristic.ProgrammableSwitchEvent.SINGLE_PRESS,
|
|
609
617
|
);
|
|
610
|
-
this.statefulProgrammableSwitchService?.updateCharacteristic(this.
|
|
618
|
+
this.statefulProgrammableSwitchService?.updateCharacteristic(this.hap.Characteristic.ProgrammableSwitchOutputState, 1);
|
|
611
619
|
this.debugLog(
|
|
612
620
|
`${this.device.remoteType}: ` +
|
|
613
621
|
`${this.accessory.displayName} updateCharacteristic ProgrammableSwitchEvent: SINGLE, ProgrammableSwitchOutputState: 1`,
|
|
614
622
|
);
|
|
615
623
|
} else {
|
|
616
624
|
this.statefulProgrammableSwitchService?.updateCharacteristic(
|
|
617
|
-
this.
|
|
618
|
-
this.
|
|
625
|
+
this.hap.Characteristic.ProgrammableSwitchEvent,
|
|
626
|
+
this.hap.Characteristic.ProgrammableSwitchEvent.SINGLE_PRESS,
|
|
619
627
|
);
|
|
620
|
-
this.statefulProgrammableSwitchService?.updateCharacteristic(this.
|
|
628
|
+
this.statefulProgrammableSwitchService?.updateCharacteristic(this.hap.Characteristic.ProgrammableSwitchOutputState, 0);
|
|
621
629
|
this.debugLog(
|
|
622
630
|
`${this.device.remoteType}: ` +
|
|
623
631
|
`${this.accessory.displayName} updateCharacteristic ProgrammableSwitchEvent: SINGLE, ProgrammableSwitchOutputState: 0`,
|
|
@@ -629,14 +637,14 @@ export class Others {
|
|
|
629
637
|
if (this.On === undefined) {
|
|
630
638
|
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} On: ${this.On}`);
|
|
631
639
|
} else {
|
|
632
|
-
this.switchService?.updateCharacteristic(this.
|
|
640
|
+
this.switchService?.updateCharacteristic(this.hap.Characteristic.On, this.On);
|
|
633
641
|
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} updateCharacteristic On: ${this.On}`);
|
|
634
642
|
}
|
|
635
643
|
} else {
|
|
636
644
|
if (this.On === undefined) {
|
|
637
645
|
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} On: ${this.On}`);
|
|
638
646
|
} else {
|
|
639
|
-
this.outletService?.updateCharacteristic(this.
|
|
647
|
+
this.outletService?.updateCharacteristic(this.hap.Characteristic.On, this.On);
|
|
640
648
|
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} updateCharacteristic On: ${this.On}`);
|
|
641
649
|
}
|
|
642
650
|
}
|
|
@@ -732,41 +740,41 @@ export class Others {
|
|
|
732
740
|
|
|
733
741
|
async apiError(e: any): Promise<void> {
|
|
734
742
|
if (this.otherDeviceType === 'garagedoor') {
|
|
735
|
-
this.garageDoorService?.updateCharacteristic(this.
|
|
736
|
-
this.garageDoorService?.updateCharacteristic(this.
|
|
737
|
-
this.garageDoorService?.updateCharacteristic(this.
|
|
743
|
+
this.garageDoorService?.updateCharacteristic(this.hap.Characteristic.TargetDoorState, e);
|
|
744
|
+
this.garageDoorService?.updateCharacteristic(this.hap.Characteristic.CurrentDoorState, e);
|
|
745
|
+
this.garageDoorService?.updateCharacteristic(this.hap.Characteristic.ObstructionDetected, e);
|
|
738
746
|
} else if (this.otherDeviceType === 'door') {
|
|
739
|
-
this.doorService?.updateCharacteristic(this.
|
|
740
|
-
this.doorService?.updateCharacteristic(this.
|
|
741
|
-
this.doorService?.updateCharacteristic(this.
|
|
747
|
+
this.doorService?.updateCharacteristic(this.hap.Characteristic.TargetPosition, e);
|
|
748
|
+
this.doorService?.updateCharacteristic(this.hap.Characteristic.CurrentPosition, e);
|
|
749
|
+
this.doorService?.updateCharacteristic(this.hap.Characteristic.PositionState, e);
|
|
742
750
|
} else if (this.otherDeviceType === 'window') {
|
|
743
|
-
this.windowService?.updateCharacteristic(this.
|
|
744
|
-
this.windowService?.updateCharacteristic(this.
|
|
745
|
-
this.windowService?.updateCharacteristic(this.
|
|
751
|
+
this.windowService?.updateCharacteristic(this.hap.Characteristic.TargetPosition, e);
|
|
752
|
+
this.windowService?.updateCharacteristic(this.hap.Characteristic.CurrentPosition, e);
|
|
753
|
+
this.windowService?.updateCharacteristic(this.hap.Characteristic.PositionState, e);
|
|
746
754
|
} else if (this.otherDeviceType === 'windowcovering') {
|
|
747
|
-
this.windowCoveringService?.updateCharacteristic(this.
|
|
748
|
-
this.windowCoveringService?.updateCharacteristic(this.
|
|
749
|
-
this.windowCoveringService?.updateCharacteristic(this.
|
|
755
|
+
this.windowCoveringService?.updateCharacteristic(this.hap.Characteristic.TargetPosition, e);
|
|
756
|
+
this.windowCoveringService?.updateCharacteristic(this.hap.Characteristic.CurrentPosition, e);
|
|
757
|
+
this.windowCoveringService?.updateCharacteristic(this.hap.Characteristic.PositionState, e);
|
|
750
758
|
} else if (this.otherDeviceType === 'lock') {
|
|
751
|
-
this.doorService?.updateCharacteristic(this.
|
|
752
|
-
this.doorService?.updateCharacteristic(this.
|
|
759
|
+
this.doorService?.updateCharacteristic(this.hap.Characteristic.LockTargetState, e);
|
|
760
|
+
this.doorService?.updateCharacteristic(this.hap.Characteristic.LockCurrentState, e);
|
|
753
761
|
} else if (this.otherDeviceType === 'faucet') {
|
|
754
|
-
this.faucetService?.updateCharacteristic(this.
|
|
762
|
+
this.faucetService?.updateCharacteristic(this.hap.Characteristic.Active, e);
|
|
755
763
|
} else if (this.otherDeviceType === 'fan') {
|
|
756
|
-
this.fanService?.updateCharacteristic(this.
|
|
764
|
+
this.fanService?.updateCharacteristic(this.hap.Characteristic.On, e);
|
|
757
765
|
} else if (this.otherDeviceType === 'stateful') {
|
|
758
|
-
this.statefulProgrammableSwitchService?.updateCharacteristic(this.
|
|
759
|
-
this.statefulProgrammableSwitchService?.updateCharacteristic(this.
|
|
766
|
+
this.statefulProgrammableSwitchService?.updateCharacteristic(this.hap.Characteristic.ProgrammableSwitchEvent, e);
|
|
767
|
+
this.statefulProgrammableSwitchService?.updateCharacteristic(this.hap.Characteristic.ProgrammableSwitchOutputState, e);
|
|
760
768
|
} else if (this.otherDeviceType === 'switch') {
|
|
761
|
-
this.switchService?.updateCharacteristic(this.
|
|
769
|
+
this.switchService?.updateCharacteristic(this.hap.Characteristic.On, e);
|
|
762
770
|
} else {
|
|
763
|
-
this.outletService?.updateCharacteristic(this.
|
|
771
|
+
this.outletService?.updateCharacteristic(this.hap.Characteristic.On, e);
|
|
764
772
|
}
|
|
765
773
|
}
|
|
766
774
|
|
|
767
775
|
async removeOutletService(accessory: PlatformAccessory): Promise<void> {
|
|
768
776
|
// If outletService still pressent, then remove first
|
|
769
|
-
this.outletService = this.accessory.getService(this.
|
|
777
|
+
this.outletService = this.accessory.getService(this.hap.Service.Outlet);
|
|
770
778
|
if (this.outletService) {
|
|
771
779
|
this.warnLog(`${this.device.remoteType}: ${accessory.displayName} Removing Leftover Outlet Service`);
|
|
772
780
|
}
|
|
@@ -775,7 +783,7 @@ export class Others {
|
|
|
775
783
|
|
|
776
784
|
async removeGarageDoorService(accessory: PlatformAccessory): Promise<void> {
|
|
777
785
|
// If garageDoorService still pressent, then remove first
|
|
778
|
-
this.garageDoorService = this.accessory.getService(this.
|
|
786
|
+
this.garageDoorService = this.accessory.getService(this.hap.Service.GarageDoorOpener);
|
|
779
787
|
if (this.garageDoorService) {
|
|
780
788
|
this.warnLog(`${this.device.remoteType}: ${accessory.displayName} Removing Leftover Garage Door Service`);
|
|
781
789
|
}
|
|
@@ -784,7 +792,7 @@ export class Others {
|
|
|
784
792
|
|
|
785
793
|
async removeDoorService(accessory: PlatformAccessory): Promise<void> {
|
|
786
794
|
// If doorService still pressent, then remove first
|
|
787
|
-
this.doorService = this.accessory.getService(this.
|
|
795
|
+
this.doorService = this.accessory.getService(this.hap.Service.Door);
|
|
788
796
|
if (this.doorService) {
|
|
789
797
|
this.warnLog(`${this.device.remoteType}: ${accessory.displayName} Removing Leftover Door Service`);
|
|
790
798
|
}
|
|
@@ -793,7 +801,7 @@ export class Others {
|
|
|
793
801
|
|
|
794
802
|
async removeLockService(accessory: PlatformAccessory): Promise<void> {
|
|
795
803
|
// If lockService still pressent, then remove first
|
|
796
|
-
this.lockService = this.accessory.getService(this.
|
|
804
|
+
this.lockService = this.accessory.getService(this.hap.Service.LockMechanism);
|
|
797
805
|
if (this.lockService) {
|
|
798
806
|
this.warnLog(`${this.device.remoteType}: ${accessory.displayName} Removing Leftover Lock Service`);
|
|
799
807
|
}
|
|
@@ -802,7 +810,7 @@ export class Others {
|
|
|
802
810
|
|
|
803
811
|
async removeFaucetService(accessory: PlatformAccessory): Promise<void> {
|
|
804
812
|
// If faucetService still pressent, then remove first
|
|
805
|
-
this.faucetService = this.accessory.getService(this.
|
|
813
|
+
this.faucetService = this.accessory.getService(this.hap.Service.Faucet);
|
|
806
814
|
if (this.faucetService) {
|
|
807
815
|
this.warnLog(`${this.device.remoteType}: ${accessory.displayName} Removing Leftover Faucet Service`);
|
|
808
816
|
}
|
|
@@ -811,7 +819,7 @@ export class Others {
|
|
|
811
819
|
|
|
812
820
|
async removeFanService(accessory: PlatformAccessory): Promise<void> {
|
|
813
821
|
// If fanService still pressent, then remove first
|
|
814
|
-
this.fanService = this.accessory.getService(this.
|
|
822
|
+
this.fanService = this.accessory.getService(this.hap.Service.Fan);
|
|
815
823
|
if (this.fanService) {
|
|
816
824
|
this.warnLog(`${this.device.remoteType}: ${accessory.displayName} Removing Leftover Fan Service`);
|
|
817
825
|
}
|
|
@@ -820,7 +828,7 @@ export class Others {
|
|
|
820
828
|
|
|
821
829
|
async removeWindowService(accessory: PlatformAccessory): Promise<void> {
|
|
822
830
|
// If windowService still pressent, then remove first
|
|
823
|
-
this.windowService = this.accessory.getService(this.
|
|
831
|
+
this.windowService = this.accessory.getService(this.hap.Service.Window);
|
|
824
832
|
if (this.windowService) {
|
|
825
833
|
this.warnLog(`${this.device.remoteType}: ${accessory.displayName} Removing Leftover Window Service`);
|
|
826
834
|
}
|
|
@@ -829,7 +837,7 @@ export class Others {
|
|
|
829
837
|
|
|
830
838
|
async removeWindowCoveringService(accessory: PlatformAccessory): Promise<void> {
|
|
831
839
|
// If windowCoveringService still pressent, then remove first
|
|
832
|
-
this.windowCoveringService = this.accessory.getService(this.
|
|
840
|
+
this.windowCoveringService = this.accessory.getService(this.hap.Service.WindowCovering);
|
|
833
841
|
if (this.windowCoveringService) {
|
|
834
842
|
this.warnLog(`${this.device.remoteType}: ${accessory.displayName} Removing Leftover Window Covering Service`);
|
|
835
843
|
}
|
|
@@ -838,7 +846,7 @@ export class Others {
|
|
|
838
846
|
|
|
839
847
|
async removeStatefulProgrammableSwitchService(accessory: PlatformAccessory): Promise<void> {
|
|
840
848
|
// If statefulProgrammableSwitchService still pressent, then remove first
|
|
841
|
-
this.statefulProgrammableSwitchService = this.accessory.getService(this.
|
|
849
|
+
this.statefulProgrammableSwitchService = this.accessory.getService(this.hap.Service.StatefulProgrammableSwitch);
|
|
842
850
|
if (this.statefulProgrammableSwitchService) {
|
|
843
851
|
this.warnLog(`${this.device.remoteType}: ${accessory.displayName} Removing Leftover Stateful Programmable Switch Service`);
|
|
844
852
|
}
|
|
@@ -847,7 +855,7 @@ export class Others {
|
|
|
847
855
|
|
|
848
856
|
async removeSwitchService(accessory: PlatformAccessory): Promise<void> {
|
|
849
857
|
// If switchService still pressent, then remove first
|
|
850
|
-
this.switchService = this.accessory.getService(this.
|
|
858
|
+
this.switchService = this.accessory.getService(this.hap.Service.Switch);
|
|
851
859
|
if (this.switchService) {
|
|
852
860
|
this.warnLog(`${this.device.remoteType}: ${accessory.displayName} Removing Leftover Switch Service`);
|
|
853
861
|
}
|
|
@@ -881,7 +889,7 @@ export class Others {
|
|
|
881
889
|
}
|
|
882
890
|
}
|
|
883
891
|
|
|
884
|
-
async
|
|
892
|
+
async deviceConfig(device: irdevice & irDevicesConfig): Promise<void> {
|
|
885
893
|
let config = {};
|
|
886
894
|
if (device.other) {
|
|
887
895
|
config = device.other;
|
|
@@ -915,7 +923,7 @@ export class Others {
|
|
|
915
923
|
}
|
|
916
924
|
}
|
|
917
925
|
|
|
918
|
-
async
|
|
926
|
+
async deviceLogs(device: irdevice & irDevicesConfig): Promise<void> {
|
|
919
927
|
if (this.platform.debugMode) {
|
|
920
928
|
this.deviceLogging = this.accessory.context.logging = 'debugMode';
|
|
921
929
|
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Using Debug Mode Logging: ${this.deviceLogging}`);
|