@switchbot/homebridge-switchbot 0.2.0-alpha.2 → 1.0.1-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/workflows/nodejs-beta.yml +1 -1
- package/.github/workflows/nodejs.yml +1 -1
- package/.github/workflows/{prerelease.js → prerelease-beta.js} +0 -0
- package/CHANGELOG.md +1 -1
- package/README.md +9 -5
- package/config.schema.json +370 -142
- package/dist/devices/bots.d.ts +18 -34
- package/dist/devices/bots.d.ts.map +1 -1
- package/dist/devices/bots.js +166 -171
- package/dist/devices/bots.js.map +1 -1
- package/dist/devices/{bulb.d.ts → colorbulb.d.ts} +12 -19
- package/dist/devices/colorbulb.d.ts.map +1 -0
- package/dist/devices/{bulb.js → colorbulb.js} +34 -32
- package/dist/devices/colorbulb.js.map +1 -0
- package/dist/devices/contact.d.ts +18 -16
- package/dist/devices/contact.d.ts.map +1 -1
- package/dist/devices/contact.js +101 -44
- package/dist/devices/contact.js.map +1 -1
- package/dist/devices/curtains.d.ts +17 -51
- package/dist/devices/curtains.d.ts.map +1 -1
- package/dist/devices/curtains.js +170 -248
- package/dist/devices/curtains.js.map +1 -1
- package/dist/devices/humidifiers.d.ts +13 -4
- package/dist/devices/humidifiers.d.ts.map +1 -1
- package/dist/devices/humidifiers.js +81 -8
- package/dist/devices/humidifiers.js.map +1 -1
- package/dist/devices/indoorcam.d.ts +6 -13
- package/dist/devices/indoorcam.d.ts.map +1 -1
- package/dist/devices/indoorcam.js.map +1 -1
- package/dist/devices/meters.d.ts +12 -15
- package/dist/devices/meters.d.ts.map +1 -1
- package/dist/devices/meters.js +38 -44
- package/dist/devices/meters.js.map +1 -1
- package/dist/devices/motion.d.ts +17 -15
- package/dist/devices/motion.d.ts.map +1 -1
- package/dist/devices/motion.js +87 -40
- package/dist/devices/motion.js.map +1 -1
- package/dist/devices/plugs.d.ts +6 -13
- package/dist/devices/plugs.d.ts.map +1 -1
- package/dist/devices/plugs.js.map +1 -1
- package/dist/irdevices/airconditioners.d.ts +10 -10
- package/dist/irdevices/airconditioners.d.ts.map +1 -1
- package/dist/irdevices/airconditioners.js +29 -9
- package/dist/irdevices/airconditioners.js.map +1 -1
- package/dist/irdevices/airpurifiers.d.ts +11 -11
- package/dist/irdevices/airpurifiers.d.ts.map +1 -1
- package/dist/irdevices/airpurifiers.js.map +1 -1
- package/dist/irdevices/cameras.d.ts +3 -3
- package/dist/irdevices/cameras.d.ts.map +1 -1
- package/dist/irdevices/cameras.js.map +1 -1
- package/dist/irdevices/fans.d.ts +6 -6
- package/dist/irdevices/fans.d.ts.map +1 -1
- package/dist/irdevices/fans.js +10 -10
- package/dist/irdevices/fans.js.map +1 -1
- package/dist/irdevices/lights.d.ts +3 -3
- package/dist/irdevices/lights.d.ts.map +1 -1
- package/dist/irdevices/lights.js.map +1 -1
- package/dist/irdevices/others.d.ts +3 -3
- package/dist/irdevices/others.d.ts.map +1 -1
- package/dist/irdevices/others.js.map +1 -1
- package/dist/irdevices/tvs.d.ts +3 -3
- package/dist/irdevices/tvs.d.ts.map +1 -1
- package/dist/irdevices/tvs.js +7 -5
- package/dist/irdevices/tvs.js.map +1 -1
- package/dist/irdevices/vacuumcleaners.d.ts +3 -3
- package/dist/irdevices/vacuumcleaners.d.ts.map +1 -1
- package/dist/irdevices/vacuumcleaners.js.map +1 -1
- package/dist/irdevices/waterheaters.d.ts +3 -3
- package/dist/irdevices/waterheaters.d.ts.map +1 -1
- package/dist/irdevices/waterheaters.js.map +1 -1
- package/dist/platform.d.ts +3 -2
- package/dist/platform.d.ts.map +1 -1
- package/dist/platform.js +136 -46
- package/dist/platform.js.map +1 -1
- package/dist/settings.d.ts +51 -8
- package/dist/settings.d.ts.map +1 -1
- package/package.json +65 -65
- package/src/devices/bots.ts +188 -193
- package/src/devices/{bulb.ts → colorbulb.ts} +46 -51
- package/src/devices/contact.ts +124 -68
- package/src/devices/curtains.ts +192 -300
- package/src/devices/humidifiers.ts +97 -14
- package/src/devices/indoorcam.ts +10 -20
- package/src/devices/meters.ts +57 -69
- package/src/devices/motion.ts +108 -62
- package/src/devices/plugs.ts +8 -19
- package/src/irdevices/airconditioners.ts +43 -20
- package/src/irdevices/airpurifiers.ts +15 -11
- package/src/irdevices/cameras.ts +5 -3
- package/src/irdevices/fans.ts +22 -16
- package/src/irdevices/lights.ts +5 -3
- package/src/irdevices/others.ts +5 -3
- package/src/irdevices/tvs.ts +13 -7
- package/src/irdevices/vacuumcleaners.ts +5 -3
- package/src/irdevices/waterheaters.ts +5 -3
- package/src/platform.ts +148 -49
- package/src/settings.ts +80 -8
- package/dist/devices/bulb.d.ts.map +0 -1
- package/dist/devices/bulb.js.map +0 -1
package/src/devices/plugs.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { Service, PlatformAccessory, CharacteristicValue
|
|
1
|
+
import { Service, PlatformAccessory, CharacteristicValue } from 'homebridge';
|
|
2
2
|
import { SwitchBotPlatform } from '../platform';
|
|
3
3
|
import { interval, Subject } from 'rxjs';
|
|
4
4
|
import { debounceTime, skipWhile, tap } from 'rxjs/operators';
|
|
5
|
-
import { DeviceURL, device, devicesConfig } from '../settings';
|
|
5
|
+
import { DeviceURL, device, devicesConfig, switchbot, deviceStatusResponse } from '../settings';
|
|
6
6
|
|
|
7
7
|
export class Plug {
|
|
8
8
|
// Services
|
|
@@ -12,26 +12,15 @@ export class Plug {
|
|
|
12
12
|
On!: CharacteristicValue;
|
|
13
13
|
OutletInUse!: CharacteristicValue;
|
|
14
14
|
|
|
15
|
-
// Others
|
|
16
|
-
deviceStatus!:
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
{
|
|
21
|
-
duration: any;
|
|
22
|
-
model: string;
|
|
23
|
-
quick: boolean;
|
|
24
|
-
id: MacAddress;
|
|
25
|
-
}
|
|
26
|
-
) => Promise<any>;
|
|
27
|
-
wait: (
|
|
28
|
-
arg0: number
|
|
29
|
-
) => any;
|
|
30
|
-
};
|
|
15
|
+
// OpenAPI Others
|
|
16
|
+
deviceStatus!: deviceStatusResponse;
|
|
17
|
+
|
|
18
|
+
// BLE Others
|
|
19
|
+
switchbot!: switchbot;
|
|
31
20
|
|
|
32
21
|
// Updates
|
|
33
22
|
plugUpdateInProgress!: boolean;
|
|
34
|
-
doPlugUpdate
|
|
23
|
+
doPlugUpdate!: Subject<void>;
|
|
35
24
|
|
|
36
25
|
constructor(
|
|
37
26
|
private readonly platform: SwitchBotPlatform,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { AxiosResponse } from 'axios';
|
|
2
2
|
import { CharacteristicValue, PlatformAccessory, Service } from 'homebridge';
|
|
3
3
|
import { SwitchBotPlatform } from '../platform';
|
|
4
|
-
import {
|
|
4
|
+
import { irDevicesConfig, DeviceURL, irdevice } from '../settings';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Platform Accessory
|
|
@@ -9,31 +9,37 @@ import { devicesConfig, DeviceURL, irdevice } from '../settings';
|
|
|
9
9
|
* Each accessory may expose multiple services of different service types.
|
|
10
10
|
*/
|
|
11
11
|
export class AirConditioner {
|
|
12
|
+
// Services
|
|
12
13
|
service!: Service;
|
|
13
14
|
|
|
15
|
+
// Characteristic Values
|
|
14
16
|
Active!: CharacteristicValue;
|
|
17
|
+
ARActive!: CharacteristicValue;
|
|
15
18
|
RotationSpeed!: CharacteristicValue;
|
|
16
|
-
CurrentHeaterCoolerState!: CharacteristicValue;
|
|
17
|
-
CurrentTemperature!: CharacteristicValue;
|
|
18
19
|
CurrentARTemp!: CharacteristicValue;
|
|
19
20
|
CurrentARMode!: CharacteristicValue;
|
|
21
|
+
LastTemperature!: CharacteristicValue;
|
|
20
22
|
CurrentARFanSpeed!: CharacteristicValue;
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
23
|
+
CurrentTemperature!: CharacteristicValue;
|
|
24
|
+
CurrentHeaterCoolerState!: CharacteristicValue;
|
|
25
|
+
|
|
26
|
+
// Others
|
|
25
27
|
Busy: any;
|
|
26
28
|
Timeout: any = null;
|
|
29
|
+
CurrentMode!: number;
|
|
30
|
+
ValidValues: number[];
|
|
31
|
+
CurrentFanSpeed!: number;
|
|
27
32
|
static MODE_AUTO: number;
|
|
28
33
|
static MODE_COOL: number;
|
|
29
34
|
static MODE_HEAT: number;
|
|
30
|
-
ValidValues: number[];
|
|
31
35
|
|
|
32
36
|
constructor(
|
|
33
37
|
private readonly platform: SwitchBotPlatform,
|
|
34
38
|
private accessory: PlatformAccessory,
|
|
35
|
-
public device: irdevice &
|
|
39
|
+
public device: irdevice & irDevicesConfig,
|
|
36
40
|
) {
|
|
41
|
+
this.CurrentTemperature = 24;
|
|
42
|
+
|
|
37
43
|
// set accessory information
|
|
38
44
|
accessory
|
|
39
45
|
.getService(this.platform.Service.AccessoryInformation)!
|
|
@@ -66,7 +72,8 @@ export class AirConditioner {
|
|
|
66
72
|
minStep: 0.01,
|
|
67
73
|
})
|
|
68
74
|
.onGet((value: CharacteristicValue) => {
|
|
69
|
-
|
|
75
|
+
this.platform.device(`onGet: ${this.CurrentTemperature}`);
|
|
76
|
+
return this.CurrentTemperatureGet(value);
|
|
70
77
|
});
|
|
71
78
|
|
|
72
79
|
if (device.irair?.hide_automode) {
|
|
@@ -158,15 +165,17 @@ export class AirConditioner {
|
|
|
158
165
|
|
|
159
166
|
private CurrentTemperatureGet(value: CharacteristicValue) {
|
|
160
167
|
this.platform.debug('Trigger Get CurrentTemperture');
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
this.
|
|
168
|
+
if (this.CurrentTemperature) {
|
|
169
|
+
this.CurrentTemperature;
|
|
170
|
+
this.service
|
|
171
|
+
.getCharacteristic(this.platform.Characteristic.CurrentTemperature).updateValue(this.CurrentTemperature);
|
|
164
172
|
} else {
|
|
173
|
+
this.CurrentTemperature = 24;
|
|
165
174
|
this.service
|
|
166
|
-
.getCharacteristic(this.platform.Characteristic.CurrentTemperature)
|
|
167
|
-
.updateValue(Number(this.CurrentTemperature) || 24);
|
|
175
|
+
.getCharacteristic(this.platform.Characteristic.CurrentTemperature).updateValue(this.CurrentTemperature);
|
|
168
176
|
}
|
|
169
|
-
|
|
177
|
+
|
|
178
|
+
return (this.CurrentTemperature = value);
|
|
170
179
|
}
|
|
171
180
|
|
|
172
181
|
private TargetHeaterCoolerStateSet(value: CharacteristicValue) {
|
|
@@ -196,18 +205,32 @@ export class AirConditioner {
|
|
|
196
205
|
} else {
|
|
197
206
|
this.CurrentHeaterCoolerState = this.platform.Characteristic.CurrentHeaterCoolerState.INACTIVE;
|
|
198
207
|
}
|
|
208
|
+
this.platform.device(`CurrentHeaterCoolerStateGet: ${this.CurrentHeaterCoolerState}`);
|
|
199
209
|
return this.CurrentHeaterCoolerState;
|
|
200
210
|
}
|
|
201
211
|
|
|
202
212
|
private HeatingThresholdTemperatureGet() {
|
|
203
|
-
|
|
213
|
+
if (this.CurrentTemperature) {
|
|
214
|
+
this.CurrentTemperature;
|
|
215
|
+
} else {
|
|
216
|
+
this.CurrentTemperature = 24;
|
|
217
|
+
}
|
|
218
|
+
this.platform.device(`HeatingThresholdTemperatureGet: ${this.CurrentTemperature}`);
|
|
204
219
|
return this.CurrentTemperature;
|
|
205
220
|
}
|
|
206
221
|
|
|
207
222
|
private HeatingThresholdTemperatureSet(value: CharacteristicValue) {
|
|
223
|
+
this.platform.device(`Before HeatingThresholdTemperatureSet CurrentTemperature: ${this.CurrentTemperature},`
|
|
224
|
+
+ ` HeatingThresholdTemperatureSet LastTemperature: ${this.LastTemperature}`);
|
|
208
225
|
this.pushAirConditionerStatusChanges();
|
|
209
|
-
this.LastTemperature =
|
|
210
|
-
this.CurrentTemperature
|
|
226
|
+
this.LastTemperature = this.CurrentTemperature;
|
|
227
|
+
if (this.CurrentTemperature) {
|
|
228
|
+
this.CurrentTemperature = value;
|
|
229
|
+
} else {
|
|
230
|
+
this.CurrentTemperature = 24;
|
|
231
|
+
}
|
|
232
|
+
this.platform.device(`After HeatingThresholdTemperatureSet CurrentTemperature: ${this.CurrentTemperature},`
|
|
233
|
+
+ ` HeatingThresholdTemperatureSet LastTemperature: ${this.LastTemperature}`);
|
|
211
234
|
}
|
|
212
235
|
|
|
213
236
|
/**
|
|
@@ -313,7 +336,7 @@ export class AirConditioner {
|
|
|
313
336
|
}
|
|
314
337
|
}
|
|
315
338
|
|
|
316
|
-
private statusCode(push: AxiosResponse<
|
|
339
|
+
private statusCode(push: AxiosResponse<{ statusCode: number;}>) {
|
|
317
340
|
switch (push.data.statusCode) {
|
|
318
341
|
case 151:
|
|
319
342
|
this.platform.log.error('Command not supported by this device type.');
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { AxiosResponse } from 'axios';
|
|
2
2
|
import { CharacteristicValue, PlatformAccessory, Service } from 'homebridge';
|
|
3
3
|
import { SwitchBotPlatform } from '../platform';
|
|
4
|
-
import {
|
|
4
|
+
import { irDevicesConfig, DeviceURL, irdevice } from '../settings';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Platform Accessory
|
|
@@ -9,29 +9,33 @@ import { devicesConfig, DeviceURL, irdevice } from '../settings';
|
|
|
9
9
|
* Each accessory may expose multiple services of different service types.
|
|
10
10
|
*/
|
|
11
11
|
export class AirPurifier {
|
|
12
|
+
// Services
|
|
12
13
|
service!: Service;
|
|
13
14
|
|
|
15
|
+
// Characteristic Values
|
|
14
16
|
Active!: CharacteristicValue;
|
|
15
|
-
|
|
16
|
-
CurrentAirPurifierState!: CharacteristicValue;
|
|
17
|
-
CurrentTemperature!: CharacteristicValue;
|
|
17
|
+
APActive!: CharacteristicValue;
|
|
18
18
|
CurrentAPTemp!: CharacteristicValue;
|
|
19
19
|
CurrentAPMode!: CharacteristicValue;
|
|
20
|
+
RotationSpeed!: CharacteristicValue;
|
|
20
21
|
CurrentAPFanSpeed!: CharacteristicValue;
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
22
|
+
CurrentTemperature!: CharacteristicValue;
|
|
23
|
+
CurrentAirPurifierState!: CharacteristicValue;
|
|
24
|
+
|
|
25
|
+
// Others
|
|
25
26
|
Busy: any;
|
|
26
27
|
Timeout: any = null;
|
|
27
|
-
static PURIFYING_AIR: number;
|
|
28
28
|
static IDLE: number;
|
|
29
|
+
CurrentMode!: number;
|
|
29
30
|
static INACTIVE: number;
|
|
31
|
+
LastTemperature!: number;
|
|
32
|
+
CurrentFanSpeed!: number;
|
|
33
|
+
static PURIFYING_AIR: number;
|
|
30
34
|
|
|
31
35
|
constructor(
|
|
32
36
|
private readonly platform: SwitchBotPlatform,
|
|
33
37
|
private accessory: PlatformAccessory,
|
|
34
|
-
public device: irdevice &
|
|
38
|
+
public device: irdevice & irDevicesConfig,
|
|
35
39
|
) {
|
|
36
40
|
// set accessory information
|
|
37
41
|
accessory
|
|
@@ -206,7 +210,7 @@ export class AirPurifier {
|
|
|
206
210
|
}
|
|
207
211
|
}
|
|
208
212
|
|
|
209
|
-
private statusCode(push: AxiosResponse<
|
|
213
|
+
private statusCode(push: AxiosResponse<{ statusCode: number;}>) {
|
|
210
214
|
switch (push.data.statusCode) {
|
|
211
215
|
case 151:
|
|
212
216
|
this.platform.log.error('Command not supported by this device type.');
|
package/src/irdevices/cameras.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { AxiosResponse } from 'axios';
|
|
2
2
|
import { CharacteristicValue, PlatformAccessory, Service } from 'homebridge';
|
|
3
3
|
import { SwitchBotPlatform } from '../platform';
|
|
4
|
-
import {
|
|
4
|
+
import { irDevicesConfig, DeviceURL, irdevice } from '../settings';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Platform Accessory
|
|
@@ -9,14 +9,16 @@ import { devicesConfig, DeviceURL, irdevice } from '../settings';
|
|
|
9
9
|
* Each accessory may expose multiple services of different service types.
|
|
10
10
|
*/
|
|
11
11
|
export class Camera {
|
|
12
|
+
// Services
|
|
12
13
|
service!: Service;
|
|
13
14
|
|
|
15
|
+
// Characteristic Values
|
|
14
16
|
On!: CharacteristicValue;
|
|
15
17
|
|
|
16
18
|
constructor(
|
|
17
19
|
private readonly platform: SwitchBotPlatform,
|
|
18
20
|
private accessory: PlatformAccessory,
|
|
19
|
-
public device: irdevice &
|
|
21
|
+
public device: irdevice & irDevicesConfig,
|
|
20
22
|
) {
|
|
21
23
|
// set accessory information
|
|
22
24
|
accessory
|
|
@@ -108,7 +110,7 @@ export class Camera {
|
|
|
108
110
|
}
|
|
109
111
|
}
|
|
110
112
|
|
|
111
|
-
private statusCode(push: AxiosResponse<
|
|
113
|
+
private statusCode(push: AxiosResponse<{ statusCode: number;}>) {
|
|
112
114
|
switch (push.data.statusCode) {
|
|
113
115
|
case 151:
|
|
114
116
|
this.platform.log.error('Command not supported by this device type.');
|
package/src/irdevices/fans.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { AxiosResponse } from 'axios';
|
|
2
2
|
import { CharacteristicValue, PlatformAccessory, Service } from 'homebridge';
|
|
3
3
|
import { SwitchBotPlatform } from '../platform';
|
|
4
|
-
import { DeviceURL, irdevice, deviceStatusResponse,
|
|
4
|
+
import { DeviceURL, irdevice, deviceStatusResponse, irDevicesConfig } from '../settings';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Platform Accessory
|
|
@@ -9,22 +9,28 @@ import { DeviceURL, irdevice, deviceStatusResponse, devicesConfig } from '../set
|
|
|
9
9
|
* Each accessory may expose multiple services of different service types.
|
|
10
10
|
*/
|
|
11
11
|
export class Fan {
|
|
12
|
+
// Services
|
|
12
13
|
service!: Service;
|
|
13
14
|
|
|
15
|
+
// Characteristic Values
|
|
14
16
|
Active!: CharacteristicValue;
|
|
15
17
|
ActiveIdentifier!: CharacteristicValue;
|
|
16
18
|
RotationSpeed!: CharacteristicValue;
|
|
17
19
|
SwingMode!: CharacteristicValue;
|
|
18
20
|
RotationDirection!: CharacteristicValue;
|
|
21
|
+
|
|
22
|
+
// Others
|
|
19
23
|
deviceStatus!: deviceStatusResponse;
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
24
|
+
|
|
25
|
+
// Config
|
|
26
|
+
minStep?: number;
|
|
27
|
+
minValue?: number;
|
|
28
|
+
maxValue?: number;
|
|
23
29
|
|
|
24
30
|
constructor(
|
|
25
31
|
private readonly platform: SwitchBotPlatform,
|
|
26
32
|
private accessory: PlatformAccessory,
|
|
27
|
-
public device: irdevice &
|
|
33
|
+
public device: irdevice & irDevicesConfig,
|
|
28
34
|
) {
|
|
29
35
|
// set accessory information
|
|
30
36
|
accessory
|
|
@@ -50,19 +56,19 @@ export class Fan {
|
|
|
50
56
|
// handle on / off events using the Active characteristic
|
|
51
57
|
this.service.getCharacteristic(this.platform.Characteristic.Active).onSet(this.ActiveSet.bind(this));
|
|
52
58
|
|
|
53
|
-
if (device.
|
|
54
|
-
if (device.
|
|
55
|
-
this.minStep = device.
|
|
59
|
+
if (device.irfan?.rotation_speed) {
|
|
60
|
+
if (device.irfan?.set_minStep) {
|
|
61
|
+
this.minStep = device.irfan?.set_minStep;
|
|
56
62
|
} else {
|
|
57
63
|
this.minStep = 1;
|
|
58
64
|
}
|
|
59
|
-
if (device.
|
|
60
|
-
this.minValue = device.
|
|
65
|
+
if (device.irfan?.set_min) {
|
|
66
|
+
this.minValue = device.irfan?.set_min;
|
|
61
67
|
} else {
|
|
62
68
|
this.minValue = 1;
|
|
63
69
|
}
|
|
64
|
-
if (device.
|
|
65
|
-
this.maxValue = device.
|
|
70
|
+
if (device.irfan?.set_max) {
|
|
71
|
+
this.maxValue = device.irfan?.set_max;
|
|
66
72
|
} else {
|
|
67
73
|
this.maxValue = 100;
|
|
68
74
|
}
|
|
@@ -77,7 +83,7 @@ export class Fan {
|
|
|
77
83
|
.onSet(this.RotationSpeedSet.bind(this));
|
|
78
84
|
} else if (
|
|
79
85
|
this.service.testCharacteristic(this.platform.Characteristic.RotationSpeed) &&
|
|
80
|
-
!device.
|
|
86
|
+
!device.irfan?.swing_mode) {
|
|
81
87
|
const characteristic = this.service.getCharacteristic(this.platform.Characteristic.RotationSpeed);
|
|
82
88
|
this.service.removeCharacteristic(characteristic);
|
|
83
89
|
this.platform.log.warn('Rotation Speed Characteristic was removed.');
|
|
@@ -87,10 +93,10 @@ export class Fan {
|
|
|
87
93
|
);
|
|
88
94
|
}
|
|
89
95
|
|
|
90
|
-
if (device.
|
|
96
|
+
if (device.irfan?.swing_mode) {
|
|
91
97
|
// handle Osolcation events using the SwingMode characteristic
|
|
92
98
|
this.service.getCharacteristic(this.platform.Characteristic.SwingMode).onSet(this.SwingModeSet.bind(this));
|
|
93
|
-
} else if (this.service.testCharacteristic(this.platform.Characteristic.SwingMode) && !device.
|
|
99
|
+
} else if (this.service.testCharacteristic(this.platform.Characteristic.SwingMode) && !device.irfan?.swing_mode) {
|
|
94
100
|
const characteristic = this.service.getCharacteristic(this.platform.Characteristic.SwingMode);
|
|
95
101
|
this.service.removeCharacteristic(characteristic);
|
|
96
102
|
this.platform.log.warn('Swing Mode Characteristic was removed.');
|
|
@@ -226,7 +232,7 @@ export class Fan {
|
|
|
226
232
|
}
|
|
227
233
|
}
|
|
228
234
|
|
|
229
|
-
private statusCode(push: AxiosResponse<
|
|
235
|
+
private statusCode(push: AxiosResponse<{ statusCode: number;}>) {
|
|
230
236
|
switch (push.data.statusCode) {
|
|
231
237
|
case 151:
|
|
232
238
|
this.platform.log.error('Command not supported by this device type.');
|
package/src/irdevices/lights.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { AxiosResponse } from 'axios';
|
|
2
2
|
import { CharacteristicValue, PlatformAccessory, Service } from 'homebridge';
|
|
3
3
|
import { SwitchBotPlatform } from '../platform';
|
|
4
|
-
import {
|
|
4
|
+
import { irDevicesConfig, DeviceURL, irdevice } from '../settings';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Platform Accessory
|
|
@@ -9,14 +9,16 @@ import { devicesConfig, DeviceURL, irdevice } from '../settings';
|
|
|
9
9
|
* Each accessory may expose multiple services of different service types.
|
|
10
10
|
*/
|
|
11
11
|
export class Light {
|
|
12
|
+
// Services
|
|
12
13
|
service!: Service;
|
|
13
14
|
|
|
15
|
+
// Characteristic Values
|
|
14
16
|
On!: CharacteristicValue;
|
|
15
17
|
|
|
16
18
|
constructor(
|
|
17
19
|
private readonly platform: SwitchBotPlatform,
|
|
18
20
|
private accessory: PlatformAccessory,
|
|
19
|
-
public device: irdevice &
|
|
21
|
+
public device: irdevice & irDevicesConfig,
|
|
20
22
|
) {
|
|
21
23
|
// set accessory information
|
|
22
24
|
accessory
|
|
@@ -143,7 +145,7 @@ export class Light {
|
|
|
143
145
|
}
|
|
144
146
|
|
|
145
147
|
|
|
146
|
-
private statusCode(push: AxiosResponse<
|
|
148
|
+
private statusCode(push: AxiosResponse<{ statusCode: number;}>) {
|
|
147
149
|
switch (push.data.statusCode) {
|
|
148
150
|
case 151:
|
|
149
151
|
this.platform.log.error('Command not supported by this device type.');
|
package/src/irdevices/others.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { AxiosResponse } from 'axios';
|
|
2
2
|
import { CharacteristicValue, PlatformAccessory, Service } from 'homebridge';
|
|
3
3
|
import { SwitchBotPlatform } from '../platform';
|
|
4
|
-
import {
|
|
4
|
+
import { irDevicesConfig, DeviceURL, irdevice } from '../settings';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Platform Accessory
|
|
@@ -9,14 +9,16 @@ import { devicesConfig, DeviceURL, irdevice } from '../settings';
|
|
|
9
9
|
* Each accessory may expose multiple services of different service types.
|
|
10
10
|
*/
|
|
11
11
|
export class Others {
|
|
12
|
+
// Services
|
|
12
13
|
private service?: Service;
|
|
13
14
|
|
|
15
|
+
// Characteristic Values
|
|
14
16
|
Active!: CharacteristicValue;
|
|
15
17
|
|
|
16
18
|
constructor(
|
|
17
19
|
private readonly platform: SwitchBotPlatform,
|
|
18
20
|
private accessory: PlatformAccessory,
|
|
19
|
-
public device: irdevice &
|
|
21
|
+
public device: irdevice & irDevicesConfig,
|
|
20
22
|
) {
|
|
21
23
|
// set accessory information
|
|
22
24
|
accessory
|
|
@@ -129,7 +131,7 @@ export class Others {
|
|
|
129
131
|
}
|
|
130
132
|
}
|
|
131
133
|
|
|
132
|
-
private statusCode(push: AxiosResponse<
|
|
134
|
+
private statusCode(push: AxiosResponse<{ statusCode: number;}>) {
|
|
133
135
|
switch (push.data.statusCode) {
|
|
134
136
|
case 151:
|
|
135
137
|
this.platform.log.error('Command not supported by this device type.');
|
package/src/irdevices/tvs.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { AxiosResponse } from 'axios';
|
|
2
2
|
import { CharacteristicValue, PlatformAccessory, Service } from 'homebridge';
|
|
3
3
|
import { SwitchBotPlatform } from '../platform';
|
|
4
|
-
import { DeviceURL, irdevice, deviceStatusResponse,
|
|
4
|
+
import { DeviceURL, irdevice, deviceStatusResponse, irDevicesConfig } from '../settings';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Platform Accessory
|
|
@@ -9,17 +9,21 @@ import { DeviceURL, irdevice, deviceStatusResponse, devicesConfig } from '../set
|
|
|
9
9
|
* Each accessory may expose multiple services of different service types.
|
|
10
10
|
*/
|
|
11
11
|
export class TV {
|
|
12
|
+
// Services
|
|
12
13
|
service!: Service;
|
|
13
14
|
speakerService: Service;
|
|
14
15
|
|
|
16
|
+
// Characteristic Values
|
|
15
17
|
Active!: CharacteristicValue;
|
|
16
18
|
ActiveIdentifier!: CharacteristicValue;
|
|
19
|
+
|
|
20
|
+
// Others
|
|
17
21
|
deviceStatus!: deviceStatusResponse;
|
|
18
22
|
|
|
19
23
|
constructor(
|
|
20
24
|
private readonly platform: SwitchBotPlatform,
|
|
21
25
|
private accessory: PlatformAccessory,
|
|
22
|
-
public device: irdevice &
|
|
26
|
+
public device: irdevice & irDevicesConfig,
|
|
23
27
|
) {
|
|
24
28
|
// set accessory information
|
|
25
29
|
accessory
|
|
@@ -191,10 +195,12 @@ export class TV {
|
|
|
191
195
|
|
|
192
196
|
private ActiveSet(value: CharacteristicValue) {
|
|
193
197
|
this.platform.debug(`${this.accessory.displayName} Set Active: ${value}`);
|
|
194
|
-
if (
|
|
195
|
-
this.
|
|
196
|
-
|
|
197
|
-
|
|
198
|
+
if (!this.device.irtv?.disable_power) {
|
|
199
|
+
if (value === this.platform.Characteristic.Active.INACTIVE) {
|
|
200
|
+
this.pushTvOffChanges();
|
|
201
|
+
} else {
|
|
202
|
+
this.pushTvOnChanges();
|
|
203
|
+
}
|
|
198
204
|
}
|
|
199
205
|
this.ActiveIdentifier = value;
|
|
200
206
|
if (this.ActiveIdentifier !== undefined) {
|
|
@@ -337,7 +343,7 @@ export class TV {
|
|
|
337
343
|
}
|
|
338
344
|
|
|
339
345
|
|
|
340
|
-
private statusCode(push: AxiosResponse<
|
|
346
|
+
private statusCode(push: AxiosResponse<{ statusCode: number;}>) {
|
|
341
347
|
switch (push.data.statusCode) {
|
|
342
348
|
case 151:
|
|
343
349
|
this.platform.log.error('Command not supported by this device type.');
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { AxiosResponse } from 'axios';
|
|
2
2
|
import { CharacteristicValue, PlatformAccessory, Service } from 'homebridge';
|
|
3
3
|
import { SwitchBotPlatform } from '../platform';
|
|
4
|
-
import {
|
|
4
|
+
import { irDevicesConfig, DeviceURL, irdevice } from '../settings';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Platform Accessory
|
|
@@ -9,14 +9,16 @@ import { devicesConfig, DeviceURL, irdevice } from '../settings';
|
|
|
9
9
|
* Each accessory may expose multiple services of different service types.
|
|
10
10
|
*/
|
|
11
11
|
export class VacuumCleaner {
|
|
12
|
+
// Services
|
|
12
13
|
service!: Service;
|
|
13
14
|
|
|
15
|
+
// Characteristic Values
|
|
14
16
|
On!: CharacteristicValue;
|
|
15
17
|
|
|
16
18
|
constructor(
|
|
17
19
|
private readonly platform: SwitchBotPlatform,
|
|
18
20
|
private accessory: PlatformAccessory,
|
|
19
|
-
public device: irdevice &
|
|
21
|
+
public device: irdevice & irDevicesConfig,
|
|
20
22
|
) {
|
|
21
23
|
// set accessory information
|
|
22
24
|
accessory
|
|
@@ -109,7 +111,7 @@ export class VacuumCleaner {
|
|
|
109
111
|
}
|
|
110
112
|
|
|
111
113
|
|
|
112
|
-
private statusCode(push: AxiosResponse<
|
|
114
|
+
private statusCode(push: AxiosResponse<{ statusCode: number;}>) {
|
|
113
115
|
switch (push.data.statusCode) {
|
|
114
116
|
case 151:
|
|
115
117
|
this.platform.log.error('Command not supported by this device type.');
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { AxiosResponse } from 'axios';
|
|
2
2
|
import { CharacteristicValue, PlatformAccessory, Service } from 'homebridge';
|
|
3
3
|
import { SwitchBotPlatform } from '../platform';
|
|
4
|
-
import {
|
|
4
|
+
import { irDevicesConfig, DeviceURL, irdevice } from '../settings';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Platform Accessory
|
|
@@ -9,14 +9,16 @@ import { devicesConfig, DeviceURL, irdevice } from '../settings';
|
|
|
9
9
|
* Each accessory may expose multiple services of different service types.
|
|
10
10
|
*/
|
|
11
11
|
export class WaterHeater {
|
|
12
|
+
// Services
|
|
12
13
|
service!: Service;
|
|
13
14
|
|
|
15
|
+
// Characteristic Values
|
|
14
16
|
Active!: CharacteristicValue;
|
|
15
17
|
|
|
16
18
|
constructor(
|
|
17
19
|
private readonly platform: SwitchBotPlatform,
|
|
18
20
|
private accessory: PlatformAccessory,
|
|
19
|
-
public device: irdevice &
|
|
21
|
+
public device: irdevice & irDevicesConfig,
|
|
20
22
|
) {
|
|
21
23
|
// set accessory information
|
|
22
24
|
accessory
|
|
@@ -126,7 +128,7 @@ export class WaterHeater {
|
|
|
126
128
|
}
|
|
127
129
|
|
|
128
130
|
|
|
129
|
-
private statusCode(push: AxiosResponse<
|
|
131
|
+
private statusCode(push: AxiosResponse<{ statusCode: number;}>) {
|
|
130
132
|
switch (push.data.statusCode) {
|
|
131
133
|
case 151:
|
|
132
134
|
this.platform.log.error('Command not supported by this device type.');
|