@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.
Files changed (99) hide show
  1. package/.github/workflows/nodejs-beta.yml +1 -1
  2. package/.github/workflows/nodejs.yml +1 -1
  3. package/.github/workflows/{prerelease.js → prerelease-beta.js} +0 -0
  4. package/CHANGELOG.md +1 -1
  5. package/README.md +9 -5
  6. package/config.schema.json +370 -142
  7. package/dist/devices/bots.d.ts +18 -34
  8. package/dist/devices/bots.d.ts.map +1 -1
  9. package/dist/devices/bots.js +166 -171
  10. package/dist/devices/bots.js.map +1 -1
  11. package/dist/devices/{bulb.d.ts → colorbulb.d.ts} +12 -19
  12. package/dist/devices/colorbulb.d.ts.map +1 -0
  13. package/dist/devices/{bulb.js → colorbulb.js} +34 -32
  14. package/dist/devices/colorbulb.js.map +1 -0
  15. package/dist/devices/contact.d.ts +18 -16
  16. package/dist/devices/contact.d.ts.map +1 -1
  17. package/dist/devices/contact.js +101 -44
  18. package/dist/devices/contact.js.map +1 -1
  19. package/dist/devices/curtains.d.ts +17 -51
  20. package/dist/devices/curtains.d.ts.map +1 -1
  21. package/dist/devices/curtains.js +170 -248
  22. package/dist/devices/curtains.js.map +1 -1
  23. package/dist/devices/humidifiers.d.ts +13 -4
  24. package/dist/devices/humidifiers.d.ts.map +1 -1
  25. package/dist/devices/humidifiers.js +81 -8
  26. package/dist/devices/humidifiers.js.map +1 -1
  27. package/dist/devices/indoorcam.d.ts +6 -13
  28. package/dist/devices/indoorcam.d.ts.map +1 -1
  29. package/dist/devices/indoorcam.js.map +1 -1
  30. package/dist/devices/meters.d.ts +12 -15
  31. package/dist/devices/meters.d.ts.map +1 -1
  32. package/dist/devices/meters.js +38 -44
  33. package/dist/devices/meters.js.map +1 -1
  34. package/dist/devices/motion.d.ts +17 -15
  35. package/dist/devices/motion.d.ts.map +1 -1
  36. package/dist/devices/motion.js +87 -40
  37. package/dist/devices/motion.js.map +1 -1
  38. package/dist/devices/plugs.d.ts +6 -13
  39. package/dist/devices/plugs.d.ts.map +1 -1
  40. package/dist/devices/plugs.js.map +1 -1
  41. package/dist/irdevices/airconditioners.d.ts +10 -10
  42. package/dist/irdevices/airconditioners.d.ts.map +1 -1
  43. package/dist/irdevices/airconditioners.js +29 -9
  44. package/dist/irdevices/airconditioners.js.map +1 -1
  45. package/dist/irdevices/airpurifiers.d.ts +11 -11
  46. package/dist/irdevices/airpurifiers.d.ts.map +1 -1
  47. package/dist/irdevices/airpurifiers.js.map +1 -1
  48. package/dist/irdevices/cameras.d.ts +3 -3
  49. package/dist/irdevices/cameras.d.ts.map +1 -1
  50. package/dist/irdevices/cameras.js.map +1 -1
  51. package/dist/irdevices/fans.d.ts +6 -6
  52. package/dist/irdevices/fans.d.ts.map +1 -1
  53. package/dist/irdevices/fans.js +10 -10
  54. package/dist/irdevices/fans.js.map +1 -1
  55. package/dist/irdevices/lights.d.ts +3 -3
  56. package/dist/irdevices/lights.d.ts.map +1 -1
  57. package/dist/irdevices/lights.js.map +1 -1
  58. package/dist/irdevices/others.d.ts +3 -3
  59. package/dist/irdevices/others.d.ts.map +1 -1
  60. package/dist/irdevices/others.js.map +1 -1
  61. package/dist/irdevices/tvs.d.ts +3 -3
  62. package/dist/irdevices/tvs.d.ts.map +1 -1
  63. package/dist/irdevices/tvs.js +7 -5
  64. package/dist/irdevices/tvs.js.map +1 -1
  65. package/dist/irdevices/vacuumcleaners.d.ts +3 -3
  66. package/dist/irdevices/vacuumcleaners.d.ts.map +1 -1
  67. package/dist/irdevices/vacuumcleaners.js.map +1 -1
  68. package/dist/irdevices/waterheaters.d.ts +3 -3
  69. package/dist/irdevices/waterheaters.d.ts.map +1 -1
  70. package/dist/irdevices/waterheaters.js.map +1 -1
  71. package/dist/platform.d.ts +3 -2
  72. package/dist/platform.d.ts.map +1 -1
  73. package/dist/platform.js +136 -46
  74. package/dist/platform.js.map +1 -1
  75. package/dist/settings.d.ts +51 -8
  76. package/dist/settings.d.ts.map +1 -1
  77. package/package.json +65 -65
  78. package/src/devices/bots.ts +188 -193
  79. package/src/devices/{bulb.ts → colorbulb.ts} +46 -51
  80. package/src/devices/contact.ts +124 -68
  81. package/src/devices/curtains.ts +192 -300
  82. package/src/devices/humidifiers.ts +97 -14
  83. package/src/devices/indoorcam.ts +10 -20
  84. package/src/devices/meters.ts +57 -69
  85. package/src/devices/motion.ts +108 -62
  86. package/src/devices/plugs.ts +8 -19
  87. package/src/irdevices/airconditioners.ts +43 -20
  88. package/src/irdevices/airpurifiers.ts +15 -11
  89. package/src/irdevices/cameras.ts +5 -3
  90. package/src/irdevices/fans.ts +22 -16
  91. package/src/irdevices/lights.ts +5 -3
  92. package/src/irdevices/others.ts +5 -3
  93. package/src/irdevices/tvs.ts +13 -7
  94. package/src/irdevices/vacuumcleaners.ts +5 -3
  95. package/src/irdevices/waterheaters.ts +5 -3
  96. package/src/platform.ts +148 -49
  97. package/src/settings.ts +80 -8
  98. package/dist/devices/bulb.d.ts.map +0 -1
  99. package/dist/devices/bulb.js.map +0 -1
@@ -1,8 +1,8 @@
1
- import { Service, PlatformAccessory, CharacteristicValue, MacAddress } from 'homebridge';
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!: any;
17
- switchbot!: {
18
- discover: (
19
- arg0:
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 { devicesConfig, DeviceURL, irdevice } from '../settings';
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
- ARActive!: CharacteristicValue;
22
- LastTemperature!: number;
23
- CurrentMode!: number;
24
- CurrentFanSpeed!: number;
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 & devicesConfig,
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
- return this.CurrentTemperatureGet(Number(value));
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
- if (Number.isNaN(this.CurrentTemperature)) {
163
- this.CurrentTemperature = 24;
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
- return (this.CurrentTemperature === Number(value));
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
- this.CurrentTemperature = this.CurrentTemperature || 24;
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 = Number(this.CurrentTemperature);
210
- this.CurrentTemperature = Number(value);
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<any>) {
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 { devicesConfig, DeviceURL, irdevice } from '../settings';
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
- RotationSpeed!: CharacteristicValue;
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
- APActive!: CharacteristicValue;
22
- LastTemperature!: number;
23
- CurrentMode!: number;
24
- CurrentFanSpeed!: number;
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 & devicesConfig,
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<any>) {
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.');
@@ -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 { devicesConfig, DeviceURL, irdevice } from '../settings';
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 & devicesConfig,
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<any>) {
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.');
@@ -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, devicesConfig } from '../settings';
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
- minStep: number | undefined;
21
- minValue: number | undefined;
22
- maxValue: number | undefined;
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 & devicesConfig,
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.fan?.rotation_speed) {
54
- if (device.fan?.set_minStep) {
55
- this.minStep = device.fan?.set_minStep;
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.fan?.set_min) {
60
- this.minValue = device.fan?.set_min;
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.fan?.set_max) {
65
- this.maxValue = device.fan?.set_max;
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.fan?.swing_mode) {
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.fan?.swing_mode) {
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.fan?.swing_mode) {
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<any>) {
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.');
@@ -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 { devicesConfig, DeviceURL, irdevice } from '../settings';
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 & devicesConfig,
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<any>) {
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.');
@@ -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 { devicesConfig, DeviceURL, irdevice } from '../settings';
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 & devicesConfig,
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<any>) {
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.');
@@ -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, devicesConfig } from '../settings';
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 & devicesConfig,
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 (value === this.platform.Characteristic.Active.INACTIVE) {
195
- this.pushTvOffChanges();
196
- } else {
197
- this.pushTvOnChanges();
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<any>) {
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 { devicesConfig, DeviceURL, irdevice } from '../settings';
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 & devicesConfig,
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<any>) {
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 { devicesConfig, DeviceURL, irdevice } from '../settings';
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 & devicesConfig,
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<any>) {
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.');