@switchbot/homebridge-switchbot 3.5.0-beta.62 → 3.5.0-beta.63
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/dist/device/blindtilt.d.ts.map +1 -1
- package/dist/device/blindtilt.js +4 -2
- package/dist/device/blindtilt.js.map +1 -1
- package/dist/device/bot.d.ts.map +1 -1
- package/dist/device/bot.js +2 -1
- package/dist/device/bot.js.map +1 -1
- package/dist/device/colorbulb.d.ts.map +1 -1
- package/dist/device/colorbulb.js +3 -1
- package/dist/device/colorbulb.js.map +1 -1
- package/dist/device/curtain.d.ts.map +1 -1
- package/dist/device/curtain.js +11 -8
- package/dist/device/curtain.js.map +1 -1
- package/dist/device/motion.js +1 -1
- package/dist/device/motion.js.map +1 -1
- package/dist/device/waterdetector.js +4 -4
- package/dist/device/waterdetector.js.map +1 -1
- package/dist/irdevice/airconditioner.d.ts +1 -1
- package/dist/irdevice/airconditioner.d.ts.map +1 -1
- package/dist/irdevice/airconditioner.js +65 -83
- package/dist/irdevice/airconditioner.js.map +1 -1
- package/dist/irdevice/airpurifier.d.ts.map +1 -1
- package/dist/irdevice/airpurifier.js +39 -17
- package/dist/irdevice/airpurifier.js.map +1 -1
- package/dist/irdevice/camera.d.ts.map +1 -1
- package/dist/irdevice/camera.js +14 -10
- package/dist/irdevice/camera.js.map +1 -1
- package/dist/irdevice/fan.d.ts.map +1 -1
- package/dist/irdevice/fan.js +27 -14
- package/dist/irdevice/fan.js.map +1 -1
- package/dist/irdevice/light.d.ts.map +1 -1
- package/dist/irdevice/light.js +55 -23
- package/dist/irdevice/light.js.map +1 -1
- package/dist/irdevice/other.d.ts +1 -1
- package/dist/irdevice/other.d.ts.map +1 -1
- package/dist/irdevice/other.js +198 -135
- package/dist/irdevice/other.js.map +1 -1
- package/dist/irdevice/tv.d.ts.map +1 -1
- package/dist/irdevice/tv.js +54 -59
- package/dist/irdevice/tv.js.map +1 -1
- package/dist/irdevice/vacuumcleaner.d.ts.map +1 -1
- package/dist/irdevice/vacuumcleaner.js +15 -10
- package/dist/irdevice/vacuumcleaner.js.map +1 -1
- package/dist/irdevice/waterheater.d.ts.map +1 -1
- package/dist/irdevice/waterheater.js +16 -13
- package/dist/irdevice/waterheater.js.map +1 -1
- package/package.json +1 -1
- package/src/device/blindtilt.ts +4 -2
- package/src/device/bot.ts +2 -1
- package/src/device/colorbulb.ts +3 -2
- package/src/device/curtain.ts +11 -8
- package/src/device/motion.ts +1 -1
- package/src/device/waterdetector.ts +4 -4
- package/src/irdevice/airconditioner.ts +73 -85
- package/src/irdevice/airpurifier.ts +46 -21
- package/src/irdevice/camera.ts +15 -12
- package/src/irdevice/fan.ts +29 -17
- package/src/irdevice/light.ts +70 -42
- package/src/irdevice/other.ts +230 -153
- package/src/irdevice/tv.ts +61 -70
- package/src/irdevice/vacuumcleaner.ts +16 -12
- package/src/irdevice/waterheater.ts +17 -16
package/dist/irdevice/other.js
CHANGED
|
@@ -18,7 +18,7 @@ export class Others extends irdeviceBase {
|
|
|
18
18
|
Door;
|
|
19
19
|
Window;
|
|
20
20
|
WindowCovering;
|
|
21
|
-
|
|
21
|
+
LockMechanism;
|
|
22
22
|
Faucet;
|
|
23
23
|
Fan;
|
|
24
24
|
StatefulProgrammableSwitch;
|
|
@@ -32,11 +32,25 @@ export class Others extends irdeviceBase {
|
|
|
32
32
|
this.getOtherConfigSettings(device);
|
|
33
33
|
// deviceType
|
|
34
34
|
if (this.otherDeviceType === 'switch') {
|
|
35
|
-
// Initialize Switch
|
|
35
|
+
// Initialize Switch Service
|
|
36
|
+
if (!accessory.context.Switch) {
|
|
37
|
+
accessory.context.Switch = {};
|
|
38
|
+
}
|
|
36
39
|
this.Switch = {
|
|
37
|
-
|
|
38
|
-
|
|
40
|
+
Name: accessory.context.Name ?? `${accessory.displayName} Switch`,
|
|
41
|
+
Service: accessory.getService(this.hap.Service.Switch) ?? accessory.addService(this.hap.Service.Switch),
|
|
42
|
+
On: accessory.context.On ?? false,
|
|
39
43
|
};
|
|
44
|
+
this.debugWarnLog(`${this.device.remoteType}: ${accessory.displayName} Displaying as Switch`);
|
|
45
|
+
this.Switch.Service
|
|
46
|
+
.setCharacteristic(this.hap.Characteristic.Name, accessory.displayName)
|
|
47
|
+
.getCharacteristic(this.hap.Characteristic.On)
|
|
48
|
+
.onGet(() => {
|
|
49
|
+
return this.Switch.On;
|
|
50
|
+
})
|
|
51
|
+
.onSet(this.OnSet.bind(this));
|
|
52
|
+
accessory.context.Name = this.Switch.Name;
|
|
53
|
+
// Remove other services
|
|
40
54
|
this.removeFanService(accessory);
|
|
41
55
|
this.removeLockService(accessory);
|
|
42
56
|
this.removeDoorService(accessory);
|
|
@@ -46,20 +60,28 @@ export class Others extends irdeviceBase {
|
|
|
46
60
|
this.removeGarageDoorService(accessory);
|
|
47
61
|
this.removeWindowCoveringService(accessory);
|
|
48
62
|
this.removeStatefulProgrammableSwitchService(accessory);
|
|
49
|
-
// Add Switch Service
|
|
50
|
-
const SwitchService = `${accessory.displayName} Switch`;
|
|
51
|
-
(this.Switch.Service = accessory.getService(this.hap.Service.Switch)
|
|
52
|
-
|| accessory.addService(this.hap.Service.Switch)), SwitchService;
|
|
53
|
-
this.debugWarnLog(`${this.device.remoteType}: ${accessory.displayName} Displaying as Switch`);
|
|
54
|
-
this.Switch.Service.setCharacteristic(this.hap.Characteristic.Name, accessory.displayName);
|
|
55
|
-
this.Switch.Service.getCharacteristic(this.hap.Characteristic.On).onSet(this.OnSet.bind(this));
|
|
56
63
|
}
|
|
57
64
|
else if (this.otherDeviceType === 'garagedoor') {
|
|
58
|
-
// Initialize Garage Door
|
|
65
|
+
// Initialize Garage Door Service
|
|
66
|
+
if (!accessory.context.GarageDoor) {
|
|
67
|
+
accessory.context.GarageDoor = {};
|
|
68
|
+
}
|
|
59
69
|
this.GarageDoor = {
|
|
60
|
-
|
|
61
|
-
|
|
70
|
+
Name: accessory.context.Name ?? `${accessory.displayName} Garage Door`,
|
|
71
|
+
Service: accessory.getService(this.hap.Service.GarageDoorOpener) ?? accessory.addService(this.hap.Service.GarageDoorOpener),
|
|
72
|
+
On: accessory.context.On ?? false,
|
|
62
73
|
};
|
|
74
|
+
this.debugWarnLog(`${this.device.remoteType}: ${accessory.displayName} Displaying as Garage Door Opener`);
|
|
75
|
+
this.GarageDoor.Service
|
|
76
|
+
.setCharacteristic(this.hap.Characteristic.Name, accessory.displayName)
|
|
77
|
+
.setCharacteristic(this.hap.Characteristic.ObstructionDetected, false)
|
|
78
|
+
.getCharacteristic(this.hap.Characteristic.TargetDoorState)
|
|
79
|
+
.onGet(() => {
|
|
80
|
+
return this.GarageDoor.On;
|
|
81
|
+
})
|
|
82
|
+
.onSet(this.OnSet.bind(this));
|
|
83
|
+
accessory.context.Name = this.GarageDoor.Name;
|
|
84
|
+
// Remove other services
|
|
63
85
|
this.removeFanService(accessory);
|
|
64
86
|
this.removeLockService(accessory);
|
|
65
87
|
this.removeDoorService(accessory);
|
|
@@ -69,98 +91,90 @@ export class Others extends irdeviceBase {
|
|
|
69
91
|
this.removeWindowService(accessory);
|
|
70
92
|
this.removeWindowCoveringService(accessory);
|
|
71
93
|
this.removeStatefulProgrammableSwitchService(accessory);
|
|
72
|
-
// Add GarageDoor Service
|
|
73
|
-
const GarageDoorService = `${accessory.displayName} Garage Door Opener`;
|
|
74
|
-
(this.GarageDoor.Service = accessory.getService(this.hap.Service.GarageDoorOpener)
|
|
75
|
-
|| accessory.addService(this.hap.Service.GarageDoorOpener)), GarageDoorService;
|
|
76
|
-
this.debugWarnLog(`${this.device.remoteType}: ${accessory.displayName} Displaying as Garage Door Opener`);
|
|
77
|
-
this.GarageDoor.Service.setCharacteristic(this.hap.Characteristic.Name, accessory.displayName);
|
|
78
|
-
this.GarageDoor.Service.getCharacteristic(this.hap.Characteristic.TargetDoorState).onSet(this.OnSet.bind(this));
|
|
79
|
-
this.GarageDoor.Service.setCharacteristic(this.hap.Characteristic.ObstructionDetected, false);
|
|
80
94
|
}
|
|
81
95
|
else if (this.otherDeviceType === 'door') {
|
|
82
|
-
// Initialize Door
|
|
96
|
+
// Initialize Door Service
|
|
97
|
+
if (!accessory.context.Door) {
|
|
98
|
+
accessory.context.Door = {};
|
|
99
|
+
}
|
|
83
100
|
this.Door = {
|
|
84
|
-
|
|
85
|
-
|
|
101
|
+
Name: accessory.context.Name ?? `${accessory.displayName} Door`,
|
|
102
|
+
Service: accessory.getService(this.hap.Service.Door) ?? accessory.addService(this.hap.Service.Door),
|
|
103
|
+
On: accessory.context.On ?? false,
|
|
86
104
|
};
|
|
87
|
-
this.removeFanService(accessory);
|
|
88
|
-
this.removeLockService(accessory);
|
|
89
|
-
this.removeOutletService(accessory);
|
|
90
|
-
this.removeFaucetService(accessory);
|
|
91
|
-
this.removeSwitchService(accessory);
|
|
92
|
-
this.removeWindowService(accessory);
|
|
93
|
-
this.removeGarageDoorService(accessory);
|
|
94
|
-
this.removeWindowCoveringService(accessory);
|
|
95
|
-
this.removeStatefulProgrammableSwitchService(accessory);
|
|
96
|
-
// Add Door Service
|
|
97
|
-
const DoorService = `${accessory.displayName} Door`;
|
|
98
|
-
(this.Door.Service = accessory.getService(this.hap.Service.Door)
|
|
99
|
-
|| accessory.addService(this.hap.Service.Door)), DoorService;
|
|
100
105
|
this.debugWarnLog(`${this.device.remoteType}: ${accessory.displayName} Displaying as Door`);
|
|
101
|
-
this.Door.Service.setCharacteristic(this.hap.Characteristic.Name, accessory.displayName);
|
|
102
106
|
this.Door.Service
|
|
107
|
+
.setCharacteristic(this.hap.Characteristic.Name, accessory.displayName)
|
|
108
|
+
.setCharacteristic(this.hap.Characteristic.PositionState, this.hap.Characteristic.PositionState.STOPPED)
|
|
103
109
|
.getCharacteristic(this.hap.Characteristic.TargetPosition)
|
|
104
110
|
.setProps({
|
|
105
111
|
validValues: [0, 100],
|
|
106
112
|
minValue: 0,
|
|
107
113
|
maxValue: 100,
|
|
108
114
|
minStep: 100,
|
|
115
|
+
})
|
|
116
|
+
.onGet(() => {
|
|
117
|
+
return this.GarageDoor.On;
|
|
109
118
|
})
|
|
110
119
|
.onSet(this.OnSet.bind(this));
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
else if (this.otherDeviceType === 'window') {
|
|
114
|
-
// Initialize Window property
|
|
115
|
-
this.Window = {
|
|
116
|
-
Service: accessory.getService(this.hap.Service.Window),
|
|
117
|
-
On: accessory.context.On || false,
|
|
118
|
-
};
|
|
120
|
+
accessory.context.Name = this.Door.Name;
|
|
121
|
+
// Remove other services
|
|
119
122
|
this.removeFanService(accessory);
|
|
120
123
|
this.removeLockService(accessory);
|
|
121
|
-
this.removeDoorService(accessory);
|
|
122
124
|
this.removeOutletService(accessory);
|
|
123
125
|
this.removeFaucetService(accessory);
|
|
124
126
|
this.removeSwitchService(accessory);
|
|
127
|
+
this.removeWindowService(accessory);
|
|
125
128
|
this.removeGarageDoorService(accessory);
|
|
126
129
|
this.removeWindowCoveringService(accessory);
|
|
127
130
|
this.removeStatefulProgrammableSwitchService(accessory);
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
131
|
+
}
|
|
132
|
+
else if (this.otherDeviceType === 'window') {
|
|
133
|
+
// Initialize Window Service
|
|
134
|
+
if (!accessory.context.Window) {
|
|
135
|
+
accessory.context.Window = {};
|
|
136
|
+
}
|
|
137
|
+
this.Window = {
|
|
138
|
+
Name: accessory.context.Name ?? `${accessory.displayName} Window`,
|
|
139
|
+
Service: accessory.getService(this.hap.Service.Window) ?? accessory.addService(this.hap.Service.Window),
|
|
140
|
+
On: accessory.context.On ?? false,
|
|
141
|
+
};
|
|
132
142
|
this.debugWarnLog(`${this.device.remoteType}: ${accessory.displayName} Displaying as Window`);
|
|
133
|
-
this.Window.Service.setCharacteristic(this.hap.Characteristic.Name, accessory.displayName)
|
|
134
|
-
|
|
143
|
+
this.Window.Service.setCharacteristic(this.hap.Characteristic.Name, accessory.displayName)
|
|
144
|
+
.setCharacteristic(this.hap.Characteristic.PositionState, this.hap.Characteristic.PositionState.STOPPED)
|
|
135
145
|
.getCharacteristic(this.hap.Characteristic.TargetPosition)
|
|
136
146
|
.setProps({
|
|
137
147
|
validValues: [0, 100],
|
|
138
148
|
minValue: 0,
|
|
139
149
|
maxValue: 100,
|
|
140
150
|
minStep: 100,
|
|
151
|
+
})
|
|
152
|
+
.onGet(() => {
|
|
153
|
+
return this.GarageDoor.On;
|
|
141
154
|
})
|
|
142
155
|
.onSet(this.OnSet.bind(this));
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
else if (this.otherDeviceType === 'windowcovering') {
|
|
146
|
-
// Initialize WindowCovering property
|
|
147
|
-
this.WindowCovering = {
|
|
148
|
-
Service: accessory.getService(this.hap.Service.WindowCovering),
|
|
149
|
-
On: accessory.context.On || false,
|
|
150
|
-
};
|
|
156
|
+
accessory.context.Name = this.Window.Name;
|
|
157
|
+
// Remove other services
|
|
151
158
|
this.removeFanService(accessory);
|
|
152
159
|
this.removeLockService(accessory);
|
|
153
160
|
this.removeDoorService(accessory);
|
|
154
161
|
this.removeOutletService(accessory);
|
|
155
162
|
this.removeFaucetService(accessory);
|
|
156
163
|
this.removeSwitchService(accessory);
|
|
157
|
-
this.removeWindowService(accessory);
|
|
158
164
|
this.removeGarageDoorService(accessory);
|
|
165
|
+
this.removeWindowCoveringService(accessory);
|
|
159
166
|
this.removeStatefulProgrammableSwitchService(accessory);
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
167
|
+
}
|
|
168
|
+
else if (this.otherDeviceType === 'windowcovering') {
|
|
169
|
+
// Initialize WindowCovering Service
|
|
170
|
+
if (!accessory.context.WindowCovering) {
|
|
171
|
+
accessory.context.WindowCovering = {};
|
|
172
|
+
}
|
|
173
|
+
this.WindowCovering = {
|
|
174
|
+
Name: accessory.context.Name ?? `${accessory.displayName} Window Covering`,
|
|
175
|
+
Service: accessory.getService(this.hap.Service.WindowCovering) ?? accessory.addService(this.hap.Service.WindowCovering),
|
|
176
|
+
On: accessory.context.On ?? false,
|
|
177
|
+
};
|
|
164
178
|
this.debugWarnLog(`${this.device.remoteType}: ${accessory.displayName} Displaying as Window Covering`);
|
|
165
179
|
this.WindowCovering.Service.setCharacteristic(this.hap.Characteristic.Name, accessory.displayName);
|
|
166
180
|
this.WindowCovering.Service
|
|
@@ -170,16 +184,44 @@ export class Others extends irdeviceBase {
|
|
|
170
184
|
minValue: 0,
|
|
171
185
|
maxValue: 100,
|
|
172
186
|
minStep: 100,
|
|
187
|
+
})
|
|
188
|
+
.onGet(() => {
|
|
189
|
+
return this.WindowCovering.On;
|
|
173
190
|
})
|
|
174
191
|
.onSet(this.OnSet.bind(this));
|
|
175
192
|
this.WindowCovering.Service.setCharacteristic(this.hap.Characteristic.PositionState, this.hap.Characteristic.PositionState.STOPPED);
|
|
193
|
+
accessory.context.Name = this.WindowCovering.Name;
|
|
194
|
+
// Remove other services
|
|
195
|
+
this.removeFanService(accessory);
|
|
196
|
+
this.removeLockService(accessory);
|
|
197
|
+
this.removeDoorService(accessory);
|
|
198
|
+
this.removeOutletService(accessory);
|
|
199
|
+
this.removeFaucetService(accessory);
|
|
200
|
+
this.removeSwitchService(accessory);
|
|
201
|
+
this.removeWindowService(accessory);
|
|
202
|
+
this.removeGarageDoorService(accessory);
|
|
203
|
+
this.removeStatefulProgrammableSwitchService(accessory);
|
|
176
204
|
}
|
|
177
205
|
else if (this.otherDeviceType === 'lock') {
|
|
178
|
-
// Initialize Lock
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
206
|
+
// Initialize Lock Service
|
|
207
|
+
if (!accessory.context.LockMechanism) {
|
|
208
|
+
accessory.context.LockMechanism = {};
|
|
209
|
+
}
|
|
210
|
+
this.LockMechanism = {
|
|
211
|
+
Name: accessory.context.Name ?? `${accessory.displayName} Lock`,
|
|
212
|
+
Service: accessory.getService(this.hap.Service.LockMechanism) ?? accessory.addService(this.hap.Service.LockMechanism),
|
|
213
|
+
On: accessory.context.On ?? false,
|
|
182
214
|
};
|
|
215
|
+
this.debugWarnLog(`${this.device.remoteType}: ${accessory.displayName} Displaying as Lock`);
|
|
216
|
+
this.LockMechanism.Service
|
|
217
|
+
.setCharacteristic(this.hap.Characteristic.Name, accessory.displayName)
|
|
218
|
+
.getCharacteristic(this.hap.Characteristic.LockTargetState)
|
|
219
|
+
.onGet(() => {
|
|
220
|
+
return this.LockMechanism.On;
|
|
221
|
+
})
|
|
222
|
+
.onSet(this.OnSet.bind(this));
|
|
223
|
+
accessory.context.Name = this.LockMechanism.Name;
|
|
224
|
+
// Remove other services
|
|
183
225
|
this.removeFanService(accessory);
|
|
184
226
|
this.removeDoorService(accessory);
|
|
185
227
|
this.removeOutletService(accessory);
|
|
@@ -189,20 +231,27 @@ export class Others extends irdeviceBase {
|
|
|
189
231
|
this.removeGarageDoorService(accessory);
|
|
190
232
|
this.removeWindowCoveringService(accessory);
|
|
191
233
|
this.removeStatefulProgrammableSwitchService(accessory);
|
|
192
|
-
// Add Lock Service
|
|
193
|
-
const LockService = `${accessory.displayName} Lock`;
|
|
194
|
-
(this.Lock.Service = accessory.getService(this.hap.Service.LockMechanism)
|
|
195
|
-
|| accessory.addService(this.hap.Service.LockMechanism)), LockService;
|
|
196
|
-
this.debugWarnLog(`${this.device.remoteType}: ${accessory.displayName} Displaying as Lock`);
|
|
197
|
-
this.Lock.Service.setCharacteristic(this.hap.Characteristic.Name, accessory.displayName);
|
|
198
|
-
this.Lock.Service.getCharacteristic(this.hap.Characteristic.LockTargetState).onSet(this.OnSet.bind(this));
|
|
199
234
|
}
|
|
200
235
|
else if (this.otherDeviceType === 'faucet') {
|
|
201
|
-
// Initialize Faucet
|
|
236
|
+
// Initialize Faucet Service
|
|
237
|
+
if (!accessory.context.Faucet) {
|
|
238
|
+
accessory.context.Faucet = {};
|
|
239
|
+
}
|
|
202
240
|
this.Faucet = {
|
|
203
|
-
|
|
204
|
-
|
|
241
|
+
Name: accessory.context.Name ?? `${accessory.displayName} Faucet`,
|
|
242
|
+
Service: accessory.getService(this.hap.Service.Faucet) ?? accessory.addService(this.hap.Service.Faucet),
|
|
243
|
+
On: accessory.context.On ?? false,
|
|
205
244
|
};
|
|
245
|
+
this.debugWarnLog(`${this.device.remoteType}: ${accessory.displayName} Displaying as Faucet`);
|
|
246
|
+
this.Faucet.Service
|
|
247
|
+
.setCharacteristic(this.hap.Characteristic.Name, accessory.displayName)
|
|
248
|
+
.getCharacteristic(this.hap.Characteristic.Active)
|
|
249
|
+
.onGet(() => {
|
|
250
|
+
return this.Faucet.On;
|
|
251
|
+
})
|
|
252
|
+
.onSet(this.OnSet.bind(this));
|
|
253
|
+
accessory.context.Name = this.Faucet.Name;
|
|
254
|
+
// Remove other services
|
|
206
255
|
this.removeFanService(accessory);
|
|
207
256
|
this.removeLockService(accessory);
|
|
208
257
|
this.removeDoorService(accessory);
|
|
@@ -212,20 +261,27 @@ export class Others extends irdeviceBase {
|
|
|
212
261
|
this.removeGarageDoorService(accessory);
|
|
213
262
|
this.removeWindowCoveringService(accessory);
|
|
214
263
|
this.removeStatefulProgrammableSwitchService(accessory);
|
|
215
|
-
// Add Faucet Service
|
|
216
|
-
const FaucetService = `${accessory.displayName} Faucet`;
|
|
217
|
-
(this.Faucet.Service = accessory.getService(this.hap.Service.Faucet)
|
|
218
|
-
|| accessory.addService(this.hap.Service.Faucet)), FaucetService;
|
|
219
|
-
this.debugWarnLog(`${this.device.remoteType}: ${accessory.displayName} Displaying as Faucet`);
|
|
220
|
-
this.Faucet.Service.setCharacteristic(this.hap.Characteristic.Name, accessory.displayName);
|
|
221
|
-
this.Faucet.Service.getCharacteristic(this.hap.Characteristic.Active).onSet(this.OnSet.bind(this));
|
|
222
264
|
}
|
|
223
265
|
else if (this.otherDeviceType === 'fan') {
|
|
224
|
-
// Initialize Fan
|
|
266
|
+
// Initialize Fan Service
|
|
267
|
+
if (!accessory.context.Fan) {
|
|
268
|
+
accessory.context.Fan = {};
|
|
269
|
+
}
|
|
225
270
|
this.Fan = {
|
|
226
|
-
|
|
227
|
-
|
|
271
|
+
Name: accessory.context.Name ?? `${accessory.displayName} Fan`,
|
|
272
|
+
Service: accessory.getService(this.hap.Service.Fanv2) ?? accessory.addService(this.hap.Service.Fanv2),
|
|
273
|
+
On: accessory.context.On ?? false,
|
|
228
274
|
};
|
|
275
|
+
this.debugWarnLog(`${this.device.remoteType}: ${accessory.displayName} Displaying as Fan`);
|
|
276
|
+
this.Fan.Service
|
|
277
|
+
.setCharacteristic(this.hap.Characteristic.Name, accessory.displayName)
|
|
278
|
+
.getCharacteristic(this.hap.Characteristic.On)
|
|
279
|
+
.onGet(() => {
|
|
280
|
+
return this.Fan.On;
|
|
281
|
+
})
|
|
282
|
+
.onSet(this.OnSet.bind(this));
|
|
283
|
+
accessory.context.Name = this.Fan.Name;
|
|
284
|
+
// Remove other services
|
|
229
285
|
this.removeLockService(accessory);
|
|
230
286
|
this.removeDoorService(accessory);
|
|
231
287
|
this.removeFaucetService(accessory);
|
|
@@ -235,20 +291,29 @@ export class Others extends irdeviceBase {
|
|
|
235
291
|
this.removeGarageDoorService(accessory);
|
|
236
292
|
this.removeWindowCoveringService(accessory);
|
|
237
293
|
this.removeStatefulProgrammableSwitchService(accessory);
|
|
238
|
-
// Add Fan Service
|
|
239
|
-
const FanService = `${accessory.displayName} Fan`;
|
|
240
|
-
(this.Fan.Service = accessory.getService(this.hap.Service.Fanv2)
|
|
241
|
-
|| accessory.addService(this.hap.Service.Fanv2)), FanService;
|
|
242
|
-
this.debugWarnLog(`${this.device.remoteType}: ${accessory.displayName} Displaying as Fan`);
|
|
243
|
-
this.Fan.Service.setCharacteristic(this.hap.Characteristic.Name, accessory.displayName);
|
|
244
|
-
this.Fan.Service.getCharacteristic(this.hap.Characteristic.On).onSet(this.OnSet.bind(this));
|
|
245
294
|
}
|
|
246
295
|
else if (this.otherDeviceType === 'stateful') {
|
|
296
|
+
// Initialize Lock Service
|
|
297
|
+
if (!accessory.context.StatefulProgrammableSwitch) {
|
|
298
|
+
accessory.context.StatefulProgrammableSwitch = {};
|
|
299
|
+
}
|
|
247
300
|
// Initialize StatefulProgrammableSwitch property
|
|
248
301
|
this.StatefulProgrammableSwitch = {
|
|
249
|
-
|
|
250
|
-
|
|
302
|
+
Name: accessory.context.Name ?? `${accessory.displayName} Stateful Programmable Switch`,
|
|
303
|
+
Service: accessory.getService(this.hap.Service.StatefulProgrammableSwitch)
|
|
304
|
+
?? accessory.addService(this.hap.Service.StatefulProgrammableSwitch),
|
|
305
|
+
On: accessory.context.On ?? false,
|
|
251
306
|
};
|
|
307
|
+
this.debugWarnLog(`${this.device.remoteType}: ${accessory.displayName} Displaying as Stateful Programmable Switch`);
|
|
308
|
+
this.StatefulProgrammableSwitch.Service
|
|
309
|
+
.setCharacteristic(this.hap.Characteristic.Name, accessory.displayName)
|
|
310
|
+
.getCharacteristic(this.hap.Characteristic.ProgrammableSwitchOutputState)
|
|
311
|
+
.onGet(() => {
|
|
312
|
+
return this.StatefulProgrammableSwitch.On;
|
|
313
|
+
})
|
|
314
|
+
.onSet(this.OnSet.bind(this));
|
|
315
|
+
accessory.context.Name = this.StatefulProgrammableSwitch.Name;
|
|
316
|
+
// Remove other services
|
|
252
317
|
this.removeFanService(accessory);
|
|
253
318
|
this.removeLockService(accessory);
|
|
254
319
|
this.removeDoorService(accessory);
|
|
@@ -258,22 +323,27 @@ export class Others extends irdeviceBase {
|
|
|
258
323
|
this.removeWindowService(accessory);
|
|
259
324
|
this.removeGarageDoorService(accessory);
|
|
260
325
|
this.removeWindowCoveringService(accessory);
|
|
261
|
-
// Add StatefulProgrammableSwitch.Service
|
|
262
|
-
const StatefulProgrammableSwitchService = `${accessory.displayName} Stateful Programmable Switch`;
|
|
263
|
-
(this.StatefulProgrammableSwitch.Service = accessory.getService(this.hap.Service.StatefulProgrammableSwitch)
|
|
264
|
-
|| accessory.addService(this.hap.Service.StatefulProgrammableSwitch)), StatefulProgrammableSwitchService;
|
|
265
|
-
this.debugWarnLog(`${this.device.remoteType}: ${accessory.displayName} Displaying as Stateful Programmable Switch`);
|
|
266
|
-
this.StatefulProgrammableSwitch.Service.setCharacteristic(this.hap.Characteristic.Name, accessory.displayName);
|
|
267
|
-
this.StatefulProgrammableSwitch.Service
|
|
268
|
-
.getCharacteristic(this.hap.Characteristic.ProgrammableSwitchOutputState)
|
|
269
|
-
.onSet(this.OnSet.bind(this));
|
|
270
326
|
}
|
|
271
327
|
else {
|
|
272
|
-
// Initialize Outlet
|
|
328
|
+
// Initialize Outlet Service
|
|
329
|
+
if (!accessory.context.Outlet) {
|
|
330
|
+
accessory.context.Outlet = {};
|
|
331
|
+
}
|
|
273
332
|
this.Outlet = {
|
|
274
|
-
|
|
275
|
-
|
|
333
|
+
Name: accessory.context.Name ?? `${accessory.displayName} Outlet`,
|
|
334
|
+
Service: accessory.getService(this.hap.Service.Outlet) ?? accessory.addService(this.hap.Service.Outlet),
|
|
335
|
+
On: accessory.context.On ?? false,
|
|
276
336
|
};
|
|
337
|
+
this.debugWarnLog(`${this.device.remoteType}: ${accessory.displayName} Displaying as Outlet`);
|
|
338
|
+
this.Outlet.Service
|
|
339
|
+
.setCharacteristic(this.hap.Characteristic.Name, accessory.displayName)
|
|
340
|
+
.getCharacteristic(this.hap.Characteristic.On)
|
|
341
|
+
.onGet(() => {
|
|
342
|
+
return this.Outlet.On;
|
|
343
|
+
})
|
|
344
|
+
.onSet(this.OnSet.bind(this));
|
|
345
|
+
accessory.context.Name = this.Outlet.Name;
|
|
346
|
+
// Remove other services
|
|
277
347
|
this.removeFanService(accessory);
|
|
278
348
|
this.removeLockService(accessory);
|
|
279
349
|
this.removeDoorService(accessory);
|
|
@@ -283,13 +353,6 @@ export class Others extends irdeviceBase {
|
|
|
283
353
|
this.removeGarageDoorService(accessory);
|
|
284
354
|
this.removeWindowCoveringService(accessory);
|
|
285
355
|
this.removeStatefulProgrammableSwitchService(accessory);
|
|
286
|
-
// Add Outlet.Service
|
|
287
|
-
const OutletService = `${accessory.displayName} Outlet`;
|
|
288
|
-
(this.Outlet.Service = accessory.getService(this.hap.Service.Outlet)
|
|
289
|
-
|| accessory.addService(this.hap.Service.Outlet)), OutletService;
|
|
290
|
-
this.debugWarnLog(`${this.device.remoteType}: ${accessory.displayName} Displaying as Outlet`);
|
|
291
|
-
this.Outlet.Service.setCharacteristic(this.hap.Characteristic.Name, accessory.displayName);
|
|
292
|
-
this.Outlet.Service.getCharacteristic(this.hap.Characteristic.On).onSet(this.OnSet.bind(this));
|
|
293
356
|
}
|
|
294
357
|
}
|
|
295
358
|
/**
|
|
@@ -340,12 +403,12 @@ export class Others extends irdeviceBase {
|
|
|
340
403
|
else if (this.otherDeviceType === 'lock') {
|
|
341
404
|
this.infoLog(`${this.device.remoteType}: ${this.accessory.displayName} Set LockTargetState: ${value}`);
|
|
342
405
|
if (value === this.hap.Characteristic.LockTargetState.SECURED) {
|
|
343
|
-
this.
|
|
406
|
+
this.LockMechanism.On = false;
|
|
344
407
|
}
|
|
345
408
|
else {
|
|
346
|
-
this.
|
|
409
|
+
this.LockMechanism.On = true;
|
|
347
410
|
}
|
|
348
|
-
On = this.
|
|
411
|
+
On = this.LockMechanism.On;
|
|
349
412
|
}
|
|
350
413
|
else if (this.otherDeviceType === 'faucet') {
|
|
351
414
|
this.infoLog(`${this.device.remoteType}: ${this.accessory.displayName} Set Active: ${value}`);
|
|
@@ -553,24 +616,24 @@ export class Others extends irdeviceBase {
|
|
|
553
616
|
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Window Covering On: ${this.WindowCovering.On}`);
|
|
554
617
|
}
|
|
555
618
|
else if (this.otherDeviceType === 'lock') {
|
|
556
|
-
if (this.
|
|
557
|
-
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} On: ${this.
|
|
619
|
+
if (this.LockMechanism?.On === undefined) {
|
|
620
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} On: ${this.LockMechanism?.On}`);
|
|
558
621
|
}
|
|
559
622
|
else {
|
|
560
|
-
if (this.
|
|
561
|
-
this.
|
|
562
|
-
this.
|
|
623
|
+
if (this.LockMechanism.On) {
|
|
624
|
+
this.LockMechanism.Service.updateCharacteristic(this.hap.Characteristic.LockTargetState, this.hap.Characteristic.LockTargetState.UNSECURED);
|
|
625
|
+
this.LockMechanism.Service.updateCharacteristic(this.hap.Characteristic.LockCurrentState, this.hap.Characteristic.LockCurrentState.UNSECURED);
|
|
563
626
|
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} updateCharacteristic`
|
|
564
|
-
+ ` LockTargetState: UNSECURED, LockCurrentState: UNSECURE (${this.
|
|
627
|
+
+ ` LockTargetState: UNSECURED, LockCurrentState: UNSECURE (${this.LockMechanism.On})`);
|
|
565
628
|
}
|
|
566
629
|
else {
|
|
567
|
-
this.
|
|
568
|
-
this.
|
|
630
|
+
this.LockMechanism.Service.updateCharacteristic(this.hap.Characteristic.LockTargetState, this.hap.Characteristic.LockTargetState.SECURED);
|
|
631
|
+
this.LockMechanism.Service.updateCharacteristic(this.hap.Characteristic.LockCurrentState, this.hap.Characteristic.LockCurrentState.SECURED);
|
|
569
632
|
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} updateCharacteristic`
|
|
570
|
-
+ ` LockTargetState: SECURED, LockCurrentState: SECURED (${this.
|
|
633
|
+
+ ` LockTargetState: SECURED, LockCurrentState: SECURED (${this.LockMechanism.On})`);
|
|
571
634
|
}
|
|
572
635
|
}
|
|
573
|
-
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Lock On: ${this.
|
|
636
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Lock On: ${this.LockMechanism?.On}`);
|
|
574
637
|
}
|
|
575
638
|
else if (this.otherDeviceType === 'faucet') {
|
|
576
639
|
if (this.Faucet.On === undefined) {
|
|
@@ -711,10 +774,10 @@ export class Others extends irdeviceBase {
|
|
|
711
774
|
}
|
|
712
775
|
async removeLockService(accessory) {
|
|
713
776
|
// If Lock.Service still present, then remove first
|
|
714
|
-
if (this.
|
|
715
|
-
this.
|
|
777
|
+
if (this.LockMechanism?.Service) {
|
|
778
|
+
this.LockMechanism.Service = this.accessory.getService(this.hap.Service.LockMechanism);
|
|
716
779
|
this.warnLog(`${this.device.remoteType}: ${accessory.displayName} Removing Leftover Lock Service`);
|
|
717
|
-
accessory.removeService(this.
|
|
780
|
+
accessory.removeService(this.LockMechanism.Service);
|
|
718
781
|
}
|
|
719
782
|
}
|
|
720
783
|
async removeFaucetService(accessory) {
|