@switchbot/homebridge-switchbot 1.3.1-beta.9 → 1.4.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 (103) hide show
  1. package/CHANGELOG.md +18 -2
  2. package/config.schema.json +82 -32
  3. package/dist/devices/bots.d.ts +15 -3
  4. package/dist/devices/bots.d.ts.map +1 -1
  5. package/dist/devices/bots.js +227 -165
  6. package/dist/devices/bots.js.map +1 -1
  7. package/dist/devices/colorbulb.d.ts +14 -3
  8. package/dist/devices/colorbulb.d.ts.map +1 -1
  9. package/dist/devices/colorbulb.js +163 -105
  10. package/dist/devices/colorbulb.js.map +1 -1
  11. package/dist/devices/contact.d.ts +13 -3
  12. package/dist/devices/contact.d.ts.map +1 -1
  13. package/dist/devices/contact.js +102 -63
  14. package/dist/devices/contact.js.map +1 -1
  15. package/dist/devices/curtains.d.ts +14 -5
  16. package/dist/devices/curtains.d.ts.map +1 -1
  17. package/dist/devices/curtains.js +180 -140
  18. package/dist/devices/curtains.js.map +1 -1
  19. package/dist/devices/humidifiers.d.ts +14 -3
  20. package/dist/devices/humidifiers.d.ts.map +1 -1
  21. package/dist/devices/humidifiers.js +173 -133
  22. package/dist/devices/humidifiers.js.map +1 -1
  23. package/dist/devices/meters.d.ts +17 -13
  24. package/dist/devices/meters.d.ts.map +1 -1
  25. package/dist/devices/meters.js +150 -105
  26. package/dist/devices/meters.js.map +1 -1
  27. package/dist/devices/motion.d.ts +13 -3
  28. package/dist/devices/motion.d.ts.map +1 -1
  29. package/dist/devices/motion.js +89 -45
  30. package/dist/devices/motion.js.map +1 -1
  31. package/dist/devices/plugs.d.ts +15 -3
  32. package/dist/devices/plugs.d.ts.map +1 -1
  33. package/dist/devices/plugs.js +115 -53
  34. package/dist/devices/plugs.js.map +1 -1
  35. package/dist/irdevices/airconditioners.d.ts +13 -3
  36. package/dist/irdevices/airconditioners.d.ts.map +1 -1
  37. package/dist/irdevices/airconditioners.js +97 -46
  38. package/dist/irdevices/airconditioners.js.map +1 -1
  39. package/dist/irdevices/airpurifiers.d.ts +13 -3
  40. package/dist/irdevices/airpurifiers.d.ts.map +1 -1
  41. package/dist/irdevices/airpurifiers.js +85 -31
  42. package/dist/irdevices/airpurifiers.js.map +1 -1
  43. package/dist/irdevices/cameras.d.ts +12 -3
  44. package/dist/irdevices/cameras.d.ts.map +1 -1
  45. package/dist/irdevices/cameras.js +73 -24
  46. package/dist/irdevices/cameras.js.map +1 -1
  47. package/dist/irdevices/fans.d.ts +12 -3
  48. package/dist/irdevices/fans.d.ts.map +1 -1
  49. package/dist/irdevices/fans.js +83 -35
  50. package/dist/irdevices/fans.js.map +1 -1
  51. package/dist/irdevices/lights.d.ts +12 -3
  52. package/dist/irdevices/lights.d.ts.map +1 -1
  53. package/dist/irdevices/lights.js +74 -25
  54. package/dist/irdevices/lights.js.map +1 -1
  55. package/dist/irdevices/others.d.ts +12 -3
  56. package/dist/irdevices/others.d.ts.map +1 -1
  57. package/dist/irdevices/others.js +80 -31
  58. package/dist/irdevices/others.js.map +1 -1
  59. package/dist/irdevices/tvs.d.ts +12 -3
  60. package/dist/irdevices/tvs.d.ts.map +1 -1
  61. package/dist/irdevices/tvs.js +90 -42
  62. package/dist/irdevices/tvs.js.map +1 -1
  63. package/dist/irdevices/vacuumcleaners.d.ts +12 -3
  64. package/dist/irdevices/vacuumcleaners.d.ts.map +1 -1
  65. package/dist/irdevices/vacuumcleaners.js +73 -24
  66. package/dist/irdevices/vacuumcleaners.js.map +1 -1
  67. package/dist/irdevices/waterheaters.d.ts +12 -3
  68. package/dist/irdevices/waterheaters.d.ts.map +1 -1
  69. package/dist/irdevices/waterheaters.js +73 -24
  70. package/dist/irdevices/waterheaters.js.map +1 -1
  71. package/dist/platform.d.ts +10 -10
  72. package/dist/platform.d.ts.map +1 -1
  73. package/dist/platform.js +290 -307
  74. package/dist/platform.js.map +1 -1
  75. package/dist/settings.d.ts +9 -6
  76. package/dist/settings.d.ts.map +1 -1
  77. package/dist/settings.js.map +1 -1
  78. package/nodemon.json +1 -1
  79. package/package.json +6 -6
  80. package/src/devices/bots.ts +221 -152
  81. package/src/devices/colorbulb.ts +172 -108
  82. package/src/devices/contact.ts +109 -64
  83. package/src/devices/curtains.ts +190 -146
  84. package/src/devices/humidifiers.ts +181 -135
  85. package/src/devices/meters.ts +156 -105
  86. package/src/devices/motion.ts +95 -45
  87. package/src/devices/plugs.ts +121 -53
  88. package/src/irdevices/airconditioners.ts +102 -46
  89. package/src/irdevices/airpurifiers.ts +91 -31
  90. package/src/irdevices/cameras.ts +79 -24
  91. package/src/irdevices/fans.ts +89 -36
  92. package/src/irdevices/lights.ts +80 -25
  93. package/src/irdevices/others.ts +86 -31
  94. package/src/irdevices/tvs.ts +96 -42
  95. package/src/irdevices/vacuumcleaners.ts +79 -24
  96. package/src/irdevices/waterheaters.ts +79 -24
  97. package/src/platform.ts +285 -302
  98. package/src/settings.ts +10 -6
  99. package/dist/devices/indoorcam.d.ts +0 -64
  100. package/dist/devices/indoorcam.d.ts.map +0 -1
  101. package/dist/devices/indoorcam.js +0 -249
  102. package/dist/devices/indoorcam.js.map +0 -1
  103. package/src/devices/indoorcam.ts +0 -309
@@ -9,11 +9,17 @@ class Plug {
9
9
  this.platform = platform;
10
10
  this.accessory = accessory;
11
11
  this.device = device;
12
- // Config
13
- this.deviceDebug = this.platform.config.options?.debug === 'device' || this.platform.debugMode;
14
- this.debugDebug = this.platform.config.options?.debug === 'debug' || this.platform.debugMode;
15
12
  // default placeholders
16
- this.On = false;
13
+ this.refreshRate();
14
+ this.logs();
15
+ if (this.On === undefined) {
16
+ this.On = false;
17
+ }
18
+ else {
19
+ this.On = this.accessory.context.On;
20
+ }
21
+ // Plug Config
22
+ this.debugLog(`Plug: ${this.accessory.displayName} Config: (offline: ${device.offline})`);
17
23
  // this is subject we use to track when we need to POST changes to the SwitchBot API
18
24
  this.doPlugUpdate = new rxjs_1.Subject();
19
25
  this.plugUpdateInProgress = false;
@@ -43,7 +49,7 @@ class Plug {
43
49
  // Update Homekit
44
50
  this.updateHomeKitCharacteristics();
45
51
  // Start an update interval
46
- (0, rxjs_1.interval)(this.platform.config.options.refreshRate * 1000)
52
+ (0, rxjs_1.interval)(this.deviceRefreshRate * 1000)
47
53
  .pipe((0, operators_1.skipWhile)(() => this.plugUpdateInProgress))
48
54
  .subscribe(() => {
49
55
  this.refreshStatus();
@@ -59,20 +65,39 @@ class Plug {
59
65
  await this.pushChanges();
60
66
  }
61
67
  catch (e) {
62
- this.platform.log.error(`Plug: ${this.accessory.displayName} failed pushChanges`);
63
- if (this.deviceDebug) {
64
- this.platform.log.error(`Plug: ${this.accessory.displayName} failed pushChanges,`
68
+ this.errorLog(`Plug: ${this.accessory.displayName} failed pushChanges`);
69
+ if (this.deviceLogging === 'debug') {
70
+ this.errorLog(`Plug: ${this.accessory.displayName} failed pushChanges,`
65
71
  + ` Error Message: ${JSON.stringify(e.message)}`);
66
72
  }
67
- if (this.debugDebug) {
68
- this.platform.log.error(`Plug: ${this.accessory.displayName} failed pushChanges,`
73
+ if (this.platform.debugMode) {
74
+ this.errorLog(`Plug: ${this.accessory.displayName} failed pushChanges,`
69
75
  + ` Error: ${JSON.stringify(e)}`);
70
76
  }
71
- this.apiError(e);
77
+ this.apiError();
72
78
  }
73
79
  this.plugUpdateInProgress = false;
74
80
  });
75
81
  }
82
+ refreshRate() {
83
+ if (this.device.refreshRate) {
84
+ this.deviceRefreshRate = this.accessory.context.refreshRate = this.device.refreshRate;
85
+ }
86
+ else if (this.platform.config.options.refreshRate) {
87
+ this.deviceRefreshRate = this.accessory.context.refreshRate = this.platform.config.options.refreshRate;
88
+ }
89
+ }
90
+ logs() {
91
+ if (this.device.logging) {
92
+ this.deviceLogging = this.accessory.context.logging = this.device.logging;
93
+ }
94
+ else if (this.platform.config.options?.logging) {
95
+ this.deviceLogging = this.accessory.context.logging = this.platform.config.options?.logging;
96
+ }
97
+ else {
98
+ this.deviceLogging = this.accessory.context.logging = 'standard';
99
+ }
100
+ }
76
101
  parseStatus() {
77
102
  switch (this.deviceStatus.body.power) {
78
103
  case 'on':
@@ -81,26 +106,26 @@ class Plug {
81
106
  default:
82
107
  this.On = false;
83
108
  }
84
- this.platform.debug(`Plug ${this.accessory.displayName} On: ${this.On}`);
109
+ this.debugLog(`Plug ${this.accessory.displayName} On: ${this.On}`);
85
110
  }
86
111
  async refreshStatus() {
87
112
  try {
88
113
  this.deviceStatus = (await this.platform.axios.get(`${settings_1.DeviceURL}/${this.device.deviceId}/status`)).data;
89
- this.platform.device(`Plug: ${this.accessory.displayName} refreshStatus: ${JSON.stringify(this.deviceStatus)}`);
114
+ this.debugLog(`Plug: ${this.accessory.displayName} refreshStatus: ${JSON.stringify(this.deviceStatus)}`);
90
115
  this.parseStatus();
91
116
  this.updateHomeKitCharacteristics();
92
117
  }
93
118
  catch (e) {
94
- this.platform.log.error(`Plug: ${this.accessory.displayName} failed refreshStatus with OpenAPI Connection`);
95
- if (this.deviceDebug) {
96
- this.platform.log.error(`Plug: ${this.accessory.displayName} failed refreshStatus with OpenAPI Connection,`
119
+ this.errorLog(`Plug: ${this.accessory.displayName} failed refreshStatus with OpenAPI Connection`);
120
+ if (this.deviceLogging === 'debug') {
121
+ this.errorLog(`Plug: ${this.accessory.displayName} failed refreshStatus with OpenAPI Connection,`
97
122
  + ` Error Message: ${JSON.stringify(e.message)}`);
98
123
  }
99
- if (this.debugDebug) {
100
- this.platform.log.error(`Plug: ${this.accessory.displayName} failed refreshStatus with OpenAPI Connection,`
124
+ if (this.platform.debugMode) {
125
+ this.errorLog(`Plug: ${this.accessory.displayName} failed refreshStatus with OpenAPI Connection,`
101
126
  + ` Error: ${JSON.stringify(e)}`);
102
127
  }
103
- this.apiError(e);
128
+ this.apiError();
104
129
  }
105
130
  }
106
131
  /**
@@ -110,22 +135,26 @@ class Plug {
110
135
  * Plug - "command" "turnOn" "default" = set to ON state
111
136
  */
112
137
  async pushChanges() {
113
- const payload = {
114
- commandType: 'command',
115
- parameter: 'default',
116
- };
117
- if (this.On) {
118
- payload.command = 'turnOn';
138
+ if (this.On !== this.OnCached) {
139
+ const payload = {
140
+ commandType: 'command',
141
+ parameter: 'default',
142
+ };
143
+ if (this.On) {
144
+ payload.command = 'turnOn';
145
+ }
146
+ else {
147
+ payload.command = 'turnOff';
148
+ }
149
+ this.infoLog(`Plug: ${this.accessory.displayName} Sending request to SwitchBot API. command: ${payload.command},`
150
+ + ` parameter: ${payload.parameter}, commandType: ${payload.commandType}`);
151
+ // Make the API request
152
+ const push = (await this.platform.axios.post(`${settings_1.DeviceURL}/${this.device.deviceId}/commands`, payload));
153
+ this.debugLog(`Plug: ${this.accessory.displayName} pushchanges: ${JSON.stringify(push.data)}`);
154
+ this.statusCode(push);
155
+ this.OnCached = this.On;
156
+ this.accessory.context.On = this.OnCached;
119
157
  }
120
- else {
121
- payload.command = 'turnOff';
122
- }
123
- this.platform.log.info(`Plug: ${this.accessory.displayName} Sending request to SwitchBot API. command: ${payload.command},`
124
- + ` parameter: ${payload.parameter}, commandType: ${payload.commandType}`);
125
- // Make the API request
126
- const push = (await this.platform.axios.post(`${settings_1.DeviceURL}/${this.device.deviceId}/commands`, payload));
127
- this.platform.debug(`Plug: ${this.accessory.displayName} pushchanges: ${JSON.stringify(push.data)}`);
128
- this.statusCode(push);
129
158
  (0, rxjs_1.interval)(5000)
130
159
  .pipe((0, operators_1.skipWhile)(() => this.plugUpdateInProgress))
131
160
  .pipe((0, operators_1.take)(1))
@@ -135,58 +164,91 @@ class Plug {
135
164
  }
136
165
  updateHomeKitCharacteristics() {
137
166
  if (this.On === undefined) {
138
- this.platform.debug(`Plug: ${this.accessory.displayName} On: ${this.On}`);
167
+ this.debugLog(`Plug: ${this.accessory.displayName} On: ${this.On}`);
139
168
  }
140
169
  else {
141
170
  this.service.updateCharacteristic(this.platform.Characteristic.On, this.On);
142
- this.platform.device(`Plug: ${this.accessory.displayName} updateCharacteristic On: ${this.On}`);
171
+ this.debugLog(`Plug: ${this.accessory.displayName} updateCharacteristic On: ${this.On}`);
143
172
  }
144
173
  }
145
- apiError(e) {
146
- this.service.updateCharacteristic(this.platform.Characteristic.On, e);
174
+ apiError() {
175
+ throw new this.platform.api.hap.HapStatusError(-70402 /* SERVICE_COMMUNICATION_FAILURE */);
147
176
  }
148
177
  statusCode(push) {
149
178
  switch (push.data.statusCode) {
150
179
  case 151:
151
- this.platform.log.error(`Plug: ${this.accessory.displayName} Command not supported by this device type.`);
180
+ this.errorLog(`Plug: ${this.accessory.displayName} Command not supported by this device type.`);
152
181
  break;
153
182
  case 152:
154
- this.platform.log.error(`Plug: ${this.accessory.displayName} Device not found.`);
183
+ this.errorLog(`Plug: ${this.accessory.displayName} Device not found.`);
155
184
  break;
156
185
  case 160:
157
- this.platform.log.error(`Plug: ${this.accessory.displayName} Command is not supported.`);
186
+ this.errorLog(`Plug: ${this.accessory.displayName} Command is not supported.`);
158
187
  break;
159
188
  case 161:
160
- this.platform.log.error(`Plug: ${this.accessory.displayName} Device is offline.`);
161
- if (this.device.offline) {
162
- this.On = false;
163
- }
189
+ this.errorLog(`Plug: ${this.accessory.displayName} Device is offline.`);
190
+ this.offlineOff();
164
191
  break;
165
192
  case 171:
166
- this.platform.log.error(`Plug: ${this.accessory.displayName} Hub Device is offline. Hub: ${this.device.hubDeviceId}`);
167
- if (this.device.offline) {
168
- this.On = false;
169
- }
193
+ this.errorLog(`Plug: ${this.accessory.displayName} Hub Device is offline. Hub: ${this.device.hubDeviceId}`);
194
+ this.offlineOff();
170
195
  break;
171
196
  case 190:
172
- this.platform.log.error(`Plug: ${this.accessory.displayName} Device internal error due to device states not synchronized with server,`
197
+ this.errorLog(`Plug: ${this.accessory.displayName} Device internal error due to device states not synchronized with server,`
173
198
  + ` Or command: ${JSON.stringify(push.data)} format is invalid`);
174
199
  break;
175
200
  case 100:
176
- this.platform.debug(`Plug: ${this.accessory.displayName} Command successfully sent.`);
201
+ this.debugLog(`Plug: ${this.accessory.displayName} Command successfully sent.`);
177
202
  break;
178
203
  default:
179
- this.platform.debug(`Plug: ${this.accessory.displayName} Unknown statusCode.`);
204
+ this.debugLog(`Plug: ${this.accessory.displayName} Unknown statusCode.`);
205
+ }
206
+ }
207
+ offlineOff() {
208
+ if (this.device.offline) {
209
+ this.On = false;
210
+ this.service.getCharacteristic(this.platform.Characteristic.On).updateValue(this.On);
180
211
  }
181
212
  }
182
213
  /**
183
214
  * Handle requests to set the value of the "On" characteristic
184
215
  */
185
216
  OnSet(value) {
186
- this.platform.debug(`Plug: ${this.accessory.displayName} - Set On: ${value}`);
217
+ this.debugLog(`Plug: ${this.accessory.displayName} - Set On: ${value}`);
187
218
  this.On = value;
188
219
  this.doPlugUpdate.next();
189
220
  }
221
+ /**
222
+ * Logging for Device
223
+ */
224
+ infoLog(...log) {
225
+ if (this.enablingDeviceLogging()) {
226
+ this.platform.log.info(String(...log));
227
+ }
228
+ }
229
+ warnLog(...log) {
230
+ if (this.enablingDeviceLogging()) {
231
+ this.platform.log.warn(String(...log));
232
+ }
233
+ }
234
+ errorLog(...log) {
235
+ if (this.enablingDeviceLogging()) {
236
+ this.platform.log.error(String(...log));
237
+ }
238
+ }
239
+ debugLog(...log) {
240
+ if (this.enablingDeviceLogging()) {
241
+ if (this.deviceLogging === 'debug') {
242
+ this.platform.log.info('[DEBUG]', String(...log));
243
+ }
244
+ else {
245
+ this.platform.log.debug(String(...log));
246
+ }
247
+ }
248
+ }
249
+ enablingDeviceLogging() {
250
+ return this.deviceLogging === 'debug' || this.deviceLogging === 'standard';
251
+ }
190
252
  }
191
253
  exports.Plug = Plug;
192
254
  //# sourceMappingURL=plugs.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"plugs.js","sourceRoot":"","sources":["../../src/devices/plugs.ts"],"names":[],"mappings":";;;AAEA,+BAAyC;AAEzC,8CAAoE;AAEpE,0CAA8F;AAE9F,MAAa,IAAI;IAkBf,YACmB,QAA2B,EACpC,SAA4B,EAC7B,MAA8B;QAFpB,aAAQ,GAA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AAC;IAED,OAAO,CAAC,GAAG,GAAU;QACnB,IAAI,IAAI,CAAC,qBAAqB,EAAE,EAAE;YAChC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC;SACxC;IACH,CAAC;IAED,QAAQ,CAAC,GAAG,GAAU;QACpB,IAAI,IAAI,CAAC,qBAAqB,EAAE,EAAE;YAChC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC;SACzC;IACH,CAAC;IAED,QAAQ,CAAC,GAAG,GAAU;QACpB,IAAI,IAAI,CAAC,qBAAqB,EAAE,EAAE;YAChC,IAAI,IAAI,CAAC,aAAa,KAAK,OAAO,EAAE;gBAClC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,EAAE,MAAM,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC;aACnD;iBAAM;gBACL,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC;aACzC;SACF;IACH,CAAC;IAED,qBAAqB;QACnB,OAAO,IAAI,CAAC,aAAa,KAAK,OAAO,IAAI,IAAI,CAAC,aAAa,KAAK,UAAU,CAAC;IAC7E,CAAC;CACF;AAjSD,oBAiSC"}
@@ -12,9 +12,11 @@ export declare class AirConditioner {
12
12
  device: irdevice & irDevicesConfig;
13
13
  service: Service;
14
14
  Active: CharacteristicValue;
15
+ ActiveCached: CharacteristicValue;
15
16
  RotationSpeed: CharacteristicValue;
16
17
  LastTemperature: CharacteristicValue;
17
18
  CurrentTemperature: CharacteristicValue;
19
+ CurrentTemperatureCached: CharacteristicValue;
18
20
  TargetHeaterCoolerState?: CharacteristicValue;
19
21
  CurrentHeaterCoolerState: CharacteristicValue;
20
22
  HeatingThresholdTemperature?: CharacteristicValue;
@@ -27,9 +29,9 @@ export declare class AirConditioner {
27
29
  static MODE_AUTO: number;
28
30
  static MODE_COOL: number;
29
31
  static MODE_HEAT: number;
30
- private readonly deviceDebug;
31
- private readonly debugDebug;
32
+ deviceLogging: string;
32
33
  constructor(platform: SwitchBotPlatform, accessory: PlatformAccessory, device: irdevice & irDevicesConfig);
34
+ logs(): void;
33
35
  private RotationSpeedSet;
34
36
  private RotationSpeedGet;
35
37
  private ActiveSet;
@@ -54,6 +56,14 @@ export declare class AirConditioner {
54
56
  pushAirConditionerDetailsChanges(): Promise<void>;
55
57
  pushChanges(payload: payload): Promise<void>;
56
58
  private statusCode;
57
- apiError(e: any): void;
59
+ apiError(): void;
60
+ /**
61
+ * Logging for Device
62
+ */
63
+ infoLog(...log: any[]): void;
64
+ warnLog(...log: any[]): void;
65
+ errorLog(...log: any[]): void;
66
+ debugLog(...log: any[]): void;
67
+ enablingDeviceLogging(): boolean;
58
68
  }
59
69
  //# sourceMappingURL=airconditioners.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"airconditioners.d.ts","sourceRoot":"","sources":["../../src/irdevices/airconditioners.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EAAE,eAAe,EAAa,QAAQ,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAC5E,OAAO,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAE7E;;;;GAIG;AACH,qBAAa,cAAc;IA6BvB,OAAO,CAAC,QAAQ,CAAC,QAAQ;IACzB,OAAO,CAAC,SAAS;IACV,MAAM,EAAE,QAAQ,GAAG,eAAe;IA7B3C,OAAO,EAAG,OAAO,CAAC;IAGlB,MAAM,EAAG,mBAAmB,CAAC;IAC7B,aAAa,EAAG,mBAAmB,CAAC;IACpC,eAAe,EAAG,mBAAmB,CAAC;IACtC,kBAAkB,EAAG,mBAAmB,CAAC;IACzC,uBAAuB,CAAC,EAAE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O,CAAC,8BAA8B;IAMtC,OAAO,CAAC,8BAA8B;IAQtC;;;;;;;;OAQG;IACG,2BAA2B;IAW3B,4BAA4B;IAW5B,+BAA+B;IAW/B,gCAAgC;IAqCzB,WAAW,CAAC,OAAO,EAAE,OAAO;IA0BzC,OAAO,CAAC,UAAU;IA6BX,QAAQ;IAIf;;KAEC;IACD,OAAO,CAAC,GAAG,GAAG,EAAE,GAAG,EAAE;IAMrB,OAAO,CAAC,GAAG,GAAG,EAAE,GAAG,EAAE;IAMrB,QAAQ,CAAC,GAAG,GAAG,EAAE,GAAG,EAAE;IAMtB,QAAQ,CAAC,GAAG,GAAG,EAAE,GAAG,EAAE;IAUtB,qBAAqB,IAAI,OAAO;CAGjC"}
@@ -13,10 +13,20 @@ class AirConditioner {
13
13
  this.accessory = accessory;
14
14
  this.device = device;
15
15
  this.Timeout = null;
16
- // Config
17
- this.deviceDebug = this.platform.config.options?.debug === 'device' || this.platform.debugMode;
18
- this.debugDebug = this.platform.config.options?.debug === 'debug' || this.platform.debugMode;
19
- this.CurrentTemperature = 24;
16
+ // default placeholders
17
+ this.logs();
18
+ if (this.Active === undefined) {
19
+ this.Active = this.platform.Characteristic.Active.INACTIVE;
20
+ }
21
+ else {
22
+ this.Active = this.accessory.context.Active;
23
+ }
24
+ if (this.CurrentTemperature === undefined) {
25
+ this.CurrentTemperature = 24;
26
+ }
27
+ else {
28
+ this.CurrentTemperature = this.accessory.context.CurrentTemperature;
29
+ }
20
30
  // set accessory information
21
31
  accessory
22
32
  .getService(this.platform.Service.AccessoryInformation)
@@ -95,6 +105,17 @@ class AirConditioner {
95
105
  })
96
106
  .onSet(this.RotationSpeedSet.bind(this));
97
107
  }
108
+ logs() {
109
+ if (this.device.logging) {
110
+ this.deviceLogging = this.accessory.context.logging = this.device.logging;
111
+ }
112
+ else if (this.platform.config.options?.logging) {
113
+ this.deviceLogging = this.accessory.context.logging = this.platform.config.options?.logging;
114
+ }
115
+ else {
116
+ this.deviceLogging = this.accessory.context.logging = 'standard';
117
+ }
118
+ }
98
119
  RotationSpeedSet(value) {
99
120
  if (value === 4) {
100
121
  this.CurrentFanSpeed = 1;
@@ -115,67 +136,69 @@ class AirConditioner {
115
136
  return this.RotationSpeed;
116
137
  }
117
138
  ActiveSet(value) {
118
- this.platform.debug(`Air Conditioner: ${this.accessory.displayName} Set Active: ${value}`);
139
+ this.debugLog(`Air Conditioner: ${this.accessory.displayName} Set Active: ${value}`);
119
140
  if (value === this.platform.Characteristic.Active.INACTIVE) {
120
141
  this.pushAirConditionerOffChanges();
121
- this.platform.device(`Air Conditioner: ${this.accessory.displayName} pushAirConditionerOffChanges, Active: ${this.Active}`);
142
+ this.debugLog(`Air Conditioner: ${this.accessory.displayName} pushAirConditionerOffChanges, Active: ${this.Active}`);
122
143
  }
123
144
  else {
124
145
  this.pushAirConditionerOnChanges();
125
- this.platform.device(`Air Conditioner: ${this.accessory.displayName} pushAirConditionerOffChanges, Active: ${this.Active}`);
146
+ this.debugLog(`Air Conditioner: ${this.accessory.displayName} pushAirConditionerOffChanges, Active: ${this.Active}`);
126
147
  }
127
148
  this.Active = value;
149
+ this.ActiveCached = this.Active;
150
+ this.accessory.context.Active = this.ActiveCached;
128
151
  }
129
152
  updateHomeKitCharacteristics() {
130
153
  if (this.Active === undefined) {
131
- this.platform.debug(`Air Conditioner: ${this.accessory.displayName} Active: ${this.Active}`);
154
+ this.debugLog(`Air Conditioner: ${this.accessory.displayName} Active: ${this.Active}`);
132
155
  }
133
156
  else {
134
157
  this.service?.updateCharacteristic(this.platform.Characteristic.Active, this.Active);
135
- this.platform.device(`Air Conditioner: ${this.accessory.displayName} updateCharacteristic Active: ${this.Active}`);
158
+ this.debugLog(`Air Conditioner: ${this.accessory.displayName} updateCharacteristic Active: ${this.Active}`);
136
159
  }
137
160
  if (this.RotationSpeed === undefined) {
138
- this.platform.debug(`Air Conditioner: ${this.accessory.displayName} RotationSpeed: ${this.RotationSpeed}`);
161
+ this.debugLog(`Air Conditioner: ${this.accessory.displayName} RotationSpeed: ${this.RotationSpeed}`);
139
162
  }
140
163
  else {
141
164
  this.service?.updateCharacteristic(this.platform.Characteristic.RotationSpeed, this.RotationSpeed);
142
- this.platform.device(`Air Conditioner: ${this.accessory.displayName} updateCharacteristic RotationSpeed: ${this.RotationSpeed}`);
165
+ this.debugLog(`Air Conditioner: ${this.accessory.displayName} updateCharacteristic RotationSpeed: ${this.RotationSpeed}`);
143
166
  }
144
167
  if (this.CurrentTemperature === undefined) {
145
- this.platform.debug(`Air Conditioner: ${this.accessory.displayName} CurrentTemperature: ${this.CurrentTemperature}`);
168
+ this.debugLog(`Air Conditioner: ${this.accessory.displayName} CurrentTemperature: ${this.CurrentTemperature}`);
146
169
  }
147
170
  else {
148
171
  this.service?.updateCharacteristic(this.platform.Characteristic.CurrentTemperature, this.CurrentTemperature);
149
- this.platform.device(`Air Conditioner: ${this.accessory.displayName} updateCharacteristic CurrentTemperature: ${this.CurrentTemperature}`);
172
+ this.debugLog(`Air Conditioner: ${this.accessory.displayName} updateCharacteristic CurrentTemperature: ${this.CurrentTemperature}`);
150
173
  }
151
174
  if (this.TargetHeaterCoolerState === undefined) {
152
- this.platform.debug(`Air Conditioner: ${this.accessory.displayName} TargetHeaterCoolerState: ${this.TargetHeaterCoolerState}`);
175
+ this.debugLog(`Air Conditioner: ${this.accessory.displayName} TargetHeaterCoolerState: ${this.TargetHeaterCoolerState}`);
153
176
  }
154
177
  else {
155
178
  this.service?.updateCharacteristic(this.platform.Characteristic.TargetHeaterCoolerState, this.TargetHeaterCoolerState);
156
- this.platform.device(`Air Conditioner: ${this.accessory.displayName}`
179
+ this.debugLog(`Air Conditioner: ${this.accessory.displayName}`
157
180
  + ` updateCharacteristic TargetHeaterCoolerState: ${this.TargetHeaterCoolerState}`);
158
181
  }
159
182
  if (this.CurrentHeaterCoolerState === undefined) {
160
- this.platform.debug(`Air Conditioner: ${this.accessory.displayName} CurrentHeaterCoolerState: ${this.CurrentHeaterCoolerState}`);
183
+ this.debugLog(`Air Conditioner: ${this.accessory.displayName} CurrentHeaterCoolerState: ${this.CurrentHeaterCoolerState}`);
161
184
  }
162
185
  else {
163
186
  this.service?.updateCharacteristic(this.platform.Characteristic.CurrentHeaterCoolerState, this.CurrentHeaterCoolerState);
164
- this.platform.device(`Air Conditioner: ${this.accessory.displayName}`
187
+ this.debugLog(`Air Conditioner: ${this.accessory.displayName}`
165
188
  + ` updateCharacteristic CurrentHeaterCoolerState: ${this.CurrentHeaterCoolerState}`);
166
189
  }
167
190
  if (this.HeatingThresholdTemperature === undefined) {
168
- this.platform.debug(`Air Conditioner: ${this.accessory.displayName} HeatingThresholdTemperature: ${this.HeatingThresholdTemperature}`);
191
+ this.debugLog(`Air Conditioner: ${this.accessory.displayName} HeatingThresholdTemperature: ${this.HeatingThresholdTemperature}`);
169
192
  }
170
193
  else {
171
194
  this.service?.updateCharacteristic(this.platform.Characteristic.HeatingThresholdTemperature, this.HeatingThresholdTemperature);
172
- this.platform.device(`Air Conditioner: ${this.accessory.displayName}`
195
+ this.debugLog(`Air Conditioner: ${this.accessory.displayName}`
173
196
  + ` updateCharacteristic HeatingThresholdTemperature: ${this.HeatingThresholdTemperature}`);
174
197
  }
175
198
  }
176
199
  CurrentTemperatureGet(value) {
177
200
  value = Number(this.CurrentTemperature) || 24;
178
- this.platform.debug(`Air Conditioner: ${this.accessory.displayName} Trigger Get CurrentTemperature: ${value}`);
201
+ this.debugLog(`Air Conditioner: ${this.accessory.displayName} Trigger Get CurrentTemperature: ${value}`);
179
202
  this.service
180
203
  .getCharacteristic(this.platform.Characteristic.CurrentTemperature)
181
204
  .updateValue(value);
@@ -209,19 +232,19 @@ class AirConditioner {
209
232
  else {
210
233
  this.CurrentHeaterCoolerState = this.platform.Characteristic.CurrentHeaterCoolerState.INACTIVE;
211
234
  }
212
- this.platform.device(`Air Conditioner: ${this.accessory.displayName} CurrentHeaterCoolerState: ${this.CurrentHeaterCoolerState}`);
235
+ this.debugLog(`Air Conditioner: ${this.accessory.displayName} CurrentHeaterCoolerState: ${this.CurrentHeaterCoolerState}`);
213
236
  return this.CurrentHeaterCoolerState;
214
237
  }
215
238
  HeatingThresholdTemperatureGet() {
216
239
  this.CurrentTemperature = this.CurrentTemperature || 24;
217
- this.platform.device(`Air Conditioner: ${this.accessory.displayName} CurrentTemperature: ${this.CurrentTemperature}`);
240
+ this.debugLog(`Air Conditioner: ${this.accessory.displayName} CurrentTemperature: ${this.CurrentTemperature}`);
218
241
  return this.CurrentTemperature;
219
242
  }
220
243
  HeatingThresholdTemperatureSet(value) {
221
244
  this.pushAirConditionerStatusChanges();
222
245
  this.LastTemperature = Number(this.CurrentTemperature);
223
246
  this.CurrentTemperature = Number(value);
224
- this.platform.device(`Air Conditioner: ${this.accessory.displayName} CurrentTemperature: ${this.CurrentTemperature},`
247
+ this.debugLog(`Air Conditioner: ${this.accessory.displayName} CurrentTemperature: ${this.CurrentTemperature},`
225
248
  + ` LastTemperature: ${this.LastTemperature}`);
226
249
  }
227
250
  /**
@@ -299,62 +322,90 @@ class AirConditioner {
299
322
  }
300
323
  async pushChanges(payload) {
301
324
  try {
302
- this.platform.log.info(`Air Conditioner: ${this.accessory.displayName} Sending request to SwitchBot API. command: ${payload.command},`
325
+ this.infoLog(`Air Conditioner: ${this.accessory.displayName} Sending request to SwitchBot API. command: ${payload.command},`
303
326
  + ` parameter: [${payload.parameter}], commandType: ${payload.commandType}`);
304
327
  // Make the API request
305
328
  const push = await this.platform.axios.post(`${settings_1.DeviceURL}/${this.device.deviceId}/commands`, payload);
306
- this.platform.log.error(`Air Conditioner: ${this.accessory.displayName} pushChanges: ${JSON.stringify(push.data)}`);
329
+ this.errorLog(`Air Conditioner: ${this.accessory.displayName} pushChanges: ${JSON.stringify(push.data)}`);
307
330
  this.statusCode(push);
331
+ this.CurrentTemperatureCached = this.CurrentTemperature;
332
+ this.accessory.context.CurrentTemperature = this.CurrentTemperatureCached;
308
333
  this.updateHomeKitCharacteristics();
309
334
  }
310
335
  catch (e) {
311
- this.platform.log.error(`Air Conditioner: ${this.accessory.displayName} failed pushChanges`);
312
- if (this.deviceDebug) {
313
- this.platform.log.error(`Air Conditioner: ${this.accessory.displayName} failed pushChanges,`
336
+ this.errorLog(`Air Conditioner: ${this.accessory.displayName} failed pushChanges`);
337
+ if (this.deviceLogging === 'debug') {
338
+ this.errorLog(`Air Conditioner: ${this.accessory.displayName} failed pushChanges,`
314
339
  + ` Error Message: ${JSON.stringify(e.message)}`);
315
340
  }
316
- if (this.debugDebug) {
317
- this.platform.log.error(`Air Conditioner: ${this.accessory.displayName} failed pushChanges,`
341
+ if (this.platform.debugMode) {
342
+ this.errorLog(`Air Conditioner: ${this.accessory.displayName} failed pushChanges,`
318
343
  + ` Error: ${JSON.stringify(e)}`);
319
344
  }
320
- this.apiError(e);
345
+ this.apiError();
321
346
  }
322
347
  }
323
348
  statusCode(push) {
324
349
  switch (push.data.statusCode) {
325
350
  case 151:
326
- this.platform.log.error(`Air Conditioner: ${this.accessory.displayName} Command not supported by this device type.`);
351
+ this.errorLog(`Air Conditioner: ${this.accessory.displayName} Command not supported by this device type.`);
327
352
  break;
328
353
  case 152:
329
- this.platform.log.error(`Air Conditioner: ${this.accessory.displayName} Device not found.`);
354
+ this.errorLog(`Air Conditioner: ${this.accessory.displayName} Device not found.`);
330
355
  break;
331
356
  case 160:
332
- this.platform.log.error(`Air Conditioner: ${this.accessory.displayName} Command is not supported.`);
357
+ this.errorLog(`Air Conditioner: ${this.accessory.displayName} Command is not supported.`);
333
358
  break;
334
359
  case 161:
335
- this.platform.log.error(`Air Conditioner: ${this.accessory.displayName} Device is offline.`);
360
+ this.errorLog(`Air Conditioner: ${this.accessory.displayName} Device is offline.`);
336
361
  break;
337
362
  case 171:
338
- this.platform.log.error(`Air Conditioner: ${this.accessory.displayName} Hub Device is offline. Hub: ${this.device.hubDeviceId}`);
363
+ this.errorLog(`Air Conditioner: ${this.accessory.displayName} Hub Device is offline. Hub: ${this.device.hubDeviceId}`);
339
364
  break;
340
365
  case 190:
341
- this.platform.log.error(`Air Conditioner: ${this.accessory.displayName} Device internal error due to device states not synchronized`
366
+ this.errorLog(`Air Conditioner: ${this.accessory.displayName} Device internal error due to device states not synchronized`
342
367
  + ` with server, Or command: ${JSON.stringify(push.data)} format is invalid`);
343
368
  break;
344
369
  case 100:
345
- this.platform.debug(`Air Conditioner: ${this.accessory.displayName} Command successfully sent.`);
370
+ this.debugLog(`Air Conditioner: ${this.accessory.displayName} Command successfully sent.`);
346
371
  break;
347
372
  default:
348
- this.platform.debug(`Air Conditioner: ${this.accessory.displayName} Unknown statusCode.`);
373
+ this.debugLog(`Air Conditioner: ${this.accessory.displayName} Unknown statusCode.`);
374
+ }
375
+ }
376
+ apiError() {
377
+ throw new this.platform.api.hap.HapStatusError(-70402 /* SERVICE_COMMUNICATION_FAILURE */);
378
+ }
379
+ /**
380
+ * Logging for Device
381
+ */
382
+ infoLog(...log) {
383
+ if (this.enablingDeviceLogging()) {
384
+ this.platform.log.info(String(...log));
385
+ }
386
+ }
387
+ warnLog(...log) {
388
+ if (this.enablingDeviceLogging()) {
389
+ this.platform.log.warn(String(...log));
390
+ }
391
+ }
392
+ errorLog(...log) {
393
+ if (this.enablingDeviceLogging()) {
394
+ this.platform.log.error(String(...log));
395
+ }
396
+ }
397
+ debugLog(...log) {
398
+ if (this.enablingDeviceLogging()) {
399
+ if (this.deviceLogging === 'debug') {
400
+ this.platform.log.info('[DEBUG]', String(...log));
401
+ }
402
+ else {
403
+ this.platform.log.debug(String(...log));
404
+ }
349
405
  }
350
406
  }
351
- apiError(e) {
352
- this.service.updateCharacteristic(this.platform.Characteristic.Active, e);
353
- this.service.updateCharacteristic(this.platform.Characteristic.RotationSpeed, e);
354
- this.service.updateCharacteristic(this.platform.Characteristic.CurrentTemperature, e);
355
- this.service.updateCharacteristic(this.platform.Characteristic.TargetHeaterCoolerState, e);
356
- this.service.updateCharacteristic(this.platform.Characteristic.CurrentHeaterCoolerState, e);
357
- this.service.updateCharacteristic(this.platform.Characteristic.HeatingThresholdTemperature, e);
407
+ enablingDeviceLogging() {
408
+ return this.deviceLogging === 'debug' || this.deviceLogging === 'standard';
358
409
  }
359
410
  }
360
411
  exports.AirConditioner = AirConditioner;