@switchbot/homebridge-switchbot 2.8.1-beta.19 → 2.8.1-beta.20

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 (87) hide show
  1. package/dist/device/blindtilt.d.ts.map +1 -1
  2. package/dist/device/blindtilt.js +0 -7
  3. package/dist/device/blindtilt.js.map +1 -1
  4. package/dist/device/ceilinglight.d.ts.map +1 -1
  5. package/dist/device/ceilinglight.js +0 -5
  6. package/dist/device/ceilinglight.js.map +1 -1
  7. package/dist/device/colorbulb.d.ts.map +1 -1
  8. package/dist/device/colorbulb.js +0 -5
  9. package/dist/device/colorbulb.js.map +1 -1
  10. package/dist/device/contact.d.ts.map +1 -1
  11. package/dist/device/contact.js +0 -7
  12. package/dist/device/contact.js.map +1 -1
  13. package/dist/device/curtain.d.ts.map +1 -1
  14. package/dist/device/curtain.js +0 -5
  15. package/dist/device/curtain.js.map +1 -1
  16. package/dist/device/hub.d.ts +3 -3
  17. package/dist/device/hub.d.ts.map +1 -1
  18. package/dist/device/hub.js +184 -161
  19. package/dist/device/hub.js.map +1 -1
  20. package/dist/device/humidifier.d.ts.map +1 -1
  21. package/dist/device/humidifier.js +0 -5
  22. package/dist/device/humidifier.js.map +1 -1
  23. package/dist/device/lightstrip.d.ts.map +1 -1
  24. package/dist/device/lightstrip.js +0 -5
  25. package/dist/device/lightstrip.js.map +1 -1
  26. package/dist/device/lock.d.ts.map +1 -1
  27. package/dist/device/lock.js +0 -5
  28. package/dist/device/lock.js.map +1 -1
  29. package/dist/device/meter.d.ts +2 -2
  30. package/dist/device/meter.d.ts.map +1 -1
  31. package/dist/device/meter.js +20 -20
  32. package/dist/device/meter.js.map +1 -1
  33. package/dist/device/motion.d.ts.map +1 -1
  34. package/dist/device/motion.js +0 -5
  35. package/dist/device/motion.js.map +1 -1
  36. package/dist/device/plug.d.ts.map +1 -1
  37. package/dist/device/plug.js +0 -5
  38. package/dist/device/plug.js.map +1 -1
  39. package/dist/device/robotvacuumcleaner.d.ts.map +1 -1
  40. package/dist/device/robotvacuumcleaner.js +0 -5
  41. package/dist/device/robotvacuumcleaner.js.map +1 -1
  42. package/dist/irdevice/airconditioner.d.ts.map +1 -1
  43. package/dist/irdevice/airconditioner.js +0 -5
  44. package/dist/irdevice/airconditioner.js.map +1 -1
  45. package/dist/irdevice/airpurifier.d.ts.map +1 -1
  46. package/dist/irdevice/airpurifier.js +0 -5
  47. package/dist/irdevice/airpurifier.js.map +1 -1
  48. package/dist/irdevice/camera.d.ts.map +1 -1
  49. package/dist/irdevice/camera.js +0 -5
  50. package/dist/irdevice/camera.js.map +1 -1
  51. package/dist/irdevice/fan.d.ts.map +1 -1
  52. package/dist/irdevice/fan.js +0 -5
  53. package/dist/irdevice/fan.js.map +1 -1
  54. package/dist/irdevice/light.d.ts.map +1 -1
  55. package/dist/irdevice/light.js +0 -5
  56. package/dist/irdevice/light.js.map +1 -1
  57. package/dist/irdevice/tv.d.ts.map +1 -1
  58. package/dist/irdevice/tv.js +0 -5
  59. package/dist/irdevice/tv.js.map +1 -1
  60. package/dist/irdevice/vacuumcleaner.d.ts.map +1 -1
  61. package/dist/irdevice/vacuumcleaner.js +0 -5
  62. package/dist/irdevice/vacuumcleaner.js.map +1 -1
  63. package/dist/irdevice/waterheater.d.ts.map +1 -1
  64. package/dist/irdevice/waterheater.js +0 -5
  65. package/dist/irdevice/waterheater.js.map +1 -1
  66. package/package.json +1 -1
  67. package/src/device/blindtilt.ts +0 -9
  68. package/src/device/ceilinglight.ts +0 -6
  69. package/src/device/colorbulb.ts +0 -6
  70. package/src/device/contact.ts +0 -8
  71. package/src/device/curtain.ts +0 -6
  72. package/src/device/hub.ts +191 -177
  73. package/src/device/humidifier.ts +0 -6
  74. package/src/device/lightstrip.ts +0 -6
  75. package/src/device/lock.ts +0 -6
  76. package/src/device/meter.ts +22 -23
  77. package/src/device/motion.ts +0 -6
  78. package/src/device/plug.ts +0 -6
  79. package/src/device/robotvacuumcleaner.ts +0 -6
  80. package/src/irdevice/airconditioner.ts +0 -6
  81. package/src/irdevice/airpurifier.ts +0 -6
  82. package/src/irdevice/camera.ts +0 -6
  83. package/src/irdevice/fan.ts +0 -6
  84. package/src/irdevice/light.ts +0 -6
  85. package/src/irdevice/tv.ts +0 -6
  86. package/src/irdevice/vacuumcleaner.ts +0 -6
  87. package/src/irdevice/waterheater.ts +0 -6
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> {
@@ -344,31 +346,37 @@ export class Hub {
344
346
  */
345
347
 
346
348
  async updateHomeKitCharacteristics(): Promise<void> {
347
- if (this.CurrentTemperature === undefined) {
348
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} CurrentTemperature: ${this.CurrentTemperature}`);
349
- } else {
350
- this.accessory.context.CurrentTemperature = this.CurrentTemperature;
351
- this.hubTemperatureSensor?.updateCharacteristic(this.platform.Characteristic.CurrentTemperature, this.CurrentTemperature);
352
- 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
+ }
353
357
  }
354
- if (this.CurrentRelativeHumidity === undefined) {
355
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} CurrentRelativeHumidity: ${this.CurrentRelativeHumidity}`);
356
- } else {
357
- this.accessory.context.CurrentRelativeHumidity = this.CurrentRelativeHumidity;
358
- this.hubHumiditySensor?.updateCharacteristic(this.platform.Characteristic.CurrentRelativeHumidity, this.CurrentRelativeHumidity);
359
- this.debugLog(
360
- `${this.device.deviceType}: ${this.accessory.displayName} ` + `updateCharacteristic CurrentRelativeHumidity: ${this.CurrentRelativeHumidity}`,
361
- );
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
+ }
362
368
  }
363
- if (this.CurrentAmbientLightLevel === undefined) {
364
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} CurrentAmbientLightLevel: ${this.CurrentAmbientLightLevel}`);
365
- } else {
366
- this.accessory.context.CurrentAmbientLightLevel = this.CurrentAmbientLightLevel;
367
- this.hubLightSensor?.updateCharacteristic(this.platform.Characteristic.CurrentAmbientLightLevel, this.CurrentAmbientLightLevel);
368
- this.debugLog(
369
- `${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} `
370
377
  + `updateCharacteristic CurrentAmbientLightLevel: ${this.CurrentAmbientLightLevel}`,
371
- );
378
+ );
379
+ }
372
380
  }
373
381
  // FirmwareRevision
374
382
  if (this.OpenAPI_FirmwareRevision === undefined) {
@@ -431,9 +439,15 @@ export class Hub {
431
439
  }
432
440
 
433
441
  async apiError(e: any): Promise<void> {
434
- this.hubTemperatureSensor?.updateCharacteristic(this.platform.Characteristic.CurrentTemperature, e);
435
- this.hubHumiditySensor?.updateCharacteristic(this.platform.Characteristic.CurrentRelativeHumidity, e);
436
- 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
+ }
437
451
  }
438
452
 
439
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);
@@ -102,12 +102,6 @@ export class StripLight {
102
102
  this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} adaptiveLighting: ${this.accessory.context.adaptiveLighting}`);
103
103
  }
104
104
 
105
- // To avoid "Cannot add a Service with the same UUID another Service without also defining a unique 'subtype' property." error,
106
- // when creating multiple services of the same type, you need to use the following syntax to specify a name and subtype id:
107
- // accessory.getService('NAME') ?? accessory.addService(this.platform.Service.Outlet, 'NAME', 'USER_DEFINED_SUBTYPE');
108
-
109
- // set the service name, this is what is displayed as the default name on the Home app
110
- // in this example we are using the name we stored in the `accessory.context` in the `discoverDevices` method.
111
105
  this.lightBulbService.setCharacteristic(this.platform.Characteristic.Name, accessory.displayName);
112
106
  if (!this.lightBulbService.testCharacteristic(this.platform.Characteristic.ConfiguredName)) {
113
107
  this.lightBulbService.addCharacteristic(this.platform.Characteristic.ConfiguredName, accessory.displayName);
@@ -83,12 +83,6 @@ export class Lock {
83
83
  (this.lockService = accessory.getService(this.platform.Service.LockMechanism) || accessory.addService(this.platform.Service.LockMechanism)),
84
84
  `${device.deviceName} ${device.deviceType}`;
85
85
 
86
- // To avoid "Cannot add a Service with the same UUID another Service without also defining a unique 'subtype' property." error,
87
- // when creating multiple services of the same type, you need to use the following syntax to specify a name and subtype id:
88
- // accessory.getService('NAME') ?? accessory.addService(this.platform.Service.LockMechanism, 'NAME', 'USER_DEFINED_SUBTYPE');
89
-
90
- // set the service name, this is what is displayed as the default name on the Home app
91
- // in this example we are using the name we stored in the `accessory.context` in the `discoverDevices` method.
92
86
  this.lockService.setCharacteristic(this.platform.Characteristic.Name, accessory.displayName);
93
87
  if (!this.lockService.testCharacteristic(this.platform.Characteristic.ConfiguredName)) {
94
88
  this.lockService.addCharacteristic(this.platform.Characteristic.ConfiguredName, accessory.displayName);
@@ -18,8 +18,8 @@ import { sleep } from '../utils';
18
18
  export class Meter {
19
19
  // Services
20
20
  batteryService: Service;
21
- humidityservice?: Service;
22
- temperatureservice?: Service;
21
+ humidityService?: Service;
22
+ temperatureService?: Service;
23
23
 
24
24
  // Characteristic Values
25
25
  BatteryLevel!: CharacteristicValue;
@@ -96,19 +96,19 @@ export class Meter {
96
96
  // Temperature Sensor Service
97
97
  if (device.meter?.hide_temperature) {
98
98
  this.debugLog(`${this.device.deviceType}: ${accessory.displayName} Removing Temperature Sensor Service`);
99
- this.temperatureservice = this.accessory.getService(this.platform.Service.TemperatureSensor);
100
- accessory.removeService(this.temperatureservice!);
101
- } else if (!this.temperatureservice) {
99
+ this.temperatureService = this.accessory.getService(this.platform.Service.TemperatureSensor);
100
+ accessory.removeService(this.temperatureService!);
101
+ } else if (!this.temperatureService) {
102
102
  this.debugLog(`${this.device.deviceType}: ${accessory.displayName} Add Temperature Sensor Service`);
103
- (this.temperatureservice =
103
+ (this.temperatureService =
104
104
  this.accessory.getService(this.platform.Service.TemperatureSensor) || this.accessory.addService(this.platform.Service.TemperatureSensor)),
105
105
  `${accessory.displayName} Temperature Sensor`;
106
106
 
107
- this.temperatureservice.setCharacteristic(this.platform.Characteristic.Name, `${accessory.displayName} Temperature Sensor`);
108
- if (!this.temperatureservice.testCharacteristic(this.platform.Characteristic.ConfiguredName)) {
109
- this.temperatureservice.addCharacteristic(this.platform.Characteristic.ConfiguredName, `${accessory.displayName} Temperature Sensor`);
107
+ this.temperatureService.setCharacteristic(this.platform.Characteristic.Name, `${accessory.displayName} Temperature Sensor`);
108
+ if (!this.temperatureService.testCharacteristic(this.platform.Characteristic.ConfiguredName)) {
109
+ this.temperatureService.addCharacteristic(this.platform.Characteristic.ConfiguredName, `${accessory.displayName} Temperature Sensor`);
110
110
  }
111
- this.temperatureservice
111
+ this.temperatureService
112
112
  .getCharacteristic(this.platform.Characteristic.CurrentTemperature)
113
113
  .setProps({
114
114
  unit: Units['CELSIUS'],
@@ -127,19 +127,19 @@ export class Meter {
127
127
  // Humidity Sensor Service
128
128
  if (device.meter?.hide_humidity) {
129
129
  this.debugLog(`${this.device.deviceType}: ${accessory.displayName} Removing Humidity Sensor Service`);
130
- this.humidityservice = this.accessory.getService(this.platform.Service.HumiditySensor);
131
- accessory.removeService(this.humidityservice!);
132
- } else if (!this.humidityservice) {
130
+ this.humidityService = this.accessory.getService(this.platform.Service.HumiditySensor);
131
+ accessory.removeService(this.humidityService!);
132
+ } else if (!this.humidityService) {
133
133
  this.debugLog(`${this.device.deviceType}: ${accessory.displayName} Add Humidity Sensor Service`);
134
- (this.humidityservice =
134
+ (this.humidityService =
135
135
  this.accessory.getService(this.platform.Service.HumiditySensor) || this.accessory.addService(this.platform.Service.HumiditySensor)),
136
136
  `${accessory.displayName} Humidity Sensor`;
137
137
 
138
- this.humidityservice.setCharacteristic(this.platform.Characteristic.Name, `${accessory.displayName} Humidity Sensor`);
139
- if (!this.humidityservice.testCharacteristic(this.platform.Characteristic.ConfiguredName)) {
140
- this.humidityservice.addCharacteristic(this.platform.Characteristic.ConfiguredName, `${accessory.displayName} Humidity Sensor`);
138
+ this.humidityService.setCharacteristic(this.platform.Characteristic.Name, `${accessory.displayName} Humidity Sensor`);
139
+ if (!this.humidityService.testCharacteristic(this.platform.Characteristic.ConfiguredName)) {
140
+ this.humidityService.addCharacteristic(this.platform.Characteristic.ConfiguredName, `${accessory.displayName} Humidity Sensor`);
141
141
  }
142
- this.humidityservice
142
+ this.humidityService
143
143
  .getCharacteristic(this.platform.Characteristic.CurrentRelativeHumidity)
144
144
  .setProps({
145
145
  minStep: 0.1,
@@ -374,7 +374,7 @@ export class Meter {
374
374
  this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} CurrentRelativeHumidity: ${this.CurrentRelativeHumidity}`);
375
375
  } else {
376
376
  this.accessory.context.CurrentRelativeHumidity = this.CurrentRelativeHumidity;
377
- this.humidityservice?.updateCharacteristic(this.platform.Characteristic.CurrentRelativeHumidity, this.CurrentRelativeHumidity);
377
+ this.humidityService?.updateCharacteristic(this.platform.Characteristic.CurrentRelativeHumidity, this.CurrentRelativeHumidity);
378
378
  this.debugLog(
379
379
  `${this.device.deviceType}: ${this.accessory.displayName} updateCharacteristic` +
380
380
  ` CurrentRelativeHumidity: ${this.CurrentRelativeHumidity}`,
@@ -398,11 +398,10 @@ export class Meter {
398
398
  entry['temp'] = this.CurrentTemperature;
399
399
  }
400
400
  this.accessory.context.CurrentTemperature = this.CurrentTemperature;
401
- this.temperatureservice?.updateCharacteristic(this.platform.Characteristic.CurrentTemperature, this.CurrentTemperature);
401
+ this.temperatureService?.updateCharacteristic(this.platform.Characteristic.CurrentTemperature, this.CurrentTemperature);
402
402
  this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} updateCharacteristic CurrentTemperature: ${this.CurrentTemperature}`);
403
403
  }
404
404
  }
405
-
406
405
  if (this.BatteryLevel === undefined) {
407
406
  this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} BatteryLevel: ${this.BatteryLevel}`);
408
407
  } else {
@@ -595,10 +594,10 @@ export class Meter {
595
594
 
596
595
  async apiError(e: any): Promise<void> {
597
596
  if (!this.device.meter?.hide_humidity) {
598
- this.humidityservice?.updateCharacteristic(this.platform.Characteristic.CurrentRelativeHumidity, e);
597
+ this.humidityService?.updateCharacteristic(this.platform.Characteristic.CurrentRelativeHumidity, e);
599
598
  }
600
599
  if (!this.device.meter?.hide_temperature) {
601
- this.temperatureservice?.updateCharacteristic(this.platform.Characteristic.CurrentTemperature, e);
600
+ this.temperatureService?.updateCharacteristic(this.platform.Characteristic.CurrentTemperature, e);
602
601
  }
603
602
  this.batteryService?.updateCharacteristic(this.platform.Characteristic.BatteryLevel, e);
604
603
  this.batteryService?.updateCharacteristic(this.platform.Characteristic.StatusLowBattery, e);
@@ -93,12 +93,6 @@ export class Motion {
93
93
  (this.motionSensorService = accessory.getService(this.platform.Service.MotionSensor) || accessory.addService(this.platform.Service.MotionSensor)),
94
94
  `${accessory.displayName} Motion Sensor`;
95
95
 
96
- // To avoid "Cannot add a Service with the same UUID another Service without also defining a unique 'subtype' property." error,
97
- // when creating multiple services of the same type, you need to use the following syntax to specify a name and subtype id:
98
- // accessory.getService('NAME') ?? accessory.addService(this.platform.Service.Motion, 'NAME', 'USER_DEFINED_SUBTYPE');
99
-
100
- // set the service name, this is what is displayed as the default name on the Home app
101
- // in this example we are using the name we stored in the `accessory.context` in the `discoverDevices` method.
102
96
  this.motionSensorService.setCharacteristic(this.platform.Characteristic.Name, accessory.displayName);
103
97
  if (!this.motionSensorService.testCharacteristic(this.platform.Characteristic.ConfiguredName)) {
104
98
  this.motionSensorService.addCharacteristic(this.platform.Characteristic.ConfiguredName, accessory.displayName);
@@ -69,12 +69,6 @@ export class Plug {
69
69
  (this.outletService = accessory.getService(this.platform.Service.Outlet) || accessory.addService(this.platform.Service.Outlet)),
70
70
  `${device.deviceName} ${device.deviceType}`;
71
71
 
72
- // To avoid "Cannot add a Service with the same UUID another Service without also defining a unique 'subtype' property." error,
73
- // when creating multiple services of the same type, you need to use the following syntax to specify a name and subtype id:
74
- // accessory.getService('NAME') ?? accessory.addService(this.platform.Service.Outlet, 'NAME', 'USER_DEFINED_SUBTYPE');
75
-
76
- // set the service name, this is what is displayed as the default name on the Home app
77
- // in this example we are using the name we stored in the `accessory.context` in the `discoverDevices` method.
78
72
  this.outletService.setCharacteristic(this.platform.Characteristic.Name, accessory.displayName);
79
73
  if (!this.outletService.testCharacteristic(this.platform.Characteristic.ConfiguredName)) {
80
74
  this.outletService.addCharacteristic(this.platform.Characteristic.ConfiguredName, accessory.displayName);