@switchbot/homebridge-switchbot 1.3.1-beta.9 → 1.4.0

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 (80) hide show
  1. package/CHANGELOG.md +4 -2
  2. package/config.schema.json +0 -22
  3. package/dist/devices/bots.d.ts +2 -0
  4. package/dist/devices/bots.d.ts.map +1 -1
  5. package/dist/devices/bots.js +109 -89
  6. package/dist/devices/bots.js.map +1 -1
  7. package/dist/devices/colorbulb.d.ts +1 -0
  8. package/dist/devices/colorbulb.d.ts.map +1 -1
  9. package/dist/devices/colorbulb.js +17 -9
  10. package/dist/devices/colorbulb.js.map +1 -1
  11. package/dist/devices/contact.js +1 -1
  12. package/dist/devices/contact.js.map +1 -1
  13. package/dist/devices/humidifiers.d.ts +1 -0
  14. package/dist/devices/humidifiers.d.ts.map +1 -1
  15. package/dist/devices/humidifiers.js +9 -7
  16. package/dist/devices/humidifiers.js.map +1 -1
  17. package/dist/devices/meters.d.ts +5 -11
  18. package/dist/devices/meters.d.ts.map +1 -1
  19. package/dist/devices/meters.js +49 -47
  20. package/dist/devices/meters.js.map +1 -1
  21. package/dist/devices/plugs.d.ts +2 -0
  22. package/dist/devices/plugs.d.ts.map +1 -1
  23. package/dist/devices/plugs.js +35 -22
  24. package/dist/devices/plugs.js.map +1 -1
  25. package/dist/irdevices/airconditioners.d.ts +2 -0
  26. package/dist/irdevices/airconditioners.d.ts.map +1 -1
  27. package/dist/irdevices/airconditioners.js +17 -1
  28. package/dist/irdevices/airconditioners.js.map +1 -1
  29. package/dist/irdevices/airpurifiers.d.ts +2 -0
  30. package/dist/irdevices/airpurifiers.d.ts.map +1 -1
  31. package/dist/irdevices/airpurifiers.js +17 -0
  32. package/dist/irdevices/airpurifiers.js.map +1 -1
  33. package/dist/irdevices/cameras.d.ts +1 -0
  34. package/dist/irdevices/cameras.d.ts.map +1 -1
  35. package/dist/irdevices/cameras.js +9 -0
  36. package/dist/irdevices/cameras.js.map +1 -1
  37. package/dist/irdevices/fans.d.ts +1 -0
  38. package/dist/irdevices/fans.d.ts.map +1 -1
  39. package/dist/irdevices/fans.js +9 -0
  40. package/dist/irdevices/fans.js.map +1 -1
  41. package/dist/irdevices/lights.d.ts +1 -0
  42. package/dist/irdevices/lights.d.ts.map +1 -1
  43. package/dist/irdevices/lights.js +9 -0
  44. package/dist/irdevices/lights.js.map +1 -1
  45. package/dist/irdevices/others.d.ts +1 -0
  46. package/dist/irdevices/others.d.ts.map +1 -1
  47. package/dist/irdevices/others.js +9 -0
  48. package/dist/irdevices/others.js.map +1 -1
  49. package/dist/irdevices/tvs.d.ts +1 -0
  50. package/dist/irdevices/tvs.d.ts.map +1 -1
  51. package/dist/irdevices/tvs.js +9 -0
  52. package/dist/irdevices/tvs.js.map +1 -1
  53. package/dist/irdevices/vacuumcleaners.d.ts +1 -0
  54. package/dist/irdevices/vacuumcleaners.d.ts.map +1 -1
  55. package/dist/irdevices/vacuumcleaners.js +9 -0
  56. package/dist/irdevices/vacuumcleaners.js.map +1 -1
  57. package/dist/irdevices/waterheaters.d.ts +1 -0
  58. package/dist/irdevices/waterheaters.d.ts.map +1 -1
  59. package/dist/irdevices/waterheaters.js +9 -0
  60. package/dist/irdevices/waterheaters.js.map +1 -1
  61. package/dist/settings.d.ts +5 -5
  62. package/dist/settings.d.ts.map +1 -1
  63. package/dist/settings.js.map +1 -1
  64. package/package.json +66 -66
  65. package/src/devices/bots.ts +88 -68
  66. package/src/devices/colorbulb.ts +17 -9
  67. package/src/devices/contact.ts +1 -1
  68. package/src/devices/humidifiers.ts +10 -7
  69. package/src/devices/meters.ts +50 -48
  70. package/src/devices/plugs.ts +38 -23
  71. package/src/irdevices/airconditioners.ts +17 -1
  72. package/src/irdevices/airpurifiers.ts +18 -0
  73. package/src/irdevices/cameras.ts +10 -0
  74. package/src/irdevices/fans.ts +10 -0
  75. package/src/irdevices/lights.ts +10 -0
  76. package/src/irdevices/others.ts +10 -0
  77. package/src/irdevices/tvs.ts +10 -0
  78. package/src/irdevices/vacuumcleaners.ts +10 -0
  79. package/src/irdevices/waterheaters.ts +10 -0
  80. package/src/settings.ts +6 -5
@@ -15,11 +15,13 @@ export class AirPurifier {
15
15
  // Characteristic Values
16
16
  Active!: CharacteristicValue;
17
17
  APActive!: CharacteristicValue;
18
+ ActiveCached!: CharacteristicValue;
18
19
  CurrentAPTemp!: CharacteristicValue;
19
20
  CurrentAPMode!: CharacteristicValue;
20
21
  RotationSpeed!: CharacteristicValue;
21
22
  CurrentAPFanSpeed!: CharacteristicValue;
22
23
  CurrentTemperature!: CharacteristicValue;
24
+ CurrentTemperatureCached!: CharacteristicValue;
23
25
  CurrentAirPurifierState!: CharacteristicValue;
24
26
  CurrentHeaterCoolerState!: CharacteristicValue;
25
27
 
@@ -42,6 +44,18 @@ export class AirPurifier {
42
44
  private accessory: PlatformAccessory,
43
45
  public device: irdevice & irDevicesConfig,
44
46
  ) {
47
+ // default placeholders
48
+ if (this.Active === undefined) {
49
+ this.Active = this.platform.Characteristic.Active.INACTIVE;
50
+ } else {
51
+ this.Active = this.accessory.context.Active;
52
+ }
53
+ if (this.CurrentTemperature === undefined) {
54
+ this.CurrentTemperature = 24;
55
+ } else {
56
+ this.CurrentTemperature = this.accessory.context.CurrentTemperature;
57
+ }
58
+
45
59
  // set accessory information
46
60
  accessory
47
61
  .getService(this.platform.Service.AccessoryInformation)!
@@ -81,6 +95,8 @@ export class AirPurifier {
81
95
  this.pushAirConditionerOnChanges();
82
96
  }
83
97
  this.Active = value;
98
+ this.ActiveCached = this.Active;
99
+ this.accessory.context.Active = this.ActiveCached;
84
100
  }
85
101
 
86
102
  private updateHomeKitCharacteristics() {
@@ -210,6 +226,8 @@ export class AirPurifier {
210
226
  this.platform.debug(`Air Purifier: ${this.accessory.displayName} pushChanges: ${push.data}`);
211
227
  this.statusCode(push);
212
228
  this.updateHomeKitCharacteristics();
229
+ this.CurrentTemperatureCached = this.CurrentTemperature;
230
+ this.accessory.context.CurrentTemperature = this.CurrentTemperatureCached;
213
231
  } catch (e: any) {
214
232
  this.platform.log.error(`Air Purifier: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection`);
215
233
  if (this.deviceDebug) {
@@ -14,6 +14,7 @@ export class Camera {
14
14
 
15
15
  // Characteristic Values
16
16
  On!: CharacteristicValue;
17
+ OnCached!: CharacteristicValue;
17
18
 
18
19
  // Config
19
20
  private readonly deviceDebug = this.platform.config.options?.debug === 'device' || this.platform.debugMode;
@@ -24,6 +25,13 @@ export class Camera {
24
25
  private accessory: PlatformAccessory,
25
26
  public device: irdevice & irDevicesConfig,
26
27
  ) {
28
+ // default placeholders
29
+ if (this.On === undefined) {
30
+ this.On = false;
31
+ } else {
32
+ this.On = this.accessory.context.On;
33
+ }
34
+
27
35
  // set accessory information
28
36
  accessory
29
37
  .getService(this.platform.Service.AccessoryInformation)!
@@ -110,6 +118,8 @@ export class Camera {
110
118
  this.platform.debug(`Camera: ${this.accessory.displayName} pushChanges: ${push.data}`);
111
119
  this.statusCode(push);
112
120
  this.updateHomeKitCharacteristics();
121
+ this.OnCached = this.On;
122
+ this.accessory.context.On = this.OnCached;
113
123
  } catch (e: any) {
114
124
  this.platform.log.error(`Camera: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection`);
115
125
  if (this.deviceDebug) {
@@ -14,6 +14,7 @@ export class Fan {
14
14
 
15
15
  // Characteristic Values
16
16
  Active!: CharacteristicValue;
17
+ ActiveCached!: CharacteristicValue;
17
18
  ActiveIdentifier!: CharacteristicValue;
18
19
  RotationSpeed!: CharacteristicValue;
19
20
  SwingMode!: CharacteristicValue;
@@ -34,6 +35,13 @@ export class Fan {
34
35
  private accessory: PlatformAccessory,
35
36
  public device: irdevice & irDevicesConfig,
36
37
  ) {
38
+ // default placeholders
39
+ if (this.Active === undefined) {
40
+ this.Active = this.platform.Characteristic.Active.INACTIVE;
41
+ } else {
42
+ this.Active = this.accessory.context.Active;
43
+ }
44
+
37
45
  // set accessory information
38
46
  accessory
39
47
  .getService(this.platform.Service.AccessoryInformation)!
@@ -164,6 +172,8 @@ export class Fan {
164
172
  this.pushFanOnChanges();
165
173
  }
166
174
  this.Active = value;
175
+ this.ActiveCached = this.Active;
176
+ this.accessory.context.Active = this.ActiveCached;
167
177
  }
168
178
 
169
179
  /**
@@ -14,6 +14,7 @@ export class Light {
14
14
 
15
15
  // Characteristic Values
16
16
  On!: CharacteristicValue;
17
+ OnCached!: CharacteristicValue;
17
18
 
18
19
  // Config
19
20
  private readonly deviceDebug = this.platform.config.options?.debug === 'device' || this.platform.debugMode;
@@ -24,6 +25,13 @@ export class Light {
24
25
  private accessory: PlatformAccessory,
25
26
  public device: irdevice & irDevicesConfig,
26
27
  ) {
28
+ // default placeholders
29
+ if (this.On === undefined) {
30
+ this.On = false;
31
+ } else {
32
+ this.On = this.accessory.context.On;
33
+ }
34
+
27
35
  // set accessory information
28
36
  accessory
29
37
  .getService(this.platform.Service.AccessoryInformation)!
@@ -142,6 +150,8 @@ export class Light {
142
150
  const push = await this.platform.axios.post(`${DeviceURL}/${this.device.deviceId}/commands`, payload);
143
151
  this.platform.debug(`Light: ${this.accessory.displayName} pushChanges: ${push.data}`);
144
152
  this.statusCode(push);
153
+ this.OnCached = this.On;
154
+ this.accessory.context.On = this.OnCached;
145
155
  this.updateHomeKitCharacteristics();
146
156
  } catch (e: any) {
147
157
  this.platform.log.error(`Light: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection`);
@@ -14,6 +14,7 @@ export class Others {
14
14
 
15
15
  // Characteristic Values
16
16
  Active!: CharacteristicValue;
17
+ ActiveCached!: CharacteristicValue;
17
18
 
18
19
  // Config
19
20
  private readonly deviceDebug = this.platform.config.options?.debug === 'device' || this.platform.debugMode;
@@ -24,6 +25,13 @@ export class Others {
24
25
  private accessory: PlatformAccessory,
25
26
  public device: irdevice & irDevicesConfig,
26
27
  ) {
28
+ // default placeholders
29
+ if (this.Active === undefined) {
30
+ this.Active = this.platform.Characteristic.Active.INACTIVE;
31
+ } else {
32
+ this.Active = this.accessory.context.Active;
33
+ }
34
+
27
35
  // set accessory information
28
36
  accessory
29
37
  .getService(this.platform.Service.AccessoryInformation)!
@@ -54,6 +62,8 @@ export class Others {
54
62
  this.pushOffChanges();
55
63
  }
56
64
  this.Active = value;
65
+ this.ActiveCached = this.Active;
66
+ this.accessory.context.Active = this.ActiveCached;
57
67
  }
58
68
 
59
69
  private updateHomeKitCharacteristics() {
@@ -15,6 +15,7 @@ export class TV {
15
15
 
16
16
  // Characteristic Values
17
17
  Active!: CharacteristicValue;
18
+ ActiveCached!: CharacteristicValue;
18
19
  ActiveIdentifier!: CharacteristicValue;
19
20
 
20
21
  // Others
@@ -29,6 +30,13 @@ export class TV {
29
30
  private accessory: PlatformAccessory,
30
31
  public device: irdevice & irDevicesConfig,
31
32
  ) {
33
+ // default placeholders
34
+ if (this.Active === undefined) {
35
+ this.Active = this.platform.Characteristic.Active.INACTIVE;
36
+ } else {
37
+ this.Active = this.accessory.context.Active;
38
+ }
39
+
32
40
  // set accessory information
33
41
  accessory
34
42
  .getService(this.platform.Service.AccessoryInformation)!
@@ -207,6 +215,8 @@ export class TV {
207
215
  this.pushTvOnChanges();
208
216
  }
209
217
  this.Active = value;
218
+ this.ActiveCached = this.Active;
219
+ this.accessory.context.Active = this.ActiveCached;
210
220
  }
211
221
  }
212
222
 
@@ -14,6 +14,7 @@ export class VacuumCleaner {
14
14
 
15
15
  // Characteristic Values
16
16
  On!: CharacteristicValue;
17
+ OnCached!: CharacteristicValue;
17
18
 
18
19
  // Config
19
20
  private readonly deviceDebug = this.platform.config.options?.debug === 'device' || this.platform.debugMode;
@@ -24,6 +25,13 @@ export class VacuumCleaner {
24
25
  private accessory: PlatformAccessory,
25
26
  public device: irdevice & irDevicesConfig,
26
27
  ) {
28
+ // default placeholders
29
+ if (this.On === undefined) {
30
+ this.On = false;
31
+ } else {
32
+ this.On = this.accessory.context.On;
33
+ }
34
+
27
35
  // set accessory information
28
36
  accessory
29
37
  .getService(this.platform.Service.AccessoryInformation)!
@@ -109,6 +117,8 @@ export class VacuumCleaner {
109
117
  const push = await this.platform.axios.post(`${DeviceURL}/${this.device.deviceId}/commands`, payload);
110
118
  this.platform.debug(`Vacuum Cleaner: ${this.accessory.displayName} pushChanges: ${push.data}`);
111
119
  this.statusCode(push);
120
+ this.OnCached = this.On;
121
+ this.accessory.context.On = this.OnCached;
112
122
  this.updateHomeKitCharacteristics();
113
123
  } catch (e: any) {
114
124
  this.platform.log.error(`Vacuum Cleaner: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection`);
@@ -14,6 +14,7 @@ export class WaterHeater {
14
14
 
15
15
  // Characteristic Values
16
16
  Active!: CharacteristicValue;
17
+ ActiveCached!: CharacteristicValue;
17
18
 
18
19
  // Config
19
20
  private readonly deviceDebug = this.platform.config.options?.debug === 'device' || this.platform.debugMode;
@@ -24,6 +25,13 @@ export class WaterHeater {
24
25
  private accessory: PlatformAccessory,
25
26
  public device: irdevice & irDevicesConfig,
26
27
  ) {
28
+ // default placeholders
29
+ if (this.Active === undefined) {
30
+ this.Active = this.platform.Characteristic.Active.INACTIVE;
31
+ } else {
32
+ this.Active = this.accessory.context.Active;
33
+ }
34
+
27
35
  // set accessory information
28
36
  accessory
29
37
  .getService(this.platform.Service.AccessoryInformation)!
@@ -71,6 +79,8 @@ export class WaterHeater {
71
79
  this.service.setCharacteristic(this.platform.Characteristic.InUse, this.platform.Characteristic.InUse.IN_USE);
72
80
  }
73
81
  this.Active = value;
82
+ this.ActiveCached = this.Active;
83
+ this.accessory.context.Active = this.ActiveCached;
74
84
  }
75
85
 
76
86
  private updateHomeKitCharacteristics() {
package/src/settings.ts CHANGED
@@ -53,7 +53,6 @@ export interface devicesConfig extends device {
53
53
  }
54
54
 
55
55
  export type meter = {
56
- unit?: number;
57
56
  hide_temperature?: boolean;
58
57
  hide_humidity?: boolean;
59
58
  };
@@ -281,10 +280,7 @@ export type serviceData = {
281
280
  //Humidifier's AutoMode
282
281
  autoMode?: boolean;
283
282
  //Meter Temperature Levels
284
- temperature?: {
285
- c: number,
286
- f: number
287
- };
283
+ temperature?: temperature;
288
284
  // Fahrenheit enabled for Meter
289
285
  fahrenheit: boolean;
290
286
  // Humidity level for Meter
@@ -304,6 +300,11 @@ export type serviceData = {
304
300
  position?: number;
305
301
  };
306
302
 
303
+ export type temperature = {
304
+ c: number;
305
+ f: number;
306
+ };
307
+
307
308
  export type switchbot = {
308
309
  discover: (
309
310
  arg0: