@switchbot/homebridge-switchbot 1.7.0 → 1.7.1-beta.11
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/CHANGELOG.md +17 -0
- package/config.schema.json +101 -33
- package/dist/devices/bots.d.ts +9 -5
- package/dist/devices/bots.d.ts.map +1 -1
- package/dist/devices/bots.js +144 -77
- package/dist/devices/bots.js.map +1 -1
- package/dist/devices/colorbulb.d.ts +9 -4
- package/dist/devices/colorbulb.d.ts.map +1 -1
- package/dist/devices/colorbulb.js +40 -37
- package/dist/devices/colorbulb.js.map +1 -1
- package/dist/devices/contact.d.ts +10 -2
- package/dist/devices/contact.d.ts.map +1 -1
- package/dist/devices/contact.js +92 -51
- package/dist/devices/contact.js.map +1 -1
- package/dist/devices/curtains.d.ts +10 -3
- package/dist/devices/curtains.d.ts.map +1 -1
- package/dist/devices/curtains.js +52 -34
- package/dist/devices/curtains.js.map +1 -1
- package/dist/devices/humidifiers.d.ts +8 -2
- package/dist/devices/humidifiers.d.ts.map +1 -1
- package/dist/devices/humidifiers.js +28 -35
- package/dist/devices/humidifiers.js.map +1 -1
- package/dist/devices/meters.d.ts +14 -12
- package/dist/devices/meters.d.ts.map +1 -1
- package/dist/devices/meters.js +63 -103
- package/dist/devices/meters.js.map +1 -1
- package/dist/devices/motion.d.ts +10 -3
- package/dist/devices/motion.d.ts.map +1 -1
- package/dist/devices/motion.js +114 -68
- package/dist/devices/motion.js.map +1 -1
- package/dist/devices/plugs.d.ts +3 -1
- package/dist/devices/plugs.d.ts.map +1 -1
- package/dist/devices/plugs.js +8 -1
- package/dist/devices/plugs.js.map +1 -1
- package/dist/irdevices/airconditioners.d.ts +1 -0
- package/dist/irdevices/airconditioners.d.ts.map +1 -1
- package/dist/irdevices/airconditioners.js +6 -0
- package/dist/irdevices/airconditioners.js.map +1 -1
- package/dist/irdevices/airpurifiers.d.ts +1 -0
- package/dist/irdevices/airpurifiers.d.ts.map +1 -1
- package/dist/irdevices/airpurifiers.js +6 -0
- package/dist/irdevices/airpurifiers.js.map +1 -1
- package/dist/irdevices/cameras.d.ts +1 -0
- package/dist/irdevices/cameras.d.ts.map +1 -1
- package/dist/irdevices/cameras.js +6 -0
- package/dist/irdevices/cameras.js.map +1 -1
- package/dist/irdevices/fans.d.ts +1 -0
- package/dist/irdevices/fans.d.ts.map +1 -1
- package/dist/irdevices/fans.js +6 -0
- package/dist/irdevices/fans.js.map +1 -1
- package/dist/irdevices/lights.d.ts +1 -0
- package/dist/irdevices/lights.d.ts.map +1 -1
- package/dist/irdevices/lights.js +6 -0
- package/dist/irdevices/lights.js.map +1 -1
- package/dist/irdevices/others.d.ts +1 -0
- package/dist/irdevices/others.d.ts.map +1 -1
- package/dist/irdevices/others.js +6 -0
- package/dist/irdevices/others.js.map +1 -1
- package/dist/irdevices/tvs.d.ts +1 -0
- package/dist/irdevices/tvs.d.ts.map +1 -1
- package/dist/irdevices/tvs.js +6 -0
- package/dist/irdevices/tvs.js.map +1 -1
- package/dist/irdevices/vacuumcleaners.d.ts +1 -0
- package/dist/irdevices/vacuumcleaners.d.ts.map +1 -1
- package/dist/irdevices/vacuumcleaners.js +6 -0
- package/dist/irdevices/vacuumcleaners.js.map +1 -1
- package/dist/irdevices/waterheaters.d.ts +1 -0
- package/dist/irdevices/waterheaters.d.ts.map +1 -1
- package/dist/irdevices/waterheaters.js +6 -0
- package/dist/irdevices/waterheaters.js.map +1 -1
- package/dist/platform.d.ts +2 -1
- package/dist/platform.d.ts.map +1 -1
- package/dist/platform.js +14 -1
- package/dist/platform.js.map +1 -1
- package/dist/settings.d.ts +14 -0
- package/dist/settings.d.ts.map +1 -1
- package/dist/settings.js.map +1 -1
- package/package.json +71 -71
- package/src/devices/bots.ts +140 -74
- package/src/devices/colorbulb.ts +46 -40
- package/src/devices/contact.ts +99 -55
- package/src/devices/curtains.ts +60 -36
- package/src/devices/humidifiers.ts +36 -36
- package/src/devices/meters.ts +79 -113
- package/src/devices/motion.ts +125 -74
- package/src/devices/plugs.ts +11 -2
- package/src/irdevices/airconditioners.ts +7 -0
- package/src/irdevices/airpurifiers.ts +7 -0
- package/src/irdevices/cameras.ts +7 -0
- package/src/irdevices/fans.ts +7 -0
- package/src/irdevices/lights.ts +7 -0
- package/src/irdevices/others.ts +7 -0
- package/src/irdevices/tvs.ts +7 -0
- package/src/irdevices/vacuumcleaners.ts +7 -0
- package/src/irdevices/waterheaters.ts +7 -0
- package/src/platform.ts +14 -1
- package/src/settings.ts +15 -0
package/src/devices/plugs.ts
CHANGED
|
@@ -4,7 +4,7 @@ import { interval, Subject } from 'rxjs';
|
|
|
4
4
|
import { SwitchBotPlatform } from '../platform';
|
|
5
5
|
import { debounceTime, skipWhile, take, tap } from 'rxjs/operators';
|
|
6
6
|
import { Service, PlatformAccessory, CharacteristicValue } from 'homebridge';
|
|
7
|
-
import { DeviceURL, device, devicesConfig, deviceStatusResponse, payload } from '../settings';
|
|
7
|
+
import { DeviceURL, device, devicesConfig, deviceStatusResponse, payload, deviceStatus } from '../settings';
|
|
8
8
|
|
|
9
9
|
export class Plug {
|
|
10
10
|
// Services
|
|
@@ -15,6 +15,7 @@ export class Plug {
|
|
|
15
15
|
OnCached!: CharacteristicValue;
|
|
16
16
|
|
|
17
17
|
// OpenAPI Others
|
|
18
|
+
power: deviceStatus['power'];
|
|
18
19
|
deviceStatus!: deviceStatusResponse;
|
|
19
20
|
|
|
20
21
|
// Config
|
|
@@ -35,6 +36,7 @@ export class Plug {
|
|
|
35
36
|
this.logs();
|
|
36
37
|
this.scan();
|
|
37
38
|
this.refreshRate();
|
|
39
|
+
this.config(device);
|
|
38
40
|
if (this.On === undefined) {
|
|
39
41
|
this.On = false;
|
|
40
42
|
} else {
|
|
@@ -116,6 +118,12 @@ export class Plug {
|
|
|
116
118
|
});
|
|
117
119
|
}
|
|
118
120
|
|
|
121
|
+
config(device: device & devicesConfig) {
|
|
122
|
+
if (device.plug !== undefined) {
|
|
123
|
+
this.warnLog(`Plug: ${this.accessory.displayName} Config: ${JSON.stringify(device.plug)}`);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
|
|
119
127
|
refreshRate() {
|
|
120
128
|
if (this.device.refreshRate) {
|
|
121
129
|
this.deviceRefreshRate = this.accessory.context.refreshRate = this.device.refreshRate;
|
|
@@ -164,7 +172,7 @@ export class Plug {
|
|
|
164
172
|
}
|
|
165
173
|
|
|
166
174
|
parseStatus() {
|
|
167
|
-
switch (this.
|
|
175
|
+
switch (this.power) {
|
|
168
176
|
case 'on':
|
|
169
177
|
this.On = true;
|
|
170
178
|
break;
|
|
@@ -178,6 +186,7 @@ export class Plug {
|
|
|
178
186
|
try {
|
|
179
187
|
this.deviceStatus = (await this.platform.axios.get(`${DeviceURL}/${this.device.deviceId}/status`)).data;
|
|
180
188
|
this.debugLog(`Plug: ${this.accessory.displayName} refreshStatus: ${JSON.stringify(this.deviceStatus)}`);
|
|
189
|
+
this.power = this.deviceStatus.body.power;
|
|
181
190
|
this.parseStatus();
|
|
182
191
|
this.updateHomeKitCharacteristics();
|
|
183
192
|
} catch (e: any) {
|
|
@@ -50,6 +50,7 @@ export class AirConditioner {
|
|
|
50
50
|
) {
|
|
51
51
|
// default placeholders
|
|
52
52
|
this.logs();
|
|
53
|
+
this.config(device);
|
|
53
54
|
if (this.Active === undefined) {
|
|
54
55
|
this.Active = this.platform.Characteristic.Active.INACTIVE;
|
|
55
56
|
} else {
|
|
@@ -166,6 +167,12 @@ export class AirConditioner {
|
|
|
166
167
|
.onSet(this.RotationSpeedSet.bind(this));
|
|
167
168
|
}
|
|
168
169
|
|
|
170
|
+
config(device: irdevice & irDevicesConfig) {
|
|
171
|
+
if (device.irair !== undefined) {
|
|
172
|
+
this.warnLog(`Air Conditioner: ${this.accessory.displayName} Config: ${JSON.stringify(device.irair)}`);
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
|
|
169
176
|
logs() {
|
|
170
177
|
if (this.platform.debugMode) {
|
|
171
178
|
this.deviceLogging = this.accessory.context.logging = 'debug';
|
|
@@ -45,6 +45,7 @@ export class AirPurifier {
|
|
|
45
45
|
) {
|
|
46
46
|
// default placeholders
|
|
47
47
|
this.logs();
|
|
48
|
+
this.config(device);
|
|
48
49
|
if (this.Active === undefined) {
|
|
49
50
|
this.Active = this.platform.Characteristic.Active.INACTIVE;
|
|
50
51
|
} else {
|
|
@@ -87,6 +88,12 @@ export class AirPurifier {
|
|
|
87
88
|
this.service.getCharacteristic(this.platform.Characteristic.TargetAirPurifierState).onSet(this.TargetAirPurifierStateSet.bind(this));
|
|
88
89
|
}
|
|
89
90
|
|
|
91
|
+
config(device: irdevice & irDevicesConfig) {
|
|
92
|
+
if (device.irpur !== undefined) {
|
|
93
|
+
this.warnLog(`Air Purifier: ${this.accessory.displayName} Config: ${JSON.stringify(device.irpur)}`);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
90
97
|
logs() {
|
|
91
98
|
if (this.platform.debugMode) {
|
|
92
99
|
this.deviceLogging = this.accessory.context.logging = 'debug';
|
package/src/irdevices/cameras.ts
CHANGED
|
@@ -26,6 +26,7 @@ export class Camera {
|
|
|
26
26
|
) {
|
|
27
27
|
// default placeholders
|
|
28
28
|
this.logs();
|
|
29
|
+
this.config(device);
|
|
29
30
|
if (this.On === undefined) {
|
|
30
31
|
this.On = false;
|
|
31
32
|
} else {
|
|
@@ -57,6 +58,12 @@ export class Camera {
|
|
|
57
58
|
this.service.getCharacteristic(this.platform.Characteristic.On).onSet(this.OnSet.bind(this));
|
|
58
59
|
}
|
|
59
60
|
|
|
61
|
+
config(device: irdevice & irDevicesConfig) {
|
|
62
|
+
if (device.ircam !== undefined && (this.deviceLogging === 'debug' || this.deviceLogging === 'standard')) {
|
|
63
|
+
this.warnLog(`Camera: ${this.accessory.displayName} Config: ${JSON.stringify(device.ircam)}`);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
60
67
|
logs() {
|
|
61
68
|
if (this.platform.debugMode) {
|
|
62
69
|
this.deviceLogging = this.accessory.context.logging = 'debug';
|
package/src/irdevices/fans.ts
CHANGED
|
@@ -36,6 +36,7 @@ export class Fan {
|
|
|
36
36
|
) {
|
|
37
37
|
// default placeholders
|
|
38
38
|
this.logs();
|
|
39
|
+
this.config(device);
|
|
39
40
|
if (this.Active === undefined) {
|
|
40
41
|
this.Active = this.platform.Characteristic.Active.INACTIVE;
|
|
41
42
|
} else {
|
|
@@ -116,6 +117,12 @@ export class Fan {
|
|
|
116
117
|
}
|
|
117
118
|
}
|
|
118
119
|
|
|
120
|
+
config(device: irdevice & irDevicesConfig) {
|
|
121
|
+
if (device.irfan !== undefined && (this.deviceLogging === 'debug' || this.deviceLogging === 'standard')) {
|
|
122
|
+
this.warnLog(`Fan: ${this.accessory.displayName} Config: ${JSON.stringify(device.irfan)}`);
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
|
|
119
126
|
logs() {
|
|
120
127
|
if (this.platform.debugMode) {
|
|
121
128
|
this.deviceLogging = this.accessory.context.logging = 'debug';
|
package/src/irdevices/lights.ts
CHANGED
|
@@ -26,6 +26,7 @@ export class Light {
|
|
|
26
26
|
) {
|
|
27
27
|
// default placeholders
|
|
28
28
|
this.logs();
|
|
29
|
+
this.config(device);
|
|
29
30
|
if (this.On === undefined) {
|
|
30
31
|
this.On = false;
|
|
31
32
|
} else {
|
|
@@ -72,6 +73,12 @@ export class Light {
|
|
|
72
73
|
});*/
|
|
73
74
|
}
|
|
74
75
|
|
|
76
|
+
config(device: irdevice & irDevicesConfig) {
|
|
77
|
+
if (device.irlight !== undefined) {
|
|
78
|
+
this.warnLog(`Light: ${this.accessory.displayName} Config: ${JSON.stringify(device.irlight)}`);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
75
82
|
logs() {
|
|
76
83
|
if (this.platform.debugMode) {
|
|
77
84
|
this.deviceLogging = this.accessory.context.logging = 'debug';
|
package/src/irdevices/others.ts
CHANGED
|
@@ -28,6 +28,7 @@ export class Others {
|
|
|
28
28
|
// default placeholders
|
|
29
29
|
this.logs();
|
|
30
30
|
this.deviceType();
|
|
31
|
+
this.config(device);
|
|
31
32
|
if (this.Active === undefined) {
|
|
32
33
|
this.Active = this.platform.Characteristic.Active.INACTIVE;
|
|
33
34
|
} else {
|
|
@@ -76,6 +77,12 @@ export class Others {
|
|
|
76
77
|
}
|
|
77
78
|
}
|
|
78
79
|
|
|
80
|
+
config(device: irdevice & irDevicesConfig) {
|
|
81
|
+
if (device.other !== undefined) {
|
|
82
|
+
this.warnLog(`Other: ${this.accessory.displayName} Config: ${JSON.stringify(device.other)}`);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
79
86
|
logs() {
|
|
80
87
|
if (this.platform.debugMode) {
|
|
81
88
|
this.deviceLogging = this.accessory.context.logging = 'debug';
|
package/src/irdevices/tvs.ts
CHANGED
|
@@ -31,6 +31,7 @@ export class TV {
|
|
|
31
31
|
) {
|
|
32
32
|
// default placeholders
|
|
33
33
|
this.logs();
|
|
34
|
+
this.config(device);
|
|
34
35
|
if (this.Active === undefined) {
|
|
35
36
|
this.Active = this.platform.Characteristic.Active.INACTIVE;
|
|
36
37
|
} else {
|
|
@@ -128,6 +129,12 @@ export class TV {
|
|
|
128
129
|
.onSet(this.VolumeSelectorSet.bind(this));
|
|
129
130
|
}
|
|
130
131
|
|
|
132
|
+
config(device: irdevice & irDevicesConfig) {
|
|
133
|
+
if (device.irtv !== undefined) {
|
|
134
|
+
this.warnLog(`${this.device.remoteType}: ${this.accessory.displayName} Config: ${JSON.stringify(device.irtv)}`);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
|
|
131
138
|
logs() {
|
|
132
139
|
if (this.platform.debugMode) {
|
|
133
140
|
this.deviceLogging = this.accessory.context.logging = 'debug';
|
|
@@ -26,6 +26,7 @@ export class VacuumCleaner {
|
|
|
26
26
|
) {
|
|
27
27
|
// default placeholders
|
|
28
28
|
this.logs();
|
|
29
|
+
this.config(device);
|
|
29
30
|
if (this.On === undefined) {
|
|
30
31
|
this.On = false;
|
|
31
32
|
} else {
|
|
@@ -57,6 +58,12 @@ export class VacuumCleaner {
|
|
|
57
58
|
this.service.getCharacteristic(this.platform.Characteristic.On).onSet(this.OnSet.bind(this));
|
|
58
59
|
}
|
|
59
60
|
|
|
61
|
+
config(device: irdevice & irDevicesConfig) {
|
|
62
|
+
if (device.irvc !== undefined) {
|
|
63
|
+
this.warnLog(`Vacuum Cleaner: ${this.accessory.displayName} Config: ${JSON.stringify(device.irvc)}`);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
60
67
|
logs() {
|
|
61
68
|
if (this.platform.debugMode) {
|
|
62
69
|
this.deviceLogging = this.accessory.context.logging = 'debug';
|
|
@@ -26,6 +26,7 @@ export class WaterHeater {
|
|
|
26
26
|
) {
|
|
27
27
|
// default placeholders
|
|
28
28
|
this.logs();
|
|
29
|
+
this.config(device);
|
|
29
30
|
if (this.Active === undefined) {
|
|
30
31
|
this.Active = this.platform.Characteristic.Active.INACTIVE;
|
|
31
32
|
} else {
|
|
@@ -66,6 +67,12 @@ export class WaterHeater {
|
|
|
66
67
|
this.service.getCharacteristic(this.platform.Characteristic.Active).onSet(this.ActiveSet.bind(this));
|
|
67
68
|
}
|
|
68
69
|
|
|
70
|
+
config(device: irdevice & irDevicesConfig) {
|
|
71
|
+
if (device.irwh !== undefined) {
|
|
72
|
+
this.warnLog(`Water Heater: ${this.accessory.displayName} Config: ${JSON.stringify(device.irwh)}`);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
69
76
|
logs() {
|
|
70
77
|
if (this.platform.debugMode) {
|
|
71
78
|
this.deviceLogging = this.accessory.context.logging = 'debug';
|
package/src/platform.ts
CHANGED
|
@@ -192,8 +192,21 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
192
192
|
}
|
|
193
193
|
}
|
|
194
194
|
|
|
195
|
+
connectBLE() {
|
|
196
|
+
let Switchbot: new () => any;
|
|
197
|
+
let switchbot: any;
|
|
198
|
+
try {
|
|
199
|
+
Switchbot = require('node-switchbot');
|
|
200
|
+
switchbot = new Switchbot();
|
|
201
|
+
} catch (e) {
|
|
202
|
+
switchbot = false;
|
|
203
|
+
this.errorLog(`Was 'node-switchbot' found: ${switchbot}`);
|
|
204
|
+
}
|
|
205
|
+
return switchbot;
|
|
206
|
+
}
|
|
207
|
+
|
|
195
208
|
/**
|
|
196
|
-
* this method discovers
|
|
209
|
+
* this method discovers devices
|
|
197
210
|
*/
|
|
198
211
|
async discoverDevices() {
|
|
199
212
|
try {
|
package/src/settings.ts
CHANGED
|
@@ -48,7 +48,9 @@ export interface devicesConfig extends device {
|
|
|
48
48
|
humidifier?: humidifier;
|
|
49
49
|
curtain?: curtain;
|
|
50
50
|
contact?: contact;
|
|
51
|
+
motion?: motion;
|
|
51
52
|
colorbulb?: colorbulb;
|
|
53
|
+
plug?: undefined;
|
|
52
54
|
ble?: string;
|
|
53
55
|
scanDuration?: number;
|
|
54
56
|
hide_device?: boolean;
|
|
@@ -84,9 +86,17 @@ export type curtain = {
|
|
|
84
86
|
|
|
85
87
|
export type contact = {
|
|
86
88
|
hide_lightsensor?: boolean;
|
|
89
|
+
set_minLux?: number;
|
|
90
|
+
set_maxLux?: number;
|
|
87
91
|
hide_motionsensor?: boolean;
|
|
88
92
|
};
|
|
89
93
|
|
|
94
|
+
export type motion = {
|
|
95
|
+
hide_lightsensor?: boolean;
|
|
96
|
+
set_minLux?: number;
|
|
97
|
+
set_maxLux?: number;
|
|
98
|
+
};
|
|
99
|
+
|
|
90
100
|
export type colorbulb = {
|
|
91
101
|
set_minStep?: number;
|
|
92
102
|
adaptiveLightingShift?: number;
|
|
@@ -98,6 +108,11 @@ export interface irDevicesConfig extends irdevice {
|
|
|
98
108
|
logging?: string;
|
|
99
109
|
irfan?: irfan;
|
|
100
110
|
irair?: irair;
|
|
111
|
+
irpur?: undefined;
|
|
112
|
+
ircam?: undefined;
|
|
113
|
+
irlight?: undefined;
|
|
114
|
+
irvc?: undefined;
|
|
115
|
+
irwh?: undefined;
|
|
101
116
|
irtv?: irtv;
|
|
102
117
|
other?: other;
|
|
103
118
|
hide_device?: boolean;
|