@switchbot/homebridge-switchbot 3.5.0-beta.26 → 3.5.0-beta.27
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 +17 -14
- package/dist/device/blindtilt.js.map +1 -1
- package/dist/device/bot.js +13 -13
- package/dist/device/bot.js.map +1 -1
- package/dist/device/ceilinglight.js +3 -3
- package/dist/device/ceilinglight.js.map +1 -1
- package/dist/device/colorbulb.js +3 -3
- package/dist/device/colorbulb.js.map +1 -1
- package/dist/device/contact.js +5 -5
- package/dist/device/contact.js.map +1 -1
- package/dist/device/curtain.d.ts.map +1 -1
- package/dist/device/curtain.js +12 -12
- package/dist/device/curtain.js.map +1 -1
- package/dist/device/hub.d.ts.map +1 -1
- package/dist/device/hub.js +6 -6
- package/dist/device/hub.js.map +1 -1
- package/dist/device/humidifier.js +4 -4
- package/dist/device/humidifier.js.map +1 -1
- package/dist/device/iosensor.js +5 -5
- package/dist/device/iosensor.js.map +1 -1
- package/dist/device/lightstrip.js +3 -3
- package/dist/device/lightstrip.js.map +1 -1
- package/dist/device/lock.js +6 -6
- package/dist/device/lock.js.map +1 -1
- package/dist/device/meter.js +5 -5
- package/dist/device/meter.js.map +1 -1
- package/dist/device/meterplus.js +5 -5
- package/dist/device/meterplus.js.map +1 -1
- package/dist/device/motion.js +5 -6
- package/dist/device/motion.js.map +1 -1
- package/dist/device/plug.js +3 -3
- package/dist/device/plug.js.map +1 -1
- package/dist/device/robotvacuumcleaner.js +4 -4
- package/dist/device/robotvacuumcleaner.js.map +1 -1
- package/dist/device/waterdetector.d.ts.map +1 -1
- package/dist/device/waterdetector.js +9 -16
- package/dist/device/waterdetector.js.map +1 -1
- package/dist/irdevice/airconditioner.d.ts +4 -14
- package/dist/irdevice/airconditioner.d.ts.map +1 -1
- package/dist/irdevice/airconditioner.js +226 -234
- package/dist/irdevice/airconditioner.js.map +1 -1
- package/dist/irdevice/airpurifier.d.ts +3 -6
- package/dist/irdevice/airpurifier.d.ts.map +1 -1
- package/dist/irdevice/airpurifier.js +65 -56
- package/dist/irdevice/airpurifier.js.map +1 -1
- package/dist/irdevice/camera.d.ts +2 -3
- package/dist/irdevice/camera.d.ts.map +1 -1
- package/dist/irdevice/camera.js +24 -27
- package/dist/irdevice/camera.js.map +1 -1
- package/dist/irdevice/fan.d.ts +2 -7
- package/dist/irdevice/fan.d.ts.map +1 -1
- package/dist/irdevice/fan.js +57 -61
- package/dist/irdevice/fan.js.map +1 -1
- package/dist/irdevice/irdevice.js +1 -1
- package/dist/irdevice/irdevice.js.map +1 -1
- package/dist/irdevice/light.d.ts +1 -1
- package/dist/irdevice/light.d.ts.map +1 -1
- package/dist/irdevice/light.js +13 -15
- package/dist/irdevice/light.js.map +1 -1
- package/dist/irdevice/other.js +51 -50
- package/dist/irdevice/other.js.map +1 -1
- package/dist/irdevice/tv.js +2 -2
- package/dist/irdevice/tv.js.map +1 -1
- package/dist/irdevice/vacuumcleaner.js +1 -1
- package/dist/irdevice/vacuumcleaner.js.map +1 -1
- package/dist/irdevice/waterheater.js +1 -1
- package/dist/irdevice/waterheater.js.map +1 -1
- package/dist/platform.d.ts.map +1 -1
- package/dist/platform.js +22 -1
- package/dist/platform.js.map +1 -1
- package/package.json +2 -2
- package/src/custom.d.ts +1 -0
- package/src/device/blindtilt.ts +20 -18
- package/src/device/bot.ts +14 -14
- package/src/device/ceilinglight.ts +4 -4
- package/src/device/colorbulb.ts +4 -4
- package/src/device/contact.ts +6 -6
- package/src/device/curtain.ts +14 -13
- package/src/device/hub.ts +7 -6
- package/src/device/humidifier.ts +5 -5
- package/src/device/iosensor.ts +6 -6
- package/src/device/lightstrip.ts +4 -4
- package/src/device/lock.ts +7 -7
- package/src/device/meter.ts +6 -6
- package/src/device/meterplus.ts +6 -6
- package/src/device/motion.ts +6 -6
- package/src/device/plug.ts +4 -4
- package/src/device/robotvacuumcleaner.ts +5 -5
- package/src/device/waterdetector.ts +9 -17
- package/src/irdevice/airconditioner.ts +239 -238
- package/src/irdevice/airpurifier.ts +75 -56
- package/src/irdevice/camera.ts +27 -27
- package/src/irdevice/fan.ts +63 -63
- package/src/irdevice/irdevice.ts +1 -1
- package/src/irdevice/light.ts +17 -15
- package/src/irdevice/other.ts +51 -51
- package/src/irdevice/tv.ts +2 -2
- package/src/irdevice/vacuumcleaner.ts +1 -1
- package/src/irdevice/waterheater.ts +1 -1
- package/src/platform.ts +21 -4
package/src/device/blindtilt.ts
CHANGED
|
@@ -60,34 +60,34 @@ export class BlindTilt extends deviceBase {
|
|
|
60
60
|
this.blindTiltUpdateInProgress = false;
|
|
61
61
|
this.setNewTarget = false;
|
|
62
62
|
|
|
63
|
-
// Retrieve initial values and updateHomekit
|
|
64
|
-
this.refreshStatus();
|
|
65
|
-
|
|
66
63
|
// Initialize LightBulb property
|
|
67
64
|
this.WindowCovering = {
|
|
68
|
-
Service:
|
|
69
|
-
PositionState:
|
|
70
|
-
TargetPosition:
|
|
71
|
-
CurrentPosition:
|
|
72
|
-
TargetHorizontalTiltAngle:
|
|
73
|
-
CurrentHorizontalTiltAngle:
|
|
65
|
+
Service: accessory.getService(this.hap.Service.WindowCovering)!,
|
|
66
|
+
PositionState: accessory.context.PositionState || this.hap.Characteristic.PositionState.STOPPED,
|
|
67
|
+
TargetPosition: accessory.context.TargetPosition || 100,
|
|
68
|
+
CurrentPosition: accessory.context.CurrentPosition || 100,
|
|
69
|
+
TargetHorizontalTiltAngle: accessory.context.TargetHorizontalTiltAngle || 0,
|
|
70
|
+
CurrentHorizontalTiltAngle: accessory.context.CurrentHorizontalTiltAngle || 0,
|
|
74
71
|
};
|
|
75
72
|
|
|
76
73
|
// Initialize Battery property
|
|
77
74
|
this.Battery = {
|
|
78
|
-
Service:
|
|
79
|
-
BatteryLevel:
|
|
75
|
+
Service: accessory.getService(this.hap.Service.Battery)!,
|
|
76
|
+
BatteryLevel: accessory.context.BatteryLevel || 100,
|
|
80
77
|
StatusLowBattery: this.hap.Characteristic.StatusLowBattery.BATTERY_LEVEL_NORMAL,
|
|
81
78
|
};
|
|
82
79
|
|
|
83
80
|
// Initialize LightSensor property
|
|
84
81
|
if (!this.device.blindTilt?.hide_lightsensor) {
|
|
85
82
|
this.LightSensor = {
|
|
86
|
-
Service:
|
|
87
|
-
CurrentAmbientLightLevel:
|
|
83
|
+
Service: accessory.getService(this.hap.Service.LightSensor)!,
|
|
84
|
+
CurrentAmbientLightLevel: accessory.context.CurrentAmbientLightLevel || 0.0001,
|
|
88
85
|
};
|
|
89
86
|
}
|
|
90
87
|
|
|
88
|
+
// Retrieve initial values and updateHomekit
|
|
89
|
+
this.refreshStatus();
|
|
90
|
+
|
|
91
91
|
// get the WindowCovering service if it exists, otherwise create a new WindowCovering service
|
|
92
92
|
// you can create multiple services for each accessory
|
|
93
93
|
(this.WindowCovering!.Service =
|
|
@@ -262,16 +262,18 @@ export class BlindTilt extends deviceBase {
|
|
|
262
262
|
this.WindowCovering.PositionState = this.hap.Characteristic.PositionState.STOPPED;
|
|
263
263
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Stopped`);
|
|
264
264
|
}
|
|
265
|
-
this.debugLog(
|
|
266
|
-
|
|
267
|
-
` TargetPosition: ${this.WindowCovering.TargetPosition}, PositionState: ${this.WindowCovering.PositionState},`,
|
|
268
|
-
);
|
|
265
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} CurrentPosition: ${this.WindowCovering.CurrentPosition},`
|
|
266
|
+
+ ` TargetPosition: ${this.WindowCovering.TargetPosition}, PositionState: ${this.WindowCovering.PositionState},`);
|
|
269
267
|
|
|
270
268
|
if (!this.device.blindTilt?.hide_lightsensor) {
|
|
271
269
|
const set_minLux = await this.minLux();
|
|
272
270
|
const set_maxLux = await this.maxLux();
|
|
273
271
|
const spaceBetweenLevels = 9;
|
|
274
272
|
|
|
273
|
+
if (this.LightSensor?.CurrentAmbientLightLevel === 0) {
|
|
274
|
+
this.LightSensor!.CurrentAmbientLightLevel = 0.0001;
|
|
275
|
+
}
|
|
276
|
+
|
|
275
277
|
// Brightness
|
|
276
278
|
switch (serviceData.lightLevel) {
|
|
277
279
|
case 1:
|
|
@@ -347,7 +349,7 @@ export class BlindTilt extends deviceBase {
|
|
|
347
349
|
String(deviceStatus.body.direction));
|
|
348
350
|
this.debugLog(` device: ${deviceStatus.body.slidePosition} => HK: ${homekitPosition}`);
|
|
349
351
|
|
|
350
|
-
this.WindowCovering
|
|
352
|
+
this.WindowCovering!.CurrentPosition = homekitPosition;
|
|
351
353
|
// CurrentPosition
|
|
352
354
|
await this.setMinMax();
|
|
353
355
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} CurrentPosition: ${this.WindowCovering.CurrentPosition}`);
|
package/src/device/bot.ts
CHANGED
|
@@ -98,12 +98,9 @@ export class Bot extends deviceBase {
|
|
|
98
98
|
this.doBotUpdate = new Subject();
|
|
99
99
|
this.botUpdateInProgress = false;
|
|
100
100
|
|
|
101
|
-
// Retrieve initial values and updateHomekit
|
|
102
|
-
this.refreshStatus();
|
|
103
|
-
|
|
104
101
|
// Initialize Battery property
|
|
105
102
|
this.Battery = {
|
|
106
|
-
Service: accessory.
|
|
103
|
+
Service: accessory.getService(this.hap.Service.Battery)!,
|
|
107
104
|
BatteryLevel: accessory.context.BatteryLevel || 100,
|
|
108
105
|
StatusLowBattery: accessory.context.StatusLowBattery || this.hap.Characteristic.StatusLowBattery.BATTERY_LEVEL_NORMAL,
|
|
109
106
|
};
|
|
@@ -112,7 +109,7 @@ export class Bot extends deviceBase {
|
|
|
112
109
|
if (this.botDeviceType === 'switch') {
|
|
113
110
|
// Initialize Switch property
|
|
114
111
|
this.Switch = {
|
|
115
|
-
Service:
|
|
112
|
+
Service: accessory.getService(this.hap.Service.Switch)!,
|
|
116
113
|
On: accessory.context.On || false,
|
|
117
114
|
};
|
|
118
115
|
this.removeFanService(accessory);
|
|
@@ -136,7 +133,7 @@ export class Bot extends deviceBase {
|
|
|
136
133
|
} else if (this.botDeviceType === 'garagedoor') {
|
|
137
134
|
// Initialize Switch property
|
|
138
135
|
this.GarageDoor = {
|
|
139
|
-
Service:
|
|
136
|
+
Service: accessory.getService(this.hap.Service.GarageDoorOpener)!,
|
|
140
137
|
On: accessory.context.On || false,
|
|
141
138
|
};
|
|
142
139
|
this.removeFanService(accessory);
|
|
@@ -161,7 +158,7 @@ export class Bot extends deviceBase {
|
|
|
161
158
|
} else if (this.botDeviceType === 'door') {
|
|
162
159
|
// Initialize Switch property
|
|
163
160
|
this.Door = {
|
|
164
|
-
Service:
|
|
161
|
+
Service: accessory.getService(this.hap.Service.Door)!,
|
|
165
162
|
On: accessory.context.On || false,
|
|
166
163
|
};
|
|
167
164
|
this.removeFanService(accessory);
|
|
@@ -194,7 +191,7 @@ export class Bot extends deviceBase {
|
|
|
194
191
|
} else if (this.botDeviceType === 'window') {
|
|
195
192
|
// Initialize Switch property
|
|
196
193
|
this.Window = {
|
|
197
|
-
Service:
|
|
194
|
+
Service: accessory.getService(this.hap.Service.Window)!,
|
|
198
195
|
On: accessory.context.On || false,
|
|
199
196
|
};
|
|
200
197
|
this.removeFanService(accessory);
|
|
@@ -227,7 +224,7 @@ export class Bot extends deviceBase {
|
|
|
227
224
|
} else if (this.botDeviceType === 'windowcovering') {
|
|
228
225
|
// Initialize Switch property
|
|
229
226
|
this.WindowCovering = {
|
|
230
|
-
Service:
|
|
227
|
+
Service: accessory.getService(this.hap.Service.WindowCovering)!,
|
|
231
228
|
On: accessory.context.On || false,
|
|
232
229
|
};
|
|
233
230
|
this.removeFanService(accessory);
|
|
@@ -260,7 +257,7 @@ export class Bot extends deviceBase {
|
|
|
260
257
|
} else if (this.botDeviceType === 'lock') {
|
|
261
258
|
// Initialize Switch property
|
|
262
259
|
this.Lock = {
|
|
263
|
-
Service:
|
|
260
|
+
Service: accessory.getService(this.hap.Service.LockMechanism)!,
|
|
264
261
|
On: accessory.context.On || false,
|
|
265
262
|
};
|
|
266
263
|
this.removeFanService(accessory);
|
|
@@ -284,7 +281,7 @@ export class Bot extends deviceBase {
|
|
|
284
281
|
} else if (this.botDeviceType === 'faucet') {
|
|
285
282
|
// Initialize Switch property
|
|
286
283
|
this.Faucet = {
|
|
287
|
-
Service:
|
|
284
|
+
Service: accessory.getService(this.hap.Service.Faucet)!,
|
|
288
285
|
On: accessory.context.On || false,
|
|
289
286
|
};
|
|
290
287
|
this.removeFanService(accessory);
|
|
@@ -308,7 +305,7 @@ export class Bot extends deviceBase {
|
|
|
308
305
|
} else if (this.botDeviceType === 'fan') {
|
|
309
306
|
// Initialize Switch property
|
|
310
307
|
this.Fan = {
|
|
311
|
-
Service:
|
|
308
|
+
Service: accessory.getService(this.hap.Service.Fanv2)!,
|
|
312
309
|
On: accessory.context.On || false,
|
|
313
310
|
};
|
|
314
311
|
this.removeLockService(accessory);
|
|
@@ -332,7 +329,7 @@ export class Bot extends deviceBase {
|
|
|
332
329
|
} else if (this.botDeviceType === 'stateful') {
|
|
333
330
|
// Initialize Switch property
|
|
334
331
|
this.StatefulProgrammableSwitch = {
|
|
335
|
-
Service:
|
|
332
|
+
Service: accessory.getService(this.hap.Service.StatefulProgrammableSwitch)!,
|
|
336
333
|
On: accessory.context.On || false,
|
|
337
334
|
};
|
|
338
335
|
this.removeFanService(accessory);
|
|
@@ -358,7 +355,7 @@ export class Bot extends deviceBase {
|
|
|
358
355
|
} else {
|
|
359
356
|
// Initialize Switch property
|
|
360
357
|
this.Outlet = {
|
|
361
|
-
Service:
|
|
358
|
+
Service: accessory.getService(this.hap.Service.Outlet)!,
|
|
362
359
|
On: accessory.context.On || false,
|
|
363
360
|
};
|
|
364
361
|
this.removeFanService(accessory);
|
|
@@ -381,6 +378,9 @@ export class Bot extends deviceBase {
|
|
|
381
378
|
this.Outlet!.Service.getCharacteristic(this.hap.Characteristic.On).onSet(this.OnSet.bind(this));
|
|
382
379
|
}
|
|
383
380
|
|
|
381
|
+
// Retrieve initial values and updateHomekit
|
|
382
|
+
this.refreshStatus();
|
|
383
|
+
|
|
384
384
|
// batteryService
|
|
385
385
|
const batteryService = `${accessory.displayName} Battery`;
|
|
386
386
|
(this.Battery.Service = this.accessory.getService(this.hap.Service.Battery)
|
|
@@ -48,12 +48,9 @@ export class CeilingLight extends deviceBase {
|
|
|
48
48
|
this.doCeilingLightUpdate = new Subject();
|
|
49
49
|
this.ceilingLightUpdateInProgress = false;
|
|
50
50
|
|
|
51
|
-
// Retrieve initial values and updateHomekit
|
|
52
|
-
this.refreshStatus();
|
|
53
|
-
|
|
54
51
|
// Initialize LightBulb property
|
|
55
52
|
this.LightBulb = {
|
|
56
|
-
Service:
|
|
53
|
+
Service: accessory.getService(this.hap.Service.Lightbulb)!,
|
|
57
54
|
On: accessory.context.On || false,
|
|
58
55
|
Hue: accessory.context.Hue || 0,
|
|
59
56
|
Saturation: accessory.context.Saturation || 0,
|
|
@@ -61,6 +58,9 @@ export class CeilingLight extends deviceBase {
|
|
|
61
58
|
ColorTemperature: accessory.context.ColorTemperature || 140,
|
|
62
59
|
};
|
|
63
60
|
|
|
61
|
+
// Retrieve initial values and updateHomekit
|
|
62
|
+
this.refreshStatus();
|
|
63
|
+
|
|
64
64
|
const LightBulbService = `${accessory.displayName} ${device.deviceType}`;
|
|
65
65
|
(this.LightBulb!.Service = accessory.getService(this.hap.Service.Lightbulb)
|
|
66
66
|
|| accessory.addService(this.hap.Service.Lightbulb)), LightBulbService;
|
package/src/device/colorbulb.ts
CHANGED
|
@@ -49,12 +49,9 @@ export class ColorBulb extends deviceBase {
|
|
|
49
49
|
this.doColorBulbUpdate = new Subject();
|
|
50
50
|
this.colorBulbUpdateInProgress = false;
|
|
51
51
|
|
|
52
|
-
// Retrieve initial values and updateHomekit
|
|
53
|
-
this.refreshStatus();
|
|
54
|
-
|
|
55
52
|
// Initialize LightBulb property
|
|
56
53
|
this.LightBulb = {
|
|
57
|
-
Service:
|
|
54
|
+
Service: accessory.getService(this.hap.Service.Lightbulb)!,
|
|
58
55
|
On: accessory.context.On || false,
|
|
59
56
|
Hue: accessory.context.Hue || 0,
|
|
60
57
|
Saturation: accessory.context.Saturation || 0,
|
|
@@ -62,6 +59,9 @@ export class ColorBulb extends deviceBase {
|
|
|
62
59
|
ColorTemperature: accessory.context.ColorTemperature || 140,
|
|
63
60
|
};
|
|
64
61
|
|
|
62
|
+
// Retrieve initial values and updateHomekit
|
|
63
|
+
this.refreshStatus();
|
|
64
|
+
|
|
65
65
|
// get the Lightbulb service if it exists, otherwise create a new Lightbulb service
|
|
66
66
|
// you can create multiple services for each accessory
|
|
67
67
|
const lightBulbService = `${accessory.displayName} ${device.deviceType}`;
|
package/src/device/contact.ts
CHANGED
|
@@ -51,19 +51,16 @@ export class Contact extends deviceBase {
|
|
|
51
51
|
this.doContactUpdate = new Subject();
|
|
52
52
|
this.contactUpdateInProgress = false;
|
|
53
53
|
|
|
54
|
-
// Retrieve initial values and updateHomekit
|
|
55
|
-
this.refreshStatus();
|
|
56
|
-
|
|
57
54
|
// Initialize Contact Sensor property
|
|
58
55
|
this.ContactSensor = {
|
|
59
|
-
Service:
|
|
56
|
+
Service: accessory.getService(this.hap.Service.ContactSensor)!,
|
|
60
57
|
ContactSensorState: this.hap.Characteristic.ContactSensorState.CONTACT_DETECTED,
|
|
61
58
|
};
|
|
62
59
|
|
|
63
60
|
// Initialize Motion Sensor property
|
|
64
61
|
if (!this.device.contact?.hide_motionsensor) {
|
|
65
62
|
this.MotionSensor = {
|
|
66
|
-
Service:
|
|
63
|
+
Service: accessory.getService(this.hap.Service.MotionSensor)!,
|
|
67
64
|
MotionDetected: false,
|
|
68
65
|
};
|
|
69
66
|
}
|
|
@@ -71,11 +68,14 @@ export class Contact extends deviceBase {
|
|
|
71
68
|
// Initialize Light Sensor property
|
|
72
69
|
if (!this.device.contact?.hide_lightsensor) {
|
|
73
70
|
this.LightSensor = {
|
|
74
|
-
Service:
|
|
71
|
+
Service: accessory.getService(this.hap.Service.LightSensor)!,
|
|
75
72
|
CurrentAmbientLightLevel: 0,
|
|
76
73
|
};
|
|
77
74
|
}
|
|
78
75
|
|
|
76
|
+
// Retrieve initial values and updateHomekit
|
|
77
|
+
this.refreshStatus();
|
|
78
|
+
|
|
79
79
|
// get the Contact service if it exists, otherwise create a new Contact service
|
|
80
80
|
// you can create multiple services for each accessory
|
|
81
81
|
const ContactSensorService = `${accessory.displayName} Contact Sensor`;
|
package/src/device/curtain.ts
CHANGED
|
@@ -53,32 +53,33 @@ export class Curtain extends deviceBase {
|
|
|
53
53
|
this.curtainUpdateInProgress = false;
|
|
54
54
|
this.setNewTarget = false;
|
|
55
55
|
|
|
56
|
-
// Retrieve initial values and updateHomekit
|
|
57
|
-
this.refreshStatus();
|
|
58
56
|
// Initialize LightBulb property
|
|
59
57
|
this.WindowCovering = {
|
|
60
|
-
Service:
|
|
61
|
-
PositionState:
|
|
62
|
-
TargetPosition:
|
|
63
|
-
CurrentPosition:
|
|
64
|
-
HoldPosition:
|
|
58
|
+
Service: accessory.getService(this.hap.Service.WindowCovering)!,
|
|
59
|
+
PositionState: accessory.context.PositionState || this.hap.Characteristic.PositionState.STOPPED,
|
|
60
|
+
TargetPosition: accessory.context.TargetPosition || 100,
|
|
61
|
+
CurrentPosition: accessory.context.CurrentPosition || 100,
|
|
62
|
+
HoldPosition: accessory.context.HoldPosition || false,
|
|
65
63
|
};
|
|
66
64
|
|
|
67
65
|
// Initialize Battery property
|
|
68
66
|
this.Battery = {
|
|
69
|
-
Service:
|
|
70
|
-
BatteryLevel:
|
|
71
|
-
StatusLowBattery:
|
|
67
|
+
Service: accessory.getService(this.hap.Service.Battery)!,
|
|
68
|
+
BatteryLevel: accessory.context.BatteryLevel || 100,
|
|
69
|
+
StatusLowBattery: accessory.context.StatusLowBattery || this.hap.Characteristic.StatusLowBattery.BATTERY_LEVEL_NORMAL,
|
|
72
70
|
};
|
|
73
71
|
|
|
74
72
|
// Initialize LightSensor property
|
|
75
73
|
if (!this.device.curtain?.hide_lightsensor) {
|
|
76
74
|
this.LightSensor = {
|
|
77
|
-
Service:
|
|
78
|
-
CurrentAmbientLightLevel:
|
|
75
|
+
Service: accessory.getService(this.hap.Service.LightSensor)!,
|
|
76
|
+
CurrentAmbientLightLevel: accessory.context.CurrentAmbientLightLevel || 0.0001,
|
|
79
77
|
};
|
|
80
78
|
}
|
|
81
79
|
|
|
80
|
+
// Retrieve initial values and updateHomekit
|
|
81
|
+
this.refreshStatus();
|
|
82
|
+
|
|
82
83
|
// get the WindowCovering service if it exists, otherwise create a new WindowCovering service
|
|
83
84
|
// you can create multiple services for each accessory
|
|
84
85
|
const WindowCoveringService = `${accessory.displayName} ${device.deviceType}`;
|
|
@@ -393,7 +394,7 @@ export class Curtain extends deviceBase {
|
|
|
393
394
|
async openAPIparseStatus(deviceStatus: deviceStatus): Promise<void> {
|
|
394
395
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} openAPIparseStatus`);
|
|
395
396
|
// CurrentPosition
|
|
396
|
-
this.WindowCovering
|
|
397
|
+
this.WindowCovering!.CurrentPosition = 100 - Number(deviceStatus.body.slidePosition);
|
|
397
398
|
await this.setMinMax();
|
|
398
399
|
this.debugLog(`Curtain ${this.accessory.displayName} CurrentPosition: ${this.WindowCovering.CurrentPosition}`);
|
|
399
400
|
if (this.setNewTarget) {
|
package/src/device/hub.ts
CHANGED
|
@@ -38,13 +38,11 @@ export class Hub extends deviceBase {
|
|
|
38
38
|
// this is subject we use to track when we need to POST changes to the SwitchBot API
|
|
39
39
|
this.doHubUpdate = new Subject();
|
|
40
40
|
this.hubUpdateInProgress = false;
|
|
41
|
-
// Retrieve initial values and updateHomekit
|
|
42
|
-
this.refreshStatus();
|
|
43
41
|
|
|
44
42
|
// Initialize Temperature Sensor property
|
|
45
43
|
if (!device.hub?.hide_temperature) {
|
|
46
44
|
this.TemperatureSensor = {
|
|
47
|
-
Service:
|
|
45
|
+
Service: accessory.getService(this.hap.Service.TemperatureSensor)!,
|
|
48
46
|
CurrentTemperature: accessory.context.CurrentTemperature || 0,
|
|
49
47
|
};
|
|
50
48
|
}
|
|
@@ -52,7 +50,7 @@ export class Hub extends deviceBase {
|
|
|
52
50
|
// Initialize Humidity Sensor property
|
|
53
51
|
if (!device.hub?.hide_humidity) {
|
|
54
52
|
this.HumiditySensor = {
|
|
55
|
-
Service:
|
|
53
|
+
Service: accessory.getService(this.hap.Service.HumiditySensor)!,
|
|
56
54
|
CurrentRelativeHumidity: accessory.context.CurrentRelativeHumidity || 0,
|
|
57
55
|
};
|
|
58
56
|
}
|
|
@@ -60,11 +58,14 @@ export class Hub extends deviceBase {
|
|
|
60
58
|
// Initialize Light Sensor property
|
|
61
59
|
if (!device.hub?.hide_lightsensor) {
|
|
62
60
|
this.LightSensor = {
|
|
63
|
-
Service:
|
|
64
|
-
CurrentAmbientLightLevel: accessory.context.CurrentAmbientLightLevel || 0,
|
|
61
|
+
Service: accessory.getService(this.hap.Service.LightSensor)!,
|
|
62
|
+
CurrentAmbientLightLevel: accessory.context.CurrentAmbientLightLevel || 0.0001,
|
|
65
63
|
};
|
|
66
64
|
}
|
|
67
65
|
|
|
66
|
+
// Retrieve initial values and updateHomekit
|
|
67
|
+
this.refreshStatus();
|
|
68
|
+
|
|
68
69
|
// Temperature Sensor Service
|
|
69
70
|
if (device.hub?.hide_temperature) {
|
|
70
71
|
this.debugLog(`${this.device.deviceType}: ${accessory.displayName} Removing Temperature Sensor Service`);
|
package/src/device/humidifier.ts
CHANGED
|
@@ -42,12 +42,9 @@ export class Humidifier extends deviceBase {
|
|
|
42
42
|
this.doHumidifierUpdate = new Subject();
|
|
43
43
|
this.humidifierUpdateInProgress = false;
|
|
44
44
|
|
|
45
|
-
// Retrieve initial values and updateHomekit
|
|
46
|
-
this.refreshStatus();
|
|
47
|
-
|
|
48
45
|
// Initialize the HumidifierDehumidifier Service
|
|
49
46
|
this.HumidifierDehumidifier = {
|
|
50
|
-
Service: accessory.
|
|
47
|
+
Service: accessory.getService(this.hap.Service.HumidifierDehumidifier)!,
|
|
51
48
|
Active: accessory.context.Active || this.hap.Characteristic.Active.ACTIVE,
|
|
52
49
|
WaterLevel: accessory.context.WaterLevel || 100,
|
|
53
50
|
CurrentRelativeHumidity: accessory.context.CurrentRelativeHumidity || 50,
|
|
@@ -61,11 +58,14 @@ export class Humidifier extends deviceBase {
|
|
|
61
58
|
// Initialize the Temperature Sensor Service
|
|
62
59
|
if (!device.humidifier?.hide_temperature) {
|
|
63
60
|
this.TemperatureSensor = {
|
|
64
|
-
Service: accessory.
|
|
61
|
+
Service: accessory.getService(this.hap.Service.TemperatureSensor)!,
|
|
65
62
|
CurrentTemperature: accessory.context.CurrentTemperature || 30,
|
|
66
63
|
};
|
|
67
64
|
}
|
|
68
65
|
|
|
66
|
+
// Retrieve initial values and updateHomekit
|
|
67
|
+
this.refreshStatus();
|
|
68
|
+
|
|
69
69
|
// get the service if it exists, otherwise create a new service
|
|
70
70
|
// you can create multiple services for each accessory
|
|
71
71
|
const HumidifierDehumidifierService = `${accessory.displayName} Humidifier`;
|
package/src/device/iosensor.ts
CHANGED
|
@@ -45,13 +45,10 @@ export class IOSensor extends deviceBase {
|
|
|
45
45
|
this.doIOSensorUpdate = new Subject();
|
|
46
46
|
this.ioSensorUpdateInProgress = false;
|
|
47
47
|
|
|
48
|
-
// Retrieve initial values and updateHomekit
|
|
49
|
-
this.refreshStatus();
|
|
50
|
-
|
|
51
48
|
// Initialize Temperature Sensor property
|
|
52
49
|
if (!device.iosensor?.hide_temperature) {
|
|
53
50
|
this.TemperatureSensor = {
|
|
54
|
-
Service:
|
|
51
|
+
Service: accessory.getService(this.hap.Service.TemperatureSensor)!,
|
|
55
52
|
CurrentTemperature: accessory.context.CurrentTemperature || 30,
|
|
56
53
|
};
|
|
57
54
|
}
|
|
@@ -59,18 +56,21 @@ export class IOSensor extends deviceBase {
|
|
|
59
56
|
// Initialize Humidity Sensor property
|
|
60
57
|
if (!device.iosensor?.hide_humidity) {
|
|
61
58
|
this.HumiditySensor = {
|
|
62
|
-
Service:
|
|
59
|
+
Service: accessory.getService(this.hap.Service.HumiditySensor)!,
|
|
63
60
|
CurrentRelativeHumidity: accessory.context.CurrentRelativeHumidity || 50,
|
|
64
61
|
};
|
|
65
62
|
}
|
|
66
63
|
|
|
67
64
|
// Initialize Battery property
|
|
68
65
|
this.Battery = {
|
|
69
|
-
Service:
|
|
66
|
+
Service: accessory.getService(this.hap.Service.Battery)!,
|
|
70
67
|
BatteryLevel: accessory.context.BatteryLevel || 100,
|
|
71
68
|
StatusLowBattery: accessory.context.StatusLowBattery || this.hap.Characteristic.StatusLowBattery.BATTERY_LEVEL_NORMAL,
|
|
72
69
|
};
|
|
73
70
|
|
|
71
|
+
// Retrieve initial values and updateHomekit
|
|
72
|
+
this.refreshStatus();
|
|
73
|
+
|
|
74
74
|
// Temperature Sensor Service
|
|
75
75
|
if (device.iosensor?.hide_temperature) {
|
|
76
76
|
this.debugLog(`${this.device.deviceType}: ${accessory.displayName} Removing Temperature Sensor Service`);
|
package/src/device/lightstrip.ts
CHANGED
|
@@ -42,12 +42,9 @@ export class StripLight extends deviceBase {
|
|
|
42
42
|
this.doStripLightUpdate = new Subject();
|
|
43
43
|
this.stripLightUpdateInProgress = false;
|
|
44
44
|
|
|
45
|
-
// Retrieve initial values and updateHomekit
|
|
46
|
-
this.refreshStatus();
|
|
47
|
-
|
|
48
45
|
// Initialize the LightBulb property
|
|
49
46
|
this.LightBulb = {
|
|
50
|
-
Service:
|
|
47
|
+
Service: accessory.getService(this.hap.Service.Lightbulb)!,
|
|
51
48
|
On: accessory.context.On || false,
|
|
52
49
|
Hue: accessory.context.Hue || 0,
|
|
53
50
|
Saturation: accessory.context.Saturation || 0,
|
|
@@ -55,6 +52,9 @@ export class StripLight extends deviceBase {
|
|
|
55
52
|
ColorTemperature: accessory.context.ColorTemperature || 140,
|
|
56
53
|
};
|
|
57
54
|
|
|
55
|
+
// Retrieve initial values and updateHomekit
|
|
56
|
+
this.refreshStatus();
|
|
57
|
+
|
|
58
58
|
// get the Lightbulb service if it exists, otherwise create a new Lightbulb service
|
|
59
59
|
// you can create multiple services for each accessory
|
|
60
60
|
const LightBulbService = `${accessory.displayName} ${device.deviceType}`;
|
package/src/device/lock.ts
CHANGED
|
@@ -44,19 +44,16 @@ export class Lock extends deviceBase {
|
|
|
44
44
|
this.doLockUpdate = new Subject();
|
|
45
45
|
this.lockUpdateInProgress = false;
|
|
46
46
|
|
|
47
|
-
// Retrieve initial values and updateHomekit
|
|
48
|
-
this.refreshStatus();
|
|
49
|
-
|
|
50
47
|
// Initialize LockMechanism property
|
|
51
48
|
this.LockMechanism = {
|
|
52
|
-
Service: accessory.
|
|
49
|
+
Service: accessory.getService(this.hap.Service.LockMechanism)!,
|
|
53
50
|
LockTargetState: accessory.context.LockTargetState || this.hap.Characteristic.LockTargetState.SECURED,
|
|
54
51
|
LockCurrentState: accessory.context.LockCurrentState || this.hap.Characteristic.LockCurrentState.SECURED,
|
|
55
52
|
};
|
|
56
53
|
|
|
57
54
|
// Initialize Battery property
|
|
58
55
|
this.Battery = {
|
|
59
|
-
Service: accessory.
|
|
56
|
+
Service: accessory.getService(this.hap.Service.Battery)!,
|
|
60
57
|
BatteryLevel: accessory.context.BatteryLevel || 100,
|
|
61
58
|
StatusLowBattery: accessory.context.StatusLowBattery || this.hap.Characteristic.StatusLowBattery.BATTERY_LEVEL_NORMAL,
|
|
62
59
|
};
|
|
@@ -64,7 +61,7 @@ export class Lock extends deviceBase {
|
|
|
64
61
|
// Initialize ContactSensor property
|
|
65
62
|
if (!this.device.lock?.hide_contactsensor) {
|
|
66
63
|
this.ContactSensor = {
|
|
67
|
-
Service: accessory.
|
|
64
|
+
Service: accessory.getService(this.hap.Service.ContactSensor)!,
|
|
68
65
|
ContactSensorState: accessory.context.ContactSensorState || this.hap.Characteristic.ContactSensorState.CONTACT_DETECTED,
|
|
69
66
|
};
|
|
70
67
|
}
|
|
@@ -72,11 +69,14 @@ export class Lock extends deviceBase {
|
|
|
72
69
|
// Initialize Latch Button Service
|
|
73
70
|
if (device.lock?.activate_latchbutton) {
|
|
74
71
|
this.Switch = {
|
|
75
|
-
Service: accessory.
|
|
72
|
+
Service: accessory.getService(this.hap.Service.Switch)!,
|
|
76
73
|
On: accessory.context.On || false,
|
|
77
74
|
};
|
|
78
75
|
}
|
|
79
76
|
|
|
77
|
+
// Retrieve initial values and updateHomekit
|
|
78
|
+
this.refreshStatus();
|
|
79
|
+
|
|
80
80
|
// get the LockMechanism service if it exists, otherwise create a new LockMechanism service
|
|
81
81
|
// you can create multiple services for each accessory
|
|
82
82
|
const LockMechanismService = `${accessory.displayName} ${device.deviceType}`;
|
package/src/device/meter.ts
CHANGED
|
@@ -40,13 +40,10 @@ export class Meter extends deviceBase {
|
|
|
40
40
|
this.doMeterUpdate = new Subject();
|
|
41
41
|
this.meterUpdateInProgress = false;
|
|
42
42
|
|
|
43
|
-
// Retrieve initial values and updateHomekit
|
|
44
|
-
this.refreshStatus();
|
|
45
|
-
|
|
46
43
|
// Initialize Temperature Sensor property
|
|
47
44
|
if (!device.meter?.hide_temperature) {
|
|
48
45
|
this.TemperatureSensor = {
|
|
49
|
-
Service:
|
|
46
|
+
Service: accessory.getService(this.hap.Service.TemperatureSensor)!,
|
|
50
47
|
CurrentTemperature: accessory.context.CurrentTemperature || 30,
|
|
51
48
|
};
|
|
52
49
|
}
|
|
@@ -54,18 +51,21 @@ export class Meter extends deviceBase {
|
|
|
54
51
|
// Initialize Humidity Sensor property
|
|
55
52
|
if (!device.meter?.hide_humidity) {
|
|
56
53
|
this.HumiditySensor = {
|
|
57
|
-
Service:
|
|
54
|
+
Service: accessory.getService(this.hap.Service.HumiditySensor)!,
|
|
58
55
|
CurrentRelativeHumidity: accessory.context.CurrentRelativeHumidity || 50,
|
|
59
56
|
};
|
|
60
57
|
}
|
|
61
58
|
|
|
62
59
|
// Initialize Battery property
|
|
63
60
|
this.Battery = {
|
|
64
|
-
Service:
|
|
61
|
+
Service: accessory.getService(this.hap.Service.Battery)!,
|
|
65
62
|
BatteryLevel: accessory.context.BatteryLevel || 100,
|
|
66
63
|
StatusLowBattery: accessory.context.StatusLowBattery || this.hap.Characteristic.StatusLowBattery.BATTERY_LEVEL_NORMAL,
|
|
67
64
|
};
|
|
68
65
|
|
|
66
|
+
// Retrieve initial values and updateHomekit
|
|
67
|
+
this.refreshStatus();
|
|
68
|
+
|
|
69
69
|
// Temperature Sensor Service
|
|
70
70
|
if (device.meter?.hide_temperature) {
|
|
71
71
|
this.debugLog(`${this.device.deviceType}: ${accessory.displayName} Removing Temperature Sensor Service`);
|
package/src/device/meterplus.ts
CHANGED
|
@@ -45,13 +45,10 @@ export class MeterPlus extends deviceBase {
|
|
|
45
45
|
this.doMeterUpdate = new Subject();
|
|
46
46
|
this.meterUpdateInProgress = false;
|
|
47
47
|
|
|
48
|
-
// Retrieve initial values and updateHomekit
|
|
49
|
-
this.refreshStatus();
|
|
50
|
-
|
|
51
48
|
// Initialize Temperature Sensor property
|
|
52
49
|
if (!device.meter?.hide_temperature) {
|
|
53
50
|
this.TemperatureSensor = {
|
|
54
|
-
Service:
|
|
51
|
+
Service: accessory.getService(this.hap.Service.TemperatureSensor)!,
|
|
55
52
|
CurrentTemperature: accessory.context.CurrentTemperature || 30,
|
|
56
53
|
};
|
|
57
54
|
}
|
|
@@ -59,18 +56,21 @@ export class MeterPlus extends deviceBase {
|
|
|
59
56
|
// Initialize Humidity Sensor property
|
|
60
57
|
if (!device.meter?.hide_humidity) {
|
|
61
58
|
this.HumiditySensor = {
|
|
62
|
-
Service:
|
|
59
|
+
Service: accessory.getService(this.hap.Service.HumiditySensor)!,
|
|
63
60
|
CurrentRelativeHumidity: accessory.context.CurrentRelativeHumidity || 50,
|
|
64
61
|
};
|
|
65
62
|
}
|
|
66
63
|
|
|
67
64
|
// Initialize Battery property
|
|
68
65
|
this.Battery = {
|
|
69
|
-
Service:
|
|
66
|
+
Service: accessory.getService(this.hap.Service.Battery)!,
|
|
70
67
|
BatteryLevel: accessory.context.BatteryLevel || 100,
|
|
71
68
|
StatusLowBattery: accessory.context.StatusLowBattery || this.hap.Characteristic.StatusLowBattery.BATTERY_LEVEL_NORMAL,
|
|
72
69
|
};
|
|
73
70
|
|
|
71
|
+
// Retrieve initial values and updateHomekit
|
|
72
|
+
this.refreshStatus();
|
|
73
|
+
|
|
74
74
|
// Temperature Sensor Service
|
|
75
75
|
if (device.meter?.hide_temperature) {
|
|
76
76
|
this.debugLog(`${this.device.deviceType}: ${accessory.displayName} Removing Temperature Sensor Service`);
|
package/src/device/motion.ts
CHANGED
|
@@ -46,15 +46,15 @@ export class Motion extends deviceBase {
|
|
|
46
46
|
this.doMotionUpdate = new Subject();
|
|
47
47
|
this.motionUbpdateInProgress = false;
|
|
48
48
|
|
|
49
|
+
// Initialize Motion Sensor property
|
|
50
|
+
this.MotionSensor = {
|
|
51
|
+
Service: accessory.getService(this.hap.Service.MotionSensor)!,
|
|
52
|
+
MotionDetected:accessory.context.MotionDetected || false,
|
|
53
|
+
};
|
|
54
|
+
|
|
49
55
|
// Retrieve initial values and updateHomekit
|
|
50
56
|
this.refreshStatus();
|
|
51
57
|
|
|
52
|
-
if (this.MotionSensor.MotionDetected === undefined) {
|
|
53
|
-
this.MotionSensor.MotionDetected = false;
|
|
54
|
-
} else {
|
|
55
|
-
this.MotionSensor.MotionDetected = this.accessory.context.MotionDetected;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
58
|
// get the Battery service if it exists, otherwise create a new Motion service
|
|
59
59
|
// you can create multiple services for each accessory
|
|
60
60
|
const MotionSensorService = `${accessory.displayName} Motion Sensor`;
|
package/src/device/plug.ts
CHANGED
|
@@ -29,15 +29,15 @@ export class Plug extends deviceBase {
|
|
|
29
29
|
this.doPlugUpdate = new Subject();
|
|
30
30
|
this.plugUpdateInProgress = false;
|
|
31
31
|
|
|
32
|
-
// Retrieve initial values and updateHomekit
|
|
33
|
-
this.refreshStatus();
|
|
34
|
-
|
|
35
32
|
// Initialize Outlet property
|
|
36
33
|
this.Outlet = {
|
|
37
|
-
Service:
|
|
34
|
+
Service: accessory.getService(this.hap.Service.Outlet)!,
|
|
38
35
|
On: accessory.context.On || false,
|
|
39
36
|
};
|
|
40
37
|
|
|
38
|
+
// Retrieve initial values and updateHomekit
|
|
39
|
+
this.refreshStatus();
|
|
40
|
+
|
|
41
41
|
// get the Outlet service if it exists, otherwise create a new Outlet service
|
|
42
42
|
// you can create multiple services for each accessory
|
|
43
43
|
const OutletService = `${accessory.displayName} ${device.deviceType}`;
|