@switchbot/homebridge-switchbot 2.8.1-beta.2 → 2.8.1-beta.21

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 (109) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/config.schema.json +3 -3
  3. package/dist/device/blindtilt.d.ts.map +1 -1
  4. package/dist/device/blindtilt.js +37 -23
  5. package/dist/device/blindtilt.js.map +1 -1
  6. package/dist/device/bot.d.ts.map +1 -1
  7. package/dist/device/bot.js +26 -10
  8. package/dist/device/bot.js.map +1 -1
  9. package/dist/device/ceilinglight.d.ts.map +1 -1
  10. package/dist/device/ceilinglight.js +78 -29
  11. package/dist/device/ceilinglight.js.map +1 -1
  12. package/dist/device/colorbulb.d.ts.map +1 -1
  13. package/dist/device/colorbulb.js +78 -29
  14. package/dist/device/colorbulb.js.map +1 -1
  15. package/dist/device/contact.d.ts.map +1 -1
  16. package/dist/device/contact.js +22 -19
  17. package/dist/device/contact.js.map +1 -1
  18. package/dist/device/curtain.d.ts.map +1 -1
  19. package/dist/device/curtain.js +36 -20
  20. package/dist/device/curtain.js.map +1 -1
  21. package/dist/device/hub.d.ts +3 -3
  22. package/dist/device/hub.d.ts.map +1 -1
  23. package/dist/device/hub.js +205 -172
  24. package/dist/device/hub.js.map +1 -1
  25. package/dist/device/humidifier.d.ts.map +1 -1
  26. package/dist/device/humidifier.js +66 -28
  27. package/dist/device/humidifier.js.map +1 -1
  28. package/dist/device/iosensor.d.ts.map +1 -1
  29. package/dist/device/iosensor.js +21 -11
  30. package/dist/device/iosensor.js.map +1 -1
  31. package/dist/device/lightstrip.d.ts.map +1 -1
  32. package/dist/device/lightstrip.js +63 -25
  33. package/dist/device/lightstrip.js.map +1 -1
  34. package/dist/device/lock.d.ts.map +1 -1
  35. package/dist/device/lock.js +35 -19
  36. package/dist/device/lock.js.map +1 -1
  37. package/dist/device/meter.d.ts +2 -2
  38. package/dist/device/meter.d.ts.map +1 -1
  39. package/dist/device/meter.js +41 -31
  40. package/dist/device/meter.js.map +1 -1
  41. package/dist/device/meterplus.d.ts.map +1 -1
  42. package/dist/device/meterplus.js +23 -13
  43. package/dist/device/meterplus.js.map +1 -1
  44. package/dist/device/motion.d.ts.map +1 -1
  45. package/dist/device/motion.js +21 -16
  46. package/dist/device/motion.js.map +1 -1
  47. package/dist/device/plug.d.ts.map +1 -1
  48. package/dist/device/plug.js +32 -16
  49. package/dist/device/plug.js.map +1 -1
  50. package/dist/device/robotvacuumcleaner.d.ts.map +1 -1
  51. package/dist/device/robotvacuumcleaner.js +48 -21
  52. package/dist/device/robotvacuumcleaner.js.map +1 -1
  53. package/dist/irdevice/airconditioner.d.ts.map +1 -1
  54. package/dist/irdevice/airconditioner.js +15 -9
  55. package/dist/irdevice/airconditioner.js.map +1 -1
  56. package/dist/irdevice/airpurifier.d.ts.map +1 -1
  57. package/dist/irdevice/airpurifier.js +15 -9
  58. package/dist/irdevice/airpurifier.js.map +1 -1
  59. package/dist/irdevice/camera.d.ts.map +1 -1
  60. package/dist/irdevice/camera.js +15 -9
  61. package/dist/irdevice/camera.js.map +1 -1
  62. package/dist/irdevice/fan.d.ts.map +1 -1
  63. package/dist/irdevice/fan.js +15 -9
  64. package/dist/irdevice/fan.js.map +1 -1
  65. package/dist/irdevice/light.d.ts.map +1 -1
  66. package/dist/irdevice/light.js +16 -10
  67. package/dist/irdevice/light.js.map +1 -1
  68. package/dist/irdevice/other.d.ts.map +1 -1
  69. package/dist/irdevice/other.js +15 -4
  70. package/dist/irdevice/other.js.map +1 -1
  71. package/dist/irdevice/tv.d.ts.map +1 -1
  72. package/dist/irdevice/tv.js +15 -9
  73. package/dist/irdevice/tv.js.map +1 -1
  74. package/dist/irdevice/vacuumcleaner.d.ts.map +1 -1
  75. package/dist/irdevice/vacuumcleaner.js +15 -9
  76. package/dist/irdevice/vacuumcleaner.js.map +1 -1
  77. package/dist/irdevice/waterheater.d.ts.map +1 -1
  78. package/dist/irdevice/waterheater.js +15 -9
  79. package/dist/irdevice/waterheater.js.map +1 -1
  80. package/dist/platform.d.ts.map +1 -1
  81. package/dist/platform.js +48 -20
  82. package/dist/platform.js.map +1 -1
  83. package/package.json +1 -1
  84. package/src/device/blindtilt.ts +35 -25
  85. package/src/device/bot.ts +25 -10
  86. package/src/device/ceilinglight.ts +73 -30
  87. package/src/device/colorbulb.ts +73 -30
  88. package/src/device/contact.ts +21 -20
  89. package/src/device/curtain.ts +34 -21
  90. package/src/device/hub.ts +211 -188
  91. package/src/device/humidifier.ts +62 -29
  92. package/src/device/iosensor.ts +20 -11
  93. package/src/device/lightstrip.ts +59 -26
  94. package/src/device/lock.ts +33 -20
  95. package/src/device/meter.ts +42 -34
  96. package/src/device/meterplus.ts +22 -13
  97. package/src/device/motion.ts +20 -17
  98. package/src/device/plug.ts +30 -17
  99. package/src/device/robotvacuumcleaner.ts +45 -22
  100. package/src/irdevice/airconditioner.ts +14 -10
  101. package/src/irdevice/airpurifier.ts +14 -10
  102. package/src/irdevice/camera.ts +14 -10
  103. package/src/irdevice/fan.ts +14 -10
  104. package/src/irdevice/light.ts +15 -11
  105. package/src/irdevice/other.ts +14 -4
  106. package/src/irdevice/tv.ts +14 -10
  107. package/src/irdevice/vacuumcleaner.ts +14 -10
  108. package/src/irdevice/waterheater.ts +14 -10
  109. package/src/platform.ts +50 -26
package/src/device/hub.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { CharacteristicValue, PlatformAccessory, Service } from 'homebridge';
1
+ import { CharacteristicValue, PlatformAccessory, Service, Units } from 'homebridge';
2
2
  import { interval } from 'rxjs';
3
3
  import { request } from 'undici';
4
4
  import { Context } from 'vm';
@@ -8,9 +8,9 @@ import { sleep } from '../utils';
8
8
 
9
9
  export class Hub {
10
10
  // Services
11
- hubLightSensor: Service;
12
- hubHumiditySensor: Service;
13
- hubTemperatureSensor: Service;
11
+ lightSensorService?: Service;
12
+ humidityService?: Service;
13
+ temperatureService?: Service;
14
14
 
15
15
  // Characteristic Values
16
16
  CurrentTemperature!: CharacteristicValue;
@@ -65,44 +65,33 @@ export class Hub {
65
65
  .getCharacteristic(this.platform.Characteristic.FirmwareRevision)
66
66
  .updateValue(this.FirmwareRevision(accessory, device));
67
67
 
68
- // get the WindowCovering service if it exists, otherwise create a new WindowCovering service
69
- // you can create multiple services for each accessory
70
- (this.hubTemperatureSensor =
71
- accessory.getService(this.platform.Service.TemperatureSensor) || accessory.addService(this.platform.Service.TemperatureSensor)),
72
- `${device.deviceName} ${device.deviceType}`;
73
-
74
- (this.hubHumiditySensor =
75
- accessory.getService(this.platform.Service.HumiditySensor) || accessory.addService(this.platform.Service.HumiditySensor)),
76
- `${device.deviceName} ${device.deviceType}`;
77
-
78
- (this.hubLightSensor = accessory.getService(this.platform.Service.LightSensor) || accessory.addService(this.platform.Service.LightSensor)),
79
- `${device.deviceName} ${device.deviceType}`;
80
-
81
- // To avoid "Cannot add a Service with the same UUID another Service without also defining a unique 'subtype' property." error,
82
- // when creating multiple services of the same type, you need to use the following syntax to specify a name and subtype id:
83
- // accessory.getService('NAME') ?? accessory.addService(this.platform.Service.WindowCovering, 'NAME', 'USER_DEFINED_SUBTYPE');
84
-
85
- // set the service name, this is what is displayed as the default name on the Home app
86
- // in this example we are using the name we stored in the `accessory.context` in the `discoverDevices` method
87
-
88
- // each service must implement at-minimum the "required characteristics" for the given service type
89
- // see https://developers.homebridge.io/#/service/WindowCovering
90
-
91
68
  // Temperature Sensor Service
92
69
  if (device.hub?.hide_temperature) {
93
70
  this.debugLog(`${this.device.deviceType}: ${accessory.displayName} Removing Temperature Sensor Service`);
94
- this.hubTemperatureSensor = this.hubTemperatureSensor.setCharacteristic(this.platform.Characteristic.CurrentTemperature, false);
95
- accessory.removeService(this.hubTemperatureSensor!);
96
- } else if (!this.hubTemperatureSensor) {
71
+ this.temperatureService = this.accessory.getService(this.platform.Service.TemperatureSensor);
72
+ accessory.removeService(this.temperatureService!);
73
+ } else if (!this.temperatureService) {
97
74
  this.debugLog(`${this.device.deviceType}: ${accessory.displayName} Add Temperature Sensor Service`);
98
- (this.hubTemperatureSensor =
99
- accessory.getService(this.platform.Service.TemperatureSensor) || accessory.addService(this.platform.Service.TemperatureSensor)),
100
- `${device.deviceName} ${device.deviceType}`;
75
+ (this.temperatureService =
76
+ this.accessory.getService(this.platform.Service.TemperatureSensor) || this.accessory.addService(this.platform.Service.TemperatureSensor)),
77
+ `${accessory.displayName} Temperature Sensor`;
101
78
 
102
- this.hubTemperatureSensor.setCharacteristic(this.platform.Characteristic.Name, accessory.displayName);
103
- if (!this.hubTemperatureSensor.testCharacteristic(this.platform.Characteristic.ConfiguredName)) {
104
- this.hubTemperatureSensor.addCharacteristic(this.platform.Characteristic.ConfiguredName, accessory.displayName);
79
+ this.temperatureService.setCharacteristic(this.platform.Characteristic.Name, `${accessory.displayName} Temperature Sensor`);
80
+ if (!this.temperatureService.testCharacteristic(this.platform.Characteristic.ConfiguredName)) {
81
+ this.temperatureService.addCharacteristic(this.platform.Characteristic.ConfiguredName, `${accessory.displayName} Temperature Sensor`);
105
82
  }
83
+ this.temperatureService
84
+ .getCharacteristic(this.platform.Characteristic.CurrentTemperature)
85
+ .setProps({
86
+ unit: Units['CELSIUS'],
87
+ validValueRanges: [-273.15, 100],
88
+ minValue: -273.15,
89
+ maxValue: 100,
90
+ minStep: 0.1,
91
+ })
92
+ .onGet(() => {
93
+ return this.CurrentTemperature!;
94
+ });
106
95
  } else {
107
96
  this.debugLog(`${this.device.deviceType}: ${accessory.displayName} Temperature Sensor Service Not Added`);
108
97
  }
@@ -110,18 +99,26 @@ export class Hub {
110
99
  // Humidity Sensor Service
111
100
  if (device.hub?.hide_humidity) {
112
101
  this.debugLog(`${this.device.deviceType}: ${accessory.displayName} Removing Humidity Sensor Service`);
113
- this.hubHumiditySensor = this.hubHumiditySensor.setCharacteristic(this.platform.Characteristic.CurrentRelativeHumidity, false);
114
- accessory.removeService(this.hubHumiditySensor!);
115
- } else if (!this.hubHumiditySensor) {
102
+ this.humidityService = this.accessory.getService(this.platform.Service.HumiditySensor);
103
+ accessory.removeService(this.humidityService!);
104
+ } else if (!this.humidityService) {
116
105
  this.debugLog(`${this.device.deviceType}: ${accessory.displayName} Add Humidity Sensor Service`);
117
- (this.hubHumiditySensor =
118
- accessory.getService(this.platform.Service.HumiditySensor) || accessory.addService(this.platform.Service.HumiditySensor)),
119
- `${device.deviceName} ${device.deviceType}`;
106
+ (this.humidityService =
107
+ this.accessory.getService(this.platform.Service.HumiditySensor) || this.accessory.addService(this.platform.Service.HumiditySensor)),
108
+ `${accessory.displayName} Humidity Sensor`;
120
109
 
121
- this.hubHumiditySensor.setCharacteristic(this.platform.Characteristic.Name, accessory.displayName);
122
- if (!this.hubHumiditySensor.testCharacteristic(this.platform.Characteristic.ConfiguredName)) {
123
- this.hubHumiditySensor.addCharacteristic(this.platform.Characteristic.ConfiguredName, accessory.displayName);
110
+ this.humidityService.setCharacteristic(this.platform.Characteristic.Name, `${accessory.displayName} Humidity Sensor`);
111
+ if (!this.humidityService.testCharacteristic(this.platform.Characteristic.ConfiguredName)) {
112
+ this.humidityService.addCharacteristic(this.platform.Characteristic.ConfiguredName, `${accessory.displayName} Humidity Sensor`);
124
113
  }
114
+ this.humidityService
115
+ .getCharacteristic(this.platform.Characteristic.CurrentRelativeHumidity)
116
+ .setProps({
117
+ minStep: 0.1,
118
+ })
119
+ .onGet(() => {
120
+ return this.CurrentRelativeHumidity;
121
+ });
125
122
  } else {
126
123
  this.debugLog(`${this.device.deviceType}: ${accessory.displayName} Humidity Sensor Service Not Added`);
127
124
  }
@@ -129,17 +126,16 @@ export class Hub {
129
126
  // Humidity Sensor Service
130
127
  if (device.hub?.hide_lightsensor) {
131
128
  this.debugLog(`${this.device.deviceType}: ${accessory.displayName} Removing Light Sensor Service`);
132
- this.hubLightSensor = this.hubLightSensor.setCharacteristic(this.platform.Characteristic.CurrentAmbientLightLevel, false);
133
- accessory.removeService(this.hubLightSensor!);
134
- } else if (!this.hubLightSensor) {
129
+ this.lightSensorService = this.accessory.getService(this.platform.Service.LightSensor);
130
+ accessory.removeService(this.lightSensorService!);
131
+ } else if (!this.lightSensorService) {
135
132
  this.debugLog(`${this.device.deviceType}: ${accessory.displayName} Add Light Sensor Service`);
136
- (this.hubLightSensor = accessory.getService(this.platform.Service.LightSensor) || accessory.addService(this.platform.Service.LightSensor)),
137
- `${device.deviceName} ${device.deviceType}`;
133
+ (this.lightSensorService =
134
+ this.accessory.getService(this.platform.Service.LightSensor) || this.accessory.addService(this.platform.Service.LightSensor)),
135
+ `${accessory.displayName} Light Sensor`;
138
136
 
139
- this.hubLightSensor.setCharacteristic(this.platform.Characteristic.Name, accessory.displayName);
140
- if (!this.hubLightSensor.testCharacteristic(this.platform.Characteristic.ConfiguredName)) {
141
- this.hubLightSensor.addCharacteristic(this.platform.Characteristic.ConfiguredName, accessory.displayName);
142
- }
137
+ this.lightSensorService.setCharacteristic(this.platform.Characteristic.Name, `${accessory.displayName} Light Sensor`);
138
+ this.lightSensorService.setCharacteristic(this.platform.Characteristic.ConfiguredName, `${accessory.displayName} Light Sensor`);
143
139
  } else {
144
140
  this.debugLog(`${this.device.deviceType}: ${accessory.displayName} Light Sensor Service Not Added`);
145
141
  }
@@ -170,109 +166,115 @@ export class Hub {
170
166
  async openAPIparseStatus(): Promise<void> {
171
167
  this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} openAPIparseStatus`);
172
168
  // Temperature
173
- this.CurrentTemperature = Number(this.OpenAPI_CurrentTemperature);
169
+ if (!this.device.hub?.hide_temperature) {
170
+ this.CurrentTemperature = Number(this.OpenAPI_CurrentTemperature);
171
+ }
174
172
 
175
173
  // Humidity
176
- this.CurrentRelativeHumidity = Number(this.OpenAPI_CurrentRelativeHumidity);
177
-
178
- if (!this.device.curtain?.hide_lightsensor) {
179
- this.set_minLux = this.minLux();
180
- this.set_maxLux = this.maxLux();
181
- this.spaceBetweenLevels = 19;
182
-
183
- // Brightness
184
- switch (this.OpenAPI_CurrentAmbientLightLevel) {
185
- case 1:
186
- this.CurrentAmbientLightLevel = this.set_minLux;
187
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} LightLevel: ${this.OpenAPI_CurrentAmbientLightLevel}`);
188
- break;
189
- case 2:
190
- this.CurrentAmbientLightLevel = (this.set_maxLux - this.set_minLux) / this.spaceBetweenLevels;
191
- this.debugLog(
192
- `${this.device.deviceType}: ${this.accessory.displayName} LightLevel: ${this.OpenAPI_CurrentAmbientLightLevel},` +
174
+ if (!this.device.hub?.hide_humidity) {
175
+ this.CurrentRelativeHumidity = Number(this.OpenAPI_CurrentRelativeHumidity);
176
+ }
177
+
178
+ // Brightness
179
+ if (!this.device.hub?.hide_lightsensor) {
180
+ if (!this.device.curtain?.hide_lightsensor) {
181
+ this.set_minLux = this.minLux();
182
+ this.set_maxLux = this.maxLux();
183
+ this.spaceBetweenLevels = 19;
184
+ switch (this.OpenAPI_CurrentAmbientLightLevel) {
185
+ case 1:
186
+ this.CurrentAmbientLightLevel = this.set_minLux;
187
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} LightLevel: ${this.OpenAPI_CurrentAmbientLightLevel}`);
188
+ break;
189
+ case 2:
190
+ this.CurrentAmbientLightLevel = (this.set_maxLux - this.set_minLux) / this.spaceBetweenLevels;
191
+ this.debugLog(
192
+ `${this.device.deviceType}: ${this.accessory.displayName} LightLevel: ${this.OpenAPI_CurrentAmbientLightLevel},` +
193
193
  ` Calculation: ${(this.set_maxLux - this.set_minLux) / this.spaceBetweenLevels}`,
194
- );
195
- break;
196
- case 3:
197
- this.CurrentAmbientLightLevel = ((this.set_maxLux - this.set_minLux) / this.spaceBetweenLevels) * 2;
198
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} LightLevel: ${this.OpenAPI_CurrentAmbientLightLevel}`);
199
- break;
200
- case 4:
201
- this.CurrentAmbientLightLevel = ((this.set_maxLux - this.set_minLux) / this.spaceBetweenLevels) * 3;
202
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} LightLevel: ${this.OpenAPI_CurrentAmbientLightLevel}`);
203
- break;
204
- case 5:
205
- this.CurrentAmbientLightLevel = ((this.set_maxLux - this.set_minLux) / this.spaceBetweenLevels) * 4;
206
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} LightLevel: ${this.OpenAPI_CurrentAmbientLightLevel}`);
207
- break;
208
- case 6:
209
- this.CurrentAmbientLightLevel = ((this.set_maxLux - this.set_minLux) / this.spaceBetweenLevels) * 5;
210
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} LightLevel: ${this.OpenAPI_CurrentAmbientLightLevel}`);
211
- break;
212
- case 7:
213
- this.CurrentAmbientLightLevel = ((this.set_maxLux - this.set_minLux) / this.spaceBetweenLevels) * 6;
214
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} LightLevel: ${this.OpenAPI_CurrentAmbientLightLevel}`);
215
- break;
216
- case 8:
217
- this.CurrentAmbientLightLevel = ((this.set_maxLux - this.set_minLux) / this.spaceBetweenLevels) * 7;
218
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} LightLevel: ${this.OpenAPI_CurrentAmbientLightLevel}`);
219
- break;
220
- case 9:
221
- this.CurrentAmbientLightLevel = ((this.set_maxLux - this.set_minLux) / this.spaceBetweenLevels) * 8;
222
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} LightLevel: ${this.OpenAPI_CurrentAmbientLightLevel}`);
223
- break;
224
- case 10:
225
- this.CurrentAmbientLightLevel = ((this.set_maxLux - this.set_minLux) / this.spaceBetweenLevels) * 9;
226
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} LightLevel: ${this.OpenAPI_CurrentAmbientLightLevel}`);
227
- break;
228
- case 11:
229
- this.CurrentAmbientLightLevel = ((this.set_maxLux - this.set_minLux) / this.spaceBetweenLevels) * 10;
230
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} LightLevel: ${this.OpenAPI_CurrentAmbientLightLevel}`);
231
- break;
232
- case 12:
233
- this.CurrentAmbientLightLevel = ((this.set_maxLux - this.set_minLux) / this.spaceBetweenLevels) * 11;
234
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} LightLevel: ${this.OpenAPI_CurrentAmbientLightLevel}`);
235
- break;
236
- case 13:
237
- this.CurrentAmbientLightLevel = ((this.set_maxLux - this.set_minLux) / this.spaceBetweenLevels) * 12;
238
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} LightLevel: ${this.OpenAPI_CurrentAmbientLightLevel}`);
239
- break;
240
- case 14:
241
- this.CurrentAmbientLightLevel = ((this.set_maxLux - this.set_minLux) / this.spaceBetweenLevels) * 13;
242
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} LightLevel: ${this.OpenAPI_CurrentAmbientLightLevel}`);
243
- break;
244
- case 15:
245
- this.CurrentAmbientLightLevel = ((this.set_maxLux - this.set_minLux) / this.spaceBetweenLevels) * 14;
246
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} LightLevel: ${this.OpenAPI_CurrentAmbientLightLevel}`);
247
- break;
248
- case 16:
249
- this.CurrentAmbientLightLevel = ((this.set_maxLux - this.set_minLux) / this.spaceBetweenLevels) * 15;
250
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} LightLevel: ${this.OpenAPI_CurrentAmbientLightLevel}`);
251
- break;
252
- case 17:
253
- this.CurrentAmbientLightLevel = ((this.set_maxLux - this.set_minLux) / this.spaceBetweenLevels) * 16;
254
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} LightLevel: ${this.OpenAPI_CurrentAmbientLightLevel}`);
255
- break;
256
- case 18:
257
- this.CurrentAmbientLightLevel = ((this.set_maxLux - this.set_minLux) / this.spaceBetweenLevels) * 17;
258
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} LightLevel: ${this.OpenAPI_CurrentAmbientLightLevel}`);
259
- break;
260
- case 19:
261
- this.CurrentAmbientLightLevel = ((this.set_maxLux - this.set_minLux) / this.spaceBetweenLevels) * 18;
262
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} LightLevel: ${this.OpenAPI_CurrentAmbientLightLevel}`);
263
- break;
264
- case 20:
265
- default:
266
- this.CurrentAmbientLightLevel = this.set_maxLux;
267
- this.debugLog();
268
- }
269
- this.debugLog(
270
- `${this.device.deviceType}: ${this.accessory.displayName} LightLevel: ${this.OpenAPI_CurrentAmbientLightLevel},` +
194
+ );
195
+ break;
196
+ case 3:
197
+ this.CurrentAmbientLightLevel = ((this.set_maxLux - this.set_minLux) / this.spaceBetweenLevels) * 2;
198
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} LightLevel: ${this.OpenAPI_CurrentAmbientLightLevel}`);
199
+ break;
200
+ case 4:
201
+ this.CurrentAmbientLightLevel = ((this.set_maxLux - this.set_minLux) / this.spaceBetweenLevels) * 3;
202
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} LightLevel: ${this.OpenAPI_CurrentAmbientLightLevel}`);
203
+ break;
204
+ case 5:
205
+ this.CurrentAmbientLightLevel = ((this.set_maxLux - this.set_minLux) / this.spaceBetweenLevels) * 4;
206
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} LightLevel: ${this.OpenAPI_CurrentAmbientLightLevel}`);
207
+ break;
208
+ case 6:
209
+ this.CurrentAmbientLightLevel = ((this.set_maxLux - this.set_minLux) / this.spaceBetweenLevels) * 5;
210
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} LightLevel: ${this.OpenAPI_CurrentAmbientLightLevel}`);
211
+ break;
212
+ case 7:
213
+ this.CurrentAmbientLightLevel = ((this.set_maxLux - this.set_minLux) / this.spaceBetweenLevels) * 6;
214
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} LightLevel: ${this.OpenAPI_CurrentAmbientLightLevel}`);
215
+ break;
216
+ case 8:
217
+ this.CurrentAmbientLightLevel = ((this.set_maxLux - this.set_minLux) / this.spaceBetweenLevels) * 7;
218
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} LightLevel: ${this.OpenAPI_CurrentAmbientLightLevel}`);
219
+ break;
220
+ case 9:
221
+ this.CurrentAmbientLightLevel = ((this.set_maxLux - this.set_minLux) / this.spaceBetweenLevels) * 8;
222
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} LightLevel: ${this.OpenAPI_CurrentAmbientLightLevel}`);
223
+ break;
224
+ case 10:
225
+ this.CurrentAmbientLightLevel = ((this.set_maxLux - this.set_minLux) / this.spaceBetweenLevels) * 9;
226
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} LightLevel: ${this.OpenAPI_CurrentAmbientLightLevel}`);
227
+ break;
228
+ case 11:
229
+ this.CurrentAmbientLightLevel = ((this.set_maxLux - this.set_minLux) / this.spaceBetweenLevels) * 10;
230
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} LightLevel: ${this.OpenAPI_CurrentAmbientLightLevel}`);
231
+ break;
232
+ case 12:
233
+ this.CurrentAmbientLightLevel = ((this.set_maxLux - this.set_minLux) / this.spaceBetweenLevels) * 11;
234
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} LightLevel: ${this.OpenAPI_CurrentAmbientLightLevel}`);
235
+ break;
236
+ case 13:
237
+ this.CurrentAmbientLightLevel = ((this.set_maxLux - this.set_minLux) / this.spaceBetweenLevels) * 12;
238
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} LightLevel: ${this.OpenAPI_CurrentAmbientLightLevel}`);
239
+ break;
240
+ case 14:
241
+ this.CurrentAmbientLightLevel = ((this.set_maxLux - this.set_minLux) / this.spaceBetweenLevels) * 13;
242
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} LightLevel: ${this.OpenAPI_CurrentAmbientLightLevel}`);
243
+ break;
244
+ case 15:
245
+ this.CurrentAmbientLightLevel = ((this.set_maxLux - this.set_minLux) / this.spaceBetweenLevels) * 14;
246
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} LightLevel: ${this.OpenAPI_CurrentAmbientLightLevel}`);
247
+ break;
248
+ case 16:
249
+ this.CurrentAmbientLightLevel = ((this.set_maxLux - this.set_minLux) / this.spaceBetweenLevels) * 15;
250
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} LightLevel: ${this.OpenAPI_CurrentAmbientLightLevel}`);
251
+ break;
252
+ case 17:
253
+ this.CurrentAmbientLightLevel = ((this.set_maxLux - this.set_minLux) / this.spaceBetweenLevels) * 16;
254
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} LightLevel: ${this.OpenAPI_CurrentAmbientLightLevel}`);
255
+ break;
256
+ case 18:
257
+ this.CurrentAmbientLightLevel = ((this.set_maxLux - this.set_minLux) / this.spaceBetweenLevels) * 17;
258
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} LightLevel: ${this.OpenAPI_CurrentAmbientLightLevel}`);
259
+ break;
260
+ case 19:
261
+ this.CurrentAmbientLightLevel = ((this.set_maxLux - this.set_minLux) / this.spaceBetweenLevels) * 18;
262
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} LightLevel: ${this.OpenAPI_CurrentAmbientLightLevel}`);
263
+ break;
264
+ case 20:
265
+ default:
266
+ this.CurrentAmbientLightLevel = this.set_maxLux;
267
+ this.debugLog();
268
+ }
269
+ this.debugLog(
270
+ `${this.device.deviceType}: ${this.accessory.displayName} LightLevel: ${this.OpenAPI_CurrentAmbientLightLevel},` +
271
271
  ` CurrentAmbientLightLevel: ${this.CurrentAmbientLightLevel}`,
272
- );
272
+ );
273
+ }
274
+ if (!this.device.hub?.hide_lightsensor) {
275
+ this.lightSensorService?.setCharacteristic(this.platform.Characteristic.CurrentAmbientLightLevel, this.CurrentAmbientLightLevel);
276
+ }
273
277
  }
274
-
275
- this.hubLightSensor.setCharacteristic(this.platform.Characteristic.CurrentAmbientLightLevel, this.CurrentAmbientLightLevel);
276
278
  }
277
279
 
278
280
  async refreshStatus(): Promise<void> {
@@ -290,17 +292,26 @@ export class Hub {
290
292
  const { body, statusCode, headers } = await request(`${Devices}/${this.device.deviceId}/status`, {
291
293
  headers: this.platform.generateHeaders(),
292
294
  });
295
+ this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} body: ${JSON.stringify(body)}`);
296
+ this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} statusCode: ${statusCode}`);
297
+ this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} headers: ${JSON.stringify(headers)}`);
293
298
  const deviceStatus: any = await body.json();
294
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Devices: ${JSON.stringify(deviceStatus.body)}`);
295
- this.statusCode(statusCode);
296
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Headers: ${JSON.stringify(headers)}`);
297
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} refreshStatus: ${JSON.stringify(deviceStatus)}`);
298
- this.OpenAPI_CurrentTemperature = deviceStatus.body.temperature;
299
- this.OpenAPI_CurrentRelativeHumidity = deviceStatus.body.humidity;
300
- this.OpenAPI_CurrentAmbientLightLevel = deviceStatus.body.lightLevel;
301
- this.OpenAPI_FirmwareRevision = deviceStatus.body.version;
302
- this.openAPIparseStatus();
303
- this.updateHomeKitCharacteristics();
299
+ this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} deviceStatus: ${JSON.stringify(deviceStatus)}`);
300
+ this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} deviceStatus body: ${JSON.stringify(deviceStatus.body)}`);
301
+ this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} deviceStatus statusCode: ${deviceStatus.statusCode}`);
302
+ if ((statusCode === 200 || statusCode === 100) && (deviceStatus.statusCode === 200 || deviceStatus.statusCode === 100)) {
303
+ this.debugErrorLog(`${this.device.deviceType}: ${this.accessory.displayName} `
304
+ + `statusCode: ${statusCode} & deviceStatus StatusCode: ${deviceStatus.statusCode}`);
305
+ this.OpenAPI_CurrentTemperature = deviceStatus.body.temperature;
306
+ this.OpenAPI_CurrentRelativeHumidity = deviceStatus.body.humidity;
307
+ this.OpenAPI_CurrentAmbientLightLevel = deviceStatus.body.lightLevel;
308
+ this.OpenAPI_FirmwareRevision = deviceStatus.body.version;
309
+ this.openAPIparseStatus();
310
+ this.updateHomeKitCharacteristics();
311
+ } else {
312
+ this.statusCode(statusCode);
313
+ this.statusCode(deviceStatus.statusCode);
314
+ }
304
315
  } catch (e: any) {
305
316
  this.apiError(e);
306
317
  this.errorLog(
@@ -335,31 +346,37 @@ export class Hub {
335
346
  */
336
347
 
337
348
  async updateHomeKitCharacteristics(): Promise<void> {
338
- if (this.CurrentTemperature === undefined) {
339
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} CurrentTemperature: ${this.CurrentTemperature}`);
340
- } else {
341
- this.accessory.context.CurrentTemperature = this.CurrentTemperature;
342
- this.hubTemperatureSensor?.updateCharacteristic(this.platform.Characteristic.CurrentTemperature, this.CurrentTemperature);
343
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} updateCharacteristic CurrentTemperature: ${this.CurrentTemperature}`);
349
+ if (!this.device.hub?.hide_temperature) {
350
+ if (this.CurrentTemperature === undefined) {
351
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} CurrentTemperature: ${this.CurrentTemperature}`);
352
+ } else {
353
+ this.accessory.context.CurrentTemperature = this.CurrentTemperature;
354
+ this.temperatureService?.updateCharacteristic(this.platform.Characteristic.CurrentTemperature, this.CurrentTemperature);
355
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} updateCharacteristic CurrentTemperature: ${this.CurrentTemperature}`);
356
+ }
344
357
  }
345
- if (this.CurrentRelativeHumidity === undefined) {
346
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} CurrentRelativeHumidity: ${this.CurrentRelativeHumidity}`);
347
- } else {
348
- this.accessory.context.CurrentRelativeHumidity = this.CurrentRelativeHumidity;
349
- this.hubHumiditySensor?.updateCharacteristic(this.platform.Characteristic.CurrentRelativeHumidity, this.CurrentRelativeHumidity);
350
- this.debugLog(
351
- `${this.device.deviceType}: ${this.accessory.displayName} ` + `updateCharacteristic CurrentRelativeHumidity: ${this.CurrentRelativeHumidity}`,
352
- );
358
+ if (!this.device.hub?.hide_humidity) {
359
+ if (this.CurrentRelativeHumidity === undefined) {
360
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} CurrentRelativeHumidity: ${this.CurrentRelativeHumidity}`);
361
+ } else {
362
+ this.accessory.context.CurrentRelativeHumidity = this.CurrentRelativeHumidity;
363
+ this.humidityService?.updateCharacteristic(this.platform.Characteristic.CurrentRelativeHumidity, this.CurrentRelativeHumidity);
364
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} `
365
+ + `updateCharacteristic CurrentRelativeHumidity: ${this.CurrentRelativeHumidity}`,
366
+ );
367
+ }
353
368
  }
354
- if (this.CurrentAmbientLightLevel === undefined) {
355
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} CurrentAmbientLightLevel: ${this.CurrentAmbientLightLevel}`);
356
- } else {
357
- this.accessory.context.CurrentAmbientLightLevel = this.CurrentAmbientLightLevel;
358
- this.hubLightSensor?.updateCharacteristic(this.platform.Characteristic.CurrentAmbientLightLevel, this.CurrentAmbientLightLevel);
359
- this.debugLog(
360
- `${this.device.deviceType}: ${this.accessory.displayName} `
369
+ if (!this.device.hub?.hide_lightsensor) {
370
+ if (this.CurrentAmbientLightLevel === undefined) {
371
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} CurrentAmbientLightLevel: ${this.CurrentAmbientLightLevel}`);
372
+ } else {
373
+ this.accessory.context.CurrentAmbientLightLevel = this.CurrentAmbientLightLevel;
374
+ this.lightSensorService?.updateCharacteristic(this.platform.Characteristic.CurrentAmbientLightLevel, this.CurrentAmbientLightLevel);
375
+ this.debugLog(
376
+ `${this.device.deviceType}: ${this.accessory.displayName} `
361
377
  + `updateCharacteristic CurrentAmbientLightLevel: ${this.CurrentAmbientLightLevel}`,
362
- );
378
+ );
379
+ }
363
380
  }
364
381
  // FirmwareRevision
365
382
  if (this.OpenAPI_FirmwareRevision === undefined) {
@@ -369,7 +386,7 @@ export class Hub {
369
386
  this.accessory.getService(this.platform.Service.AccessoryInformation)!
370
387
  .updateCharacteristic(this.platform.Characteristic.FirmwareRevision, this.OpenAPI_FirmwareRevision);
371
388
  this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} `
372
- + `updateCharacteristic CurrentTemperature: ${this.OpenAPI_FirmwareRevision}`);
389
+ + `updateCharacteristic FirmwareRevision: ${this.OpenAPI_FirmwareRevision}`);
373
390
  }
374
391
  }
375
392
 
@@ -422,9 +439,15 @@ export class Hub {
422
439
  }
423
440
 
424
441
  async apiError(e: any): Promise<void> {
425
- this.hubTemperatureSensor?.updateCharacteristic(this.platform.Characteristic.CurrentTemperature, e);
426
- this.hubHumiditySensor?.updateCharacteristic(this.platform.Characteristic.CurrentRelativeHumidity, e);
427
- this.hubLightSensor?.updateCharacteristic(this.platform.Characteristic.CurrentAmbientLightLevel, e);
442
+ if (!this.device.hub?.hide_temperature) {
443
+ this.temperatureService?.updateCharacteristic(this.platform.Characteristic.CurrentTemperature, e);
444
+ }
445
+ if (!this.device.hub?.hide_humidity) {
446
+ this.humidityService?.updateCharacteristic(this.platform.Characteristic.CurrentRelativeHumidity, e);
447
+ }
448
+ if (!this.device.hub?.hide_lightsensor) {
449
+ this.lightSensorService?.updateCharacteristic(this.platform.Characteristic.CurrentAmbientLightLevel, e);
450
+ }
428
451
  }
429
452
 
430
453
  minLux(): number {
@@ -91,12 +91,6 @@ export class Humidifier {
91
91
  accessory.getService(this.platform.Service.HumidifierDehumidifier) || accessory.addService(this.platform.Service.HumidifierDehumidifier)),
92
92
  `${accessory.displayName} Humidifier`;
93
93
 
94
- // To avoid "Cannot add a Service with the same UUID another Service without also defining a unique 'subtype' property." error,
95
- // when creating multiple services of the same type, you need to use the following syntax to specify a name and subtype id:
96
- // accessory.getService('NAME') ?? accessory.addService(this.platform.Service.HumidifierDehumidifier, 'NAME', 'USER_DEFINED_SUBTYPE');
97
-
98
- // set the service name, this is what is displayed as the default name on the Home app
99
- // in this example we are using the name we stored in the `accessory.context` in the `discoverDevices` method.
100
94
  this.humidifierService.setCharacteristic(this.platform.Characteristic.Name, accessory.displayName);
101
95
  if (!this.humidifierService.testCharacteristic(this.platform.Characteristic.ConfiguredName)) {
102
96
  this.humidifierService.addCharacteristic(this.platform.Characteristic.ConfiguredName, accessory.displayName);
@@ -375,20 +369,29 @@ export class Humidifier {
375
369
  const { body, statusCode, headers } = await request(`${Devices}/${this.device.deviceId}/status`, {
376
370
  headers: this.platform.generateHeaders(),
377
371
  });
372
+ this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} body: ${JSON.stringify(body)}`);
373
+ this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} statusCode: ${statusCode}`);
374
+ this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} headers: ${JSON.stringify(headers)}`);
378
375
  const deviceStatus: any = await body.json();
379
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Devices: ${JSON.stringify(deviceStatus.body)}`);
380
- this.statusCode(statusCode);
381
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Headers: ${JSON.stringify(headers)}`);
382
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} refreshStatus: ${JSON.stringify(deviceStatus)}`);
383
- this.OpenAPI_CurrentHumidifierDehumidifierState = deviceStatus.body.auto;
384
- this.OpenAPI_Active = deviceStatus.body.power;
385
- this.OpenAPI_WaterLevel = deviceStatus.body.lackWater;
386
- this.OpenAPI_CurrentRelativeHumidity = deviceStatus.body.humidity;
387
- this.OpenAPI_CurrentTemperature = deviceStatus.body.temperature;
388
- this.OpenAPI_RelativeHumidityHumidifierThreshold = deviceStatus.body.nebulizationEfficiency;
389
- this.OpenAPI_FirmwareRevision = deviceStatus.body.version;
390
- this.openAPIparseStatus();
391
- this.updateHomeKitCharacteristics();
376
+ this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} deviceStatus: ${JSON.stringify(deviceStatus)}`);
377
+ this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} deviceStatus body: ${JSON.stringify(deviceStatus.body)}`);
378
+ this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} deviceStatus statusCode: ${deviceStatus.statusCode}`);
379
+ if ((statusCode === 200 || statusCode === 100) && (deviceStatus.statusCode === 200 || deviceStatus.statusCode === 100)) {
380
+ this.debugErrorLog(`${this.device.deviceType}: ${this.accessory.displayName} `
381
+ + `statusCode: ${statusCode} & deviceStatus StatusCode: ${deviceStatus.statusCode}`);
382
+ this.OpenAPI_CurrentHumidifierDehumidifierState = deviceStatus.body.auto;
383
+ this.OpenAPI_Active = deviceStatus.body.power;
384
+ this.OpenAPI_WaterLevel = deviceStatus.body.lackWater;
385
+ this.OpenAPI_CurrentRelativeHumidity = deviceStatus.body.humidity;
386
+ this.OpenAPI_CurrentTemperature = deviceStatus.body.temperature;
387
+ this.OpenAPI_RelativeHumidityHumidifierThreshold = deviceStatus.body.nebulizationEfficiency;
388
+ this.OpenAPI_FirmwareRevision = deviceStatus.body.version;
389
+ this.openAPIparseStatus();
390
+ this.updateHomeKitCharacteristics();
391
+ } else {
392
+ this.statusCode(statusCode);
393
+ this.statusCode(deviceStatus.statusCode);
394
+ }
392
395
  } catch (e: any) {
393
396
  this.apiError(e);
394
397
  this.errorLog(
@@ -472,10 +475,20 @@ export class Humidifier {
472
475
  method: 'POST',
473
476
  headers: this.platform.generateHeaders(),
474
477
  });
478
+ this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} body: ${JSON.stringify(body)}`);
479
+ this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} statusCode: ${statusCode}`);
480
+ this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} headers: ${JSON.stringify(headers)}`);
475
481
  const deviceStatus: any = await body.json();
476
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Devices: ${JSON.stringify(deviceStatus.body)}`);
477
- this.statusCode(statusCode);
478
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Headers: ${JSON.stringify(headers)}`);
482
+ this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} deviceStatus: ${JSON.stringify(deviceStatus)}`);
483
+ this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} deviceStatus body: ${JSON.stringify(deviceStatus.body)}`);
484
+ this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} deviceStatus statusCode: ${deviceStatus.statusCode}`);
485
+ if ((statusCode === 200 || statusCode === 100) && (deviceStatus.statusCode === 200 || deviceStatus.statusCode === 100)) {
486
+ this.debugErrorLog(`${this.device.deviceType}: ${this.accessory.displayName} `
487
+ + `statusCode: ${statusCode} & deviceStatus StatusCode: ${deviceStatus.statusCode}`);
488
+ } else {
489
+ this.statusCode(statusCode);
490
+ this.statusCode(deviceStatus.statusCode);
491
+ }
479
492
  } catch (e: any) {
480
493
  this.apiError(e);
481
494
  this.errorLog(
@@ -515,10 +528,20 @@ export class Humidifier {
515
528
  method: 'POST',
516
529
  headers: this.platform.generateHeaders(),
517
530
  });
531
+ this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} body: ${JSON.stringify(body)}`);
532
+ this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} statusCode: ${statusCode}`);
533
+ this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} headers: ${JSON.stringify(headers)}`);
518
534
  const deviceStatus: any = await body.json();
519
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Devices: ${JSON.stringify(deviceStatus.body)}`);
520
- this.statusCode(statusCode);
521
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Headers: ${JSON.stringify(headers)}`);
535
+ this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} deviceStatus: ${JSON.stringify(deviceStatus)}`);
536
+ this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} deviceStatus body: ${JSON.stringify(deviceStatus.body)}`);
537
+ this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} deviceStatus statusCode: ${deviceStatus.statusCode}`);
538
+ if ((statusCode === 200 || statusCode === 100) && (deviceStatus.statusCode === 200 || deviceStatus.statusCode === 100)) {
539
+ this.debugErrorLog(`${this.device.deviceType}: ${this.accessory.displayName} `
540
+ + `statusCode: ${statusCode} & deviceStatus StatusCode: ${deviceStatus.statusCode}`);
541
+ } else {
542
+ this.statusCode(statusCode);
543
+ this.statusCode(deviceStatus.statusCode);
544
+ }
522
545
  } catch (e: any) {
523
546
  this.apiError(e);
524
547
  this.errorLog(
@@ -553,10 +576,20 @@ export class Humidifier {
553
576
  method: 'POST',
554
577
  headers: this.platform.generateHeaders(),
555
578
  });
579
+ this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} body: ${JSON.stringify(body)}`);
580
+ this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} statusCode: ${statusCode}`);
581
+ this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} headers: ${JSON.stringify(headers)}`);
556
582
  const deviceStatus: any = await body.json();
557
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Devices: ${JSON.stringify(deviceStatus.body)}`);
558
- this.statusCode(statusCode);
559
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Headers: ${JSON.stringify(headers)}`);
583
+ this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} deviceStatus: ${JSON.stringify(deviceStatus)}`);
584
+ this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} deviceStatus body: ${JSON.stringify(deviceStatus.body)}`);
585
+ this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} deviceStatus statusCode: ${deviceStatus.statusCode}`);
586
+ if ((statusCode === 200 || statusCode === 100) && (deviceStatus.statusCode === 200 || deviceStatus.statusCode === 100)) {
587
+ this.debugErrorLog(`${this.device.deviceType}: ${this.accessory.displayName} `
588
+ + `statusCode: ${statusCode} & deviceStatus StatusCode: ${deviceStatus.statusCode}`);
589
+ } else {
590
+ this.statusCode(statusCode);
591
+ this.statusCode(deviceStatus.statusCode);
592
+ }
560
593
  } catch (e: any) {
561
594
  this.apiError(e);
562
595
  this.errorLog(
@@ -708,7 +741,7 @@ export class Humidifier {
708
741
  this.accessory.getService(this.platform.Service.AccessoryInformation)!
709
742
  .updateCharacteristic(this.platform.Characteristic.FirmwareRevision, this.OpenAPI_FirmwareRevision);
710
743
  this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} `
711
- + `updateCharacteristic CurrentTemperature: ${this.OpenAPI_FirmwareRevision}`);
744
+ + `updateCharacteristic FirmwareRevision: ${this.OpenAPI_FirmwareRevision}`);
712
745
  }
713
746
  }
714
747