@switchbot/homebridge-switchbot 4.1.3 → 4.1.4-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (80) hide show
  1. package/.github/npm-version-script.cjs +81 -0
  2. package/.github/workflows/beta-release.yml +3 -1
  3. package/.github/workflows/release.yml +3 -3
  4. package/config.schema.json +59 -59
  5. package/dist/device/blindtilt.js +2 -2
  6. package/dist/device/blindtilt.js.map +1 -1
  7. package/dist/device/bot.js +3 -3
  8. package/dist/device/bot.js.map +1 -1
  9. package/dist/device/ceilinglight.js +1 -1
  10. package/dist/device/ceilinglight.js.map +1 -1
  11. package/dist/device/colorbulb.js +4 -4
  12. package/dist/device/colorbulb.js.map +1 -1
  13. package/dist/device/contact.js +1 -1
  14. package/dist/device/contact.js.map +1 -1
  15. package/dist/device/curtain.js +4 -4
  16. package/dist/device/curtain.js.map +1 -1
  17. package/dist/device/device.js +5 -5
  18. package/dist/device/device.js.map +1 -1
  19. package/dist/device/fan.js +1 -1
  20. package/dist/device/fan.js.map +1 -1
  21. package/dist/device/humidifier.js +1 -1
  22. package/dist/device/humidifier.js.map +1 -1
  23. package/dist/device/iosensor.js +1 -1
  24. package/dist/device/iosensor.js.map +1 -1
  25. package/dist/device/lightstrip.js +3 -3
  26. package/dist/device/lightstrip.js.map +1 -1
  27. package/dist/device/lock.js +2 -2
  28. package/dist/device/lock.js.map +1 -1
  29. package/dist/device/meter.js +1 -1
  30. package/dist/device/meter.js.map +1 -1
  31. package/dist/device/meterplus.js +1 -1
  32. package/dist/device/meterplus.js.map +1 -1
  33. package/dist/device/meterpro.d.ts +5 -4
  34. package/dist/device/meterpro.d.ts.map +1 -1
  35. package/dist/device/meterpro.js +80 -12
  36. package/dist/device/meterpro.js.map +1 -1
  37. package/dist/device/motion.js +1 -1
  38. package/dist/device/motion.js.map +1 -1
  39. package/dist/device/plug.js +1 -1
  40. package/dist/device/plug.js.map +1 -1
  41. package/dist/device/robotvacuumcleaner.js +2 -2
  42. package/dist/device/robotvacuumcleaner.js.map +1 -1
  43. package/dist/device/waterdetector.js +1 -1
  44. package/dist/device/waterdetector.js.map +1 -1
  45. package/dist/irdevice/airconditioner.js +3 -3
  46. package/dist/irdevice/airconditioner.js.map +1 -1
  47. package/dist/irdevice/airpurifier.js +2 -2
  48. package/dist/irdevice/airpurifier.js.map +1 -1
  49. package/dist/platform.d.ts.map +1 -1
  50. package/dist/platform.js +1 -0
  51. package/dist/platform.js.map +1 -1
  52. package/dist/settings.d.ts +9 -2
  53. package/dist/settings.d.ts.map +1 -1
  54. package/dist/settings.js +1 -0
  55. package/dist/settings.js.map +1 -1
  56. package/package.json +5 -5
  57. package/src/device/blindtilt.ts +2 -2
  58. package/src/device/bot.ts +3 -3
  59. package/src/device/ceilinglight.ts +1 -1
  60. package/src/device/colorbulb.ts +4 -4
  61. package/src/device/contact.ts +1 -1
  62. package/src/device/curtain.ts +4 -4
  63. package/src/device/device.ts +5 -5
  64. package/src/device/fan.ts +1 -1
  65. package/src/device/humidifier.ts +1 -1
  66. package/src/device/iosensor.ts +1 -1
  67. package/src/device/lightstrip.ts +3 -3
  68. package/src/device/lock.ts +2 -2
  69. package/src/device/meter.ts +1 -1
  70. package/src/device/meterplus.ts +1 -1
  71. package/src/device/meterpro.ts +109 -33
  72. package/src/device/motion.ts +1 -1
  73. package/src/device/plug.ts +1 -1
  74. package/src/device/robotvacuumcleaner.ts +2 -2
  75. package/src/device/waterdetector.ts +1 -1
  76. package/src/irdevice/airconditioner.ts +3 -3
  77. package/src/irdevice/airpurifier.ts +2 -2
  78. package/src/platform.ts +1 -0
  79. package/src/settings.ts +10 -2
  80. package/.github/workflows/dependabot.yml +0 -13
@@ -3,10 +3,10 @@
3
3
  * MeterPro.ts: @switchbot/homebridge-switchbot.
4
4
  */
5
5
  import type { CharacteristicValue, PlatformAccessory, Service } from 'homebridge'
6
- import type { device, meterProServiceData, meterProStatus, meterProWebhookContext } from 'node-switchbot'
6
+ import type { device, meterProCO2ServiceData, meterProCO2Status, meterProCO2WebhookContext, meterProServiceData, meterProStatus, meterProWebhookContext } from 'node-switchbot'
7
7
 
8
8
  import type { SwitchBotPlatform } from '../platform.js'
9
- import type { devicesConfig, meterConfig } from '../settings.js'
9
+ import type { devicesConfig, meterProConfig } from '../settings.js'
10
10
 
11
11
  import { Units } from 'homebridge'
12
12
  /*
@@ -45,14 +45,21 @@ export class MeterPro extends deviceBase {
45
45
  CurrentTemperature: CharacteristicValue
46
46
  }
47
47
 
48
+ private CarbonDioxideSensor?: {
49
+ Name: CharacteristicValue
50
+ Service: Service
51
+ CarbonDioxideDetected: CharacteristicValue
52
+ CarbonDioxideLevel: CharacteristicValue
53
+ }
54
+
48
55
  // OpenAPI
49
- deviceStatus!: meterProStatus
56
+ deviceStatus!: meterProStatus | meterProCO2Status
50
57
 
51
58
  // Webhook
52
- webhookContext!: meterProWebhookContext
59
+ webhookContext!: meterProWebhookContext | meterProCO2WebhookContext
53
60
 
54
61
  // BLE
55
- serviceData!: meterProServiceData
62
+ serviceData!: meterProServiceData | meterProCO2ServiceData
56
63
 
57
64
  // Updates
58
65
  meterUpdateInProgress!: boolean
@@ -91,7 +98,7 @@ export class MeterPro extends deviceBase {
91
98
  })
92
99
 
93
100
  // Initialize Temperature Sensor Service
94
- if ((device as meterConfig).hide_temperature) {
101
+ if ((device as meterProConfig).hide_temperature) {
95
102
  if (this.TemperatureSensor) {
96
103
  this.debugLog('Removing Temperature Sensor Service')
97
104
  this.TemperatureSensor.Service = this.accessory.getService(this.hap.Service.TemperatureSensor) as Service
@@ -118,7 +125,7 @@ export class MeterPro extends deviceBase {
118
125
  })
119
126
  }
120
127
  // Initialize Humidity Sensor Service
121
- if ((device as meterConfig).hide_humidity) {
128
+ if ((device as meterProConfig).hide_humidity) {
122
129
  if (this.HumiditySensor) {
123
130
  this.debugLog('Removing Humidity Sensor Service')
124
131
  this.HumiditySensor.Service = this.accessory.getService(this.hap.Service.HumiditySensor) as Service
@@ -141,6 +148,40 @@ export class MeterPro extends deviceBase {
141
148
  })
142
149
  }
143
150
 
151
+ // Initialize Carbon Dioxide Sensor Service
152
+ if ((device as meterProConfig).hide_co2) {
153
+ if (this.CarbonDioxideSensor) {
154
+ this.debugLog('Removing Carbon Dioxide Sensor Service')
155
+ this.CarbonDioxideSensor.Service = this.accessory.getService(this.hap.Service.CarbonDioxideSensor) as Service
156
+ accessory.removeService(this.CarbonDioxideSensor.Service)
157
+ }
158
+ } else if (this.device.deviceType === 'MeterPro(CO2)') {
159
+ accessory.context.CarbonDioxideSensor = accessory.context.CarbonDioxideSensor ?? {}
160
+ this.CarbonDioxideSensor = {
161
+ Name: `${accessory.displayName} Carbon Dioxide Sensor`,
162
+ Service: accessory.getService(this.hap.Service.CarbonDioxideSensor) ?? this.accessory.addService(this.hap.Service.CarbonDioxideSensor) as Service,
163
+ CarbonDioxideDetected: accessory.context.CarbonDioxideDetected ?? this.hap.Characteristic.CarbonDioxideDetected.CO2_LEVELS_NORMAL,
164
+ CarbonDioxideLevel: accessory.context.CarbonDioxideLevel ?? 0,
165
+ }
166
+ accessory.context.CarbonDioxideSensor = this.CarbonDioxideSensor as object
167
+
168
+ // Initialize Carbon Dioxide Sensor Characteristics
169
+ this.CarbonDioxideSensor.Service.setCharacteristic(this.hap.Characteristic.Name, this.CarbonDioxideSensor.Name).getCharacteristic(this.hap.Characteristic.CarbonDioxideDetected).onGet(() => {
170
+ return this.CarbonDioxideSensor!.CarbonDioxideDetected!
171
+ })
172
+ this.CarbonDioxideSensor.Service.getCharacteristic(this.hap.Characteristic.CarbonDioxideLevel).setProps({
173
+ minStep: 1,
174
+ }).onGet(() => {
175
+ return this.CarbonDioxideSensor!.CarbonDioxideLevel!
176
+ })
177
+ } else {
178
+ if (this.CarbonDioxideSensor) {
179
+ this.debugLog('Removing Carbon Dioxide Sensor Service')
180
+ this.CarbonDioxideSensor.Service = this.accessory.getService(this.hap.Service.CarbonDioxideSensor) as Service
181
+ accessory.removeService(this.CarbonDioxideSensor.Service)
182
+ }
183
+ }
184
+
144
185
  // Retrieve initial values and updateHomekit
145
186
  try {
146
187
  this.debugLog('Retrieve initial values and update Homekit')
@@ -175,21 +216,31 @@ export class MeterPro extends deviceBase {
175
216
 
176
217
  async BLEparseStatus(): Promise<void> {
177
218
  this.debugLog('BLEparseStatus')
178
- this.debugLog(`(temperature, humidity) = BLE:(${this.serviceData.celsius}, ${this.serviceData.humidity}), current:(${this.TemperatureSensor?.CurrentTemperature}, ${this.HumiditySensor?.CurrentRelativeHumidity})`)
219
+ this.debugLog(`(temperature, humidity${this.device.deviceType === 'MeterPro(CO2)' ? ', co2' : ''}) = BLE:(${this.serviceData.celsius}, ${this.serviceData.humidity}${this.device.deviceType === 'MeterPro(CO2)' ? `, ${(this.serviceData as meterProCO2ServiceData).co2}` : ''}) current:(${this.TemperatureSensor?.CurrentTemperature}, ${this.HumiditySensor?.CurrentRelativeHumidity}${this.device.deviceType === 'MeterPro(CO2)' ? `, ${this.CarbonDioxideSensor?.CarbonDioxideLevel}` : ''})`)
179
220
 
180
221
  // CurrentRelativeHumidity
181
- if (!(this.device as meterConfig).hide_humidity && this.HumiditySensor?.Service) {
222
+ if (!(this.device as meterProConfig).hide_humidity && this.HumiditySensor?.Service) {
182
223
  this.HumiditySensor.CurrentRelativeHumidity = validHumidity(this.serviceData.humidity, 0, 100)
183
224
  this.debugLog(`CurrentRelativeHumidity: ${this.HumiditySensor.CurrentRelativeHumidity}%`)
184
225
  }
185
226
  // Current Temperature
186
- if (!(this.device as meterConfig).hide_temperature && this.TemperatureSensor?.Service) {
227
+ if (!(this.device as meterProConfig).hide_temperature && this.TemperatureSensor?.Service) {
187
228
  const CELSIUS = this.serviceData.celsius < 0 ? 0 : this.serviceData.celsius > 100 ? 100 : this.serviceData.celsius
188
229
  this.TemperatureSensor.CurrentTemperature = CELSIUS
189
230
  this.debugLog(`CurrentTemperature: ${this.TemperatureSensor.CurrentTemperature}°c`)
190
231
  }
232
+ // Carbon Dioxide Sensor
233
+ if (!(this.device as meterProConfig).hide_co2 && this.CarbonDioxideSensor?.Service && this.device.deviceType === 'MeterPro(CO2)') {
234
+ this.CarbonDioxideSensor.CarbonDioxideLevel = (this.serviceData as meterProCO2ServiceData).co2
235
+ this.debugLog(`CarbonDioxideLevel: ${this.CarbonDioxideSensor.CarbonDioxideLevel}ppm`)
236
+ this.CarbonDioxideSensor.CarbonDioxideDetected = this.CarbonDioxideSensor.CarbonDioxideLevel > 0
237
+ ? this.hap.Characteristic.CarbonDioxideDetected.CO2_LEVELS_ABNORMAL
238
+ : this.hap.Characteristic.CarbonDioxideDetected.CO2_LEVELS_NORMAL
239
+ this.debugLog(`CarbonDioxideDetected: ${this.CarbonDioxideSensor.CarbonDioxideDetected}`)
240
+ this.warnLog('Carbon Dioxide Sensor is not supported yet.')
241
+ }
191
242
  // Battery Info
192
- if (this.serviceData.battery) {
243
+ if ('battery' in this.serviceData) {
193
244
  // BatteryLevel
194
245
  this.Battery.BatteryLevel = this.serviceData.battery
195
246
  this.debugLog(`BatteryLevel: ${this.Battery.BatteryLevel}`)
@@ -203,29 +254,43 @@ export class MeterPro extends deviceBase {
203
254
 
204
255
  async openAPIparseStatus(): Promise<void> {
205
256
  this.debugLog('openAPIparseStatus')
206
- this.debugLog(`(temperature, humidity) = OpenAPI:(${this.deviceStatus.temperature}, ${this.deviceStatus.humidity}), current:(${this.TemperatureSensor?.CurrentTemperature}, ${this.HumiditySensor?.CurrentRelativeHumidity})`)
257
+ this.debugLog(`(temperature, humidity${this.device.deviceType === 'MeterPro(CO2)' ? ', co2' : ''}) = OpenAPI:(${this.deviceStatus.temperature}, ${this.deviceStatus.humidity}${this.device.deviceType === 'MeterPro(CO2)' ? `, ${(this.deviceStatus as meterProCO2Status).co2}` : ''}) current:(${this.TemperatureSensor?.CurrentTemperature}, ${this.HumiditySensor?.CurrentRelativeHumidity}${this.device.deviceType === 'MeterPro(CO2)' ? `, ${this.CarbonDioxideSensor?.CarbonDioxideLevel}` : ''})`)
207
258
 
208
259
  // CurrentRelativeHumidity
209
- if (!(this.device as meterConfig).hide_humidity && this.HumiditySensor?.Service) {
260
+ if (!(this.device as meterProConfig).hide_humidity && this.HumiditySensor?.Service) {
210
261
  this.HumiditySensor.CurrentRelativeHumidity = this.deviceStatus.humidity
211
262
  this.debugLog(`CurrentRelativeHumidity: ${this.HumiditySensor.CurrentRelativeHumidity}%`)
212
263
  }
213
264
 
214
265
  // CurrentTemperature
215
- if (!(this.device as meterConfig).hide_temperature && this.TemperatureSensor?.Service) {
266
+ if (!(this.device as meterProConfig).hide_temperature && this.TemperatureSensor?.Service) {
216
267
  this.TemperatureSensor.CurrentTemperature = this.deviceStatus.temperature
217
268
  this.debugLog(`CurrentTemperature: ${this.TemperatureSensor.CurrentTemperature}°c`)
218
269
  }
219
270
 
271
+ // Carbon Dioxide Sensor
272
+ if (!(this.device as meterProConfig).hide_co2 && this.CarbonDioxideSensor?.Service && this.device.deviceType === 'MeterPro(CO2)') {
273
+ this.CarbonDioxideSensor.CarbonDioxideLevel = (this.deviceStatus as meterProCO2Status).co2
274
+ this.debugLog(`CarbonDioxideLevel: ${this.CarbonDioxideSensor.CarbonDioxideLevel}ppm`)
275
+ this.CarbonDioxideSensor.CarbonDioxideDetected = this.CarbonDioxideSensor.CarbonDioxideLevel > 0
276
+ ? this.hap.Characteristic.CarbonDioxideDetected.CO2_LEVELS_ABNORMAL
277
+ : this.hap.Characteristic.CarbonDioxideDetected.CO2_LEVELS_NORMAL
278
+ this.debugLog(`CarbonDioxideDetected: ${this.CarbonDioxideSensor.CarbonDioxideDetected}`)
279
+ this.warnLog('Carbon Dioxide Sensor is not supported yet.')
280
+ }
281
+
282
+ // Battery Info
283
+ if ('battery' in this.serviceData) {
220
284
  // BatteryLevel
221
- this.Battery.BatteryLevel = this.deviceStatus.battery
222
- this.debugLog(`BatteryLevel: ${this.Battery.BatteryLevel}`)
285
+ this.Battery.BatteryLevel = this.deviceStatus.battery
286
+ this.debugLog(`BatteryLevel: ${this.Battery.BatteryLevel}`)
223
287
 
224
- // StatusLowBattery
225
- this.Battery.StatusLowBattery = this.Battery.BatteryLevel < 10
226
- ? this.hap.Characteristic.StatusLowBattery.BATTERY_LEVEL_LOW
227
- : this.hap.Characteristic.StatusLowBattery.BATTERY_LEVEL_NORMAL
228
- this.debugLog(`StatusLowBattery: ${this.Battery.StatusLowBattery}`)
288
+ // StatusLowBattery
289
+ this.Battery.StatusLowBattery = this.Battery.BatteryLevel < 10
290
+ ? this.hap.Characteristic.StatusLowBattery.BATTERY_LEVEL_LOW
291
+ : this.hap.Characteristic.StatusLowBattery.BATTERY_LEVEL_NORMAL
292
+ this.debugLog(`StatusLowBattery: ${this.Battery.StatusLowBattery}`)
293
+ }
229
294
 
230
295
  // FirmwareVersion
231
296
  if (this.deviceStatus.version) {
@@ -245,23 +310,34 @@ export class MeterPro extends deviceBase {
245
310
 
246
311
  async parseStatusWebhook(): Promise<void> {
247
312
  this.debugLog('parseStatusWebhook')
248
- this.debugLog(`(scale, temperature, humidity) = Webhook:(${this.webhookContext.scale}, ${convertUnits(this.webhookContext.temperature, this.webhookContext.scale, (this.device as meterConfig).convertUnitTo)}, ${this.webhookContext.humidity}) current:(${this.TemperatureSensor?.CurrentTemperature}, ${this.HumiditySensor?.CurrentRelativeHumidity})`)
313
+ this.debugLog(`(scale, temperature, humidity${this.device.deviceType === 'MeterPro(CO2)' ? ', co2' : ''}) = Webhook:(${this.webhookContext.scale}, ${convertUnits(this.webhookContext.temperature, this.webhookContext.scale, (this.device as meterProConfig).convertUnitTo)}, ${this.webhookContext.humidity}${this.device.deviceType === 'MeterPro(CO2)' ? `, ${(this.webhookContext as meterProCO2WebhookContext).co2}` : ''}) current:(${this.TemperatureSensor?.CurrentTemperature}, ${this.HumiditySensor?.CurrentRelativeHumidity}${this.device.deviceType === 'MeterPro(CO2)' ? `, ${this.CarbonDioxideSensor?.CarbonDioxideLevel}` : ''})`)
249
314
  // Check if the scale is not CELSIUS
250
- if (this.webhookContext.scale !== 'CELSIUS' && (this.device as meterConfig).convertUnitTo === undefined) {
315
+ if (this.webhookContext.scale !== 'CELSIUS' && (this.device as meterProConfig).convertUnitTo === undefined) {
251
316
  this.warnLog(`received a non-CELSIUS Webhook scale: ${this.webhookContext.scale}, Use the *convertUnitsTo* config under Hub settings, if displaying incorrectly in HomeKit.`)
252
317
  }
253
318
 
254
319
  // CurrentRelativeHumidity
255
- if (!(this.device as meterConfig).hide_humidity && this.HumiditySensor?.Service) {
320
+ if (!(this.device as meterProConfig).hide_humidity && this.HumiditySensor?.Service) {
256
321
  this.HumiditySensor.CurrentRelativeHumidity = this.webhookContext.humidity
257
322
  this.debugLog(`CurrentRelativeHumidity: ${this.HumiditySensor.CurrentRelativeHumidity}`)
258
323
  }
259
324
 
260
325
  // CurrentTemperature
261
- if (!(this.device as meterConfig).hide_temperature && this.TemperatureSensor?.Service) {
262
- this.TemperatureSensor.CurrentTemperature = convertUnits(this.webhookContext.temperature, this.webhookContext.scale, (this.device as meterConfig).convertUnitTo)
326
+ if (!(this.device as meterProConfig).hide_temperature && this.TemperatureSensor?.Service) {
327
+ this.TemperatureSensor.CurrentTemperature = convertUnits(this.webhookContext.temperature, this.webhookContext.scale, (this.device as meterProConfig).convertUnitTo)
263
328
  this.debugLog(`CurrentTemperature: ${this.TemperatureSensor.CurrentTemperature}`)
264
329
  }
330
+
331
+ // Carbon Dioxide Sensor
332
+ if (!(this.device as meterProConfig).hide_co2 && this.CarbonDioxideSensor?.Service && this.device.deviceType === 'MeterPro(CO2)') {
333
+ this.CarbonDioxideSensor.CarbonDioxideLevel = (this.webhookContext as meterProCO2WebhookContext).co2
334
+ this.debugLog(`CarbonDioxideLevel: ${this.CarbonDioxideSensor.CarbonDioxideLevel}ppm`)
335
+ this.CarbonDioxideSensor.CarbonDioxideDetected = this.CarbonDioxideSensor.CarbonDioxideLevel > 0
336
+ ? this.hap.Characteristic.CarbonDioxideDetected.CO2_LEVELS_ABNORMAL
337
+ : this.hap.Characteristic.CarbonDioxideDetected.CO2_LEVELS_NORMAL
338
+ this.debugLog(`CarbonDioxideDetected: ${this.CarbonDioxideSensor.CarbonDioxideDetected}`)
339
+ this.warnLog('Carbon Dioxide Sensor is not supported yet.')
340
+ }
265
341
  }
266
342
 
267
343
  /**
@@ -289,7 +365,7 @@ export class MeterPro extends deviceBase {
289
365
  // Start to monitor advertisement packets
290
366
  (async () => {
291
367
  // Start to monitor advertisement packets
292
- const serviceData = await this.monitorAdvertisementPackets(switchBotBLE) as meterProServiceData
368
+ const serviceData = await this.monitorAdvertisementPackets(switchBotBLE) as meterProServiceData | meterProCO2ServiceData
293
369
  // Update HomeKit
294
370
  if (serviceData.model === SwitchBotBLEModel.MeterPro && serviceData.modelName === SwitchBotBLEModelName.MeterPro) {
295
371
  this.serviceData = serviceData
@@ -373,11 +449,11 @@ export class MeterPro extends deviceBase {
373
449
  */
374
450
  async updateHomeKitCharacteristics(): Promise<void> {
375
451
  // CurrentRelativeHumidity
376
- if (!(this.device as meterConfig).hide_humidity && this.HumiditySensor?.Service) {
452
+ if (!(this.device as meterProConfig).hide_humidity && this.HumiditySensor?.Service) {
377
453
  await this.updateCharacteristic(this.HumiditySensor.Service, this.hap.Characteristic.CurrentRelativeHumidity, this.HumiditySensor.CurrentRelativeHumidity, 'CurrentRelativeHumidity')
378
454
  }
379
455
  // CurrentTemperature
380
- if (!(this.device as meterConfig).hide_temperature && this.TemperatureSensor?.Service) {
456
+ if (!(this.device as meterProConfig).hide_temperature && this.TemperatureSensor?.Service) {
381
457
  await this.updateCharacteristic(this.TemperatureSensor.Service, this.hap.Characteristic.CurrentTemperature, this.TemperatureSensor.CurrentTemperature, 'CurrentTemperature')
382
458
  }
383
459
  // BatteryLevel
@@ -396,10 +472,10 @@ export class MeterPro extends deviceBase {
396
472
 
397
473
  async offlineOff(): Promise<void> {
398
474
  if (this.device.offline) {
399
- if (!(this.device as meterConfig).hide_humidity && this.HumiditySensor?.Service) {
475
+ if (!(this.device as meterProConfig).hide_humidity && this.HumiditySensor?.Service) {
400
476
  this.HumiditySensor.Service.updateCharacteristic(this.hap.Characteristic.CurrentRelativeHumidity, 50)
401
477
  }
402
- if (!(this.device as meterConfig).hide_temperature && this.TemperatureSensor?.Service) {
478
+ if (!(this.device as meterProConfig).hide_temperature && this.TemperatureSensor?.Service) {
403
479
  this.TemperatureSensor.Service.updateCharacteristic(this.hap.Characteristic.CurrentTemperature, 30)
404
480
  }
405
481
  this.Battery.Service.updateCharacteristic(this.hap.Characteristic.BatteryLevel, 100)
@@ -408,10 +484,10 @@ export class MeterPro extends deviceBase {
408
484
  }
409
485
 
410
486
  async apiError(e: any): Promise<void> {
411
- if (!(this.device as meterConfig).hide_humidity && this.HumiditySensor?.Service) {
487
+ if (!(this.device as meterProConfig).hide_humidity && this.HumiditySensor?.Service) {
412
488
  this.HumiditySensor.Service.updateCharacteristic(this.hap.Characteristic.CurrentRelativeHumidity, e)
413
489
  }
414
- if (!(this.device as meterConfig).hide_temperature && this.TemperatureSensor?.Service) {
490
+ if (!(this.device as meterProConfig).hide_temperature && this.TemperatureSensor?.Service) {
415
491
  this.TemperatureSensor.Service.updateCharacteristic(this.hap.Characteristic.CurrentTemperature, e)
416
492
  }
417
493
  this.Battery.Service.updateCharacteristic(this.hap.Characteristic.BatteryLevel, e)
@@ -172,7 +172,7 @@ export class Motion extends deviceBase {
172
172
  this.debugLog(`LightLevel: ${this.serviceData.lightLevel}, CurrentAmbientLightLevel: ${this.LightSensor.CurrentAmbientLightLevel}`)
173
173
  }
174
174
  // Battery Info
175
- if (this.serviceData.battery) {
175
+ if ('battery' in this.serviceData) {
176
176
  // BatteryLevel
177
177
  this.Battery.BatteryLevel = this.serviceData.battery
178
178
  this.debugLog(`BatteryLevel: ${this.Battery.BatteryLevel}`)
@@ -321,7 +321,7 @@ export class Plug extends deviceBase {
321
321
  })
322
322
  })
323
323
  .then(async () => {
324
- this.successLog(`On: ${this.Outlet.On} sent over SwitchBot BLE, sent successfully`)
324
+ this.successLog(`On: ${this.Outlet.On} sent over SwitchBot BLE, sent successfully`)
325
325
  await this.updateHomeKitCharacteristics()
326
326
  })
327
327
  .catch(async (e: any) => {
@@ -171,7 +171,7 @@ export class RobotVacuumCleaner extends deviceBase {
171
171
  this.debugLog(`On: ${this.LightBulb.On}`)
172
172
 
173
173
  // Battery Info
174
- if (this.serviceData.battery) {
174
+ if ('battery' in this.serviceData) {
175
175
  // BatteryLevel
176
176
  this.Battery.BatteryLevel = this.serviceData.battery
177
177
  this.debugLog(`BatteryLevel: ${this.Battery.BatteryLevel}`)
@@ -406,7 +406,7 @@ export class RobotVacuumCleaner extends deviceBase {
406
406
  })
407
407
  })
408
408
  .then(async () => {
409
- this.successLog(`On: ${this.LightBulb.On} sent over SwitchBot BLE, sent successfully`)
409
+ this.successLog(`On: ${this.LightBulb.On} sent over SwitchBot BLE, sent successfully`)
410
410
  await this.updateHomeKitCharacteristics()
411
411
  })
412
412
  .catch(async (e: any) => {
@@ -159,7 +159,7 @@ export class WaterDetector extends deviceBase {
159
159
  this.debugLog(`LeakDetected: ${this.LeakSensor.LeakDetected}`)
160
160
  }
161
161
  // Battery Info
162
- if (this.serviceData.battery) {
162
+ if ('battery' in this.serviceData) {
163
163
  // BatteryLevel
164
164
  this.Battery.BatteryLevel = this.serviceData.battery
165
165
  this.debugLog(`BatteryLevel: ${this.Battery.BatteryLevel}`)
@@ -186,7 +186,7 @@ export class AirConditioner extends irdeviceBase {
186
186
  }
187
187
 
188
188
  async pushAirConditionerStatusChanges(): Promise<void> {
189
- this.debugLog(`pushAirConditionerStatusChanges Active: ${this.HeaterCooler.Active}, disablePushOff: ${this.disablePushOff}, disablePushOn: ${this.disablePushOn}`)
189
+ this.debugLog(`pushAirConditionerStatusChanges Active: ${this.HeaterCooler.Active}, disablePushOff: ${this.disablePushOff}, disablePushOn: ${this.disablePushOn}`)
190
190
  if (!this.Busy) {
191
191
  this.Busy = true
192
192
  this.HeaterCooler.CurrentHeaterCoolerState = this.hap.Characteristic.CurrentHeaterCoolerState.IDLE
@@ -198,7 +198,7 @@ export class AirConditioner extends irdeviceBase {
198
198
  }
199
199
 
200
200
  async pushAirConditionerDetailsChanges(): Promise<void> {
201
- this.debugLog(`pushAirConditionerDetailsChanges Active: ${this.HeaterCooler.Active}, disablePushOff: ${this.disablePushOff}, disablePushOn: ${this.disablePushOn}`)
201
+ this.debugLog(`pushAirConditionerDetailsChanges Active: ${this.HeaterCooler.Active}, disablePushOff: ${this.disablePushOff}, disablePushOn: ${this.disablePushOn}`)
202
202
  // await this.deviceContext();
203
203
  if (this.CurrentMode === undefined) {
204
204
  this.CurrentMode = 1
@@ -399,7 +399,7 @@ export class AirConditioner extends irdeviceBase {
399
399
  async TargetHeaterCoolerStateGet(): Promise<CharacteristicValue> {
400
400
  const targetState = this.HeaterCooler.TargetHeaterCoolerState || this.accessory.context.TargetHeaterCoolerState
401
401
  this.HeaterCooler.TargetHeaterCoolerState = this.ValidValues.includes(targetState) ? targetState : this.ValidValues[0]
402
- this.debugLog(`Get (${this.getTargetHeaterCoolerStateName()}) TargetHeaterCoolerState: ${this.HeaterCooler.TargetHeaterCoolerState}, ValidValues: ${this.ValidValues}, hide_automode: ${this.hide_automode}`)
402
+ this.debugLog(`Get (${this.getTargetHeaterCoolerStateName()}) TargetHeaterCoolerState: ${this.HeaterCooler.TargetHeaterCoolerState}, ValidValues: ${this.ValidValues}, hide_automode: ${this.hide_automode}`)
403
403
  return this.HeaterCooler.TargetHeaterCoolerState
404
404
  }
405
405
 
@@ -173,7 +173,7 @@ export class AirPurifier extends irdeviceBase {
173
173
  }
174
174
 
175
175
  async pushAirPurifierStatusChanges(): Promise<void> {
176
- this.debugLog(`pushAirPurifierStatusChanges Active: ${this.AirPurifier.Active}, disablePushOff: ${this.disablePushOff}, disablePushOn: ${this.disablePushOn}`)
176
+ this.debugLog(`pushAirPurifierStatusChanges Active: ${this.AirPurifier.Active}, disablePushOff: ${this.disablePushOff}, disablePushOn: ${this.disablePushOn}`)
177
177
  if (!this.Busy) {
178
178
  this.Busy = true
179
179
  this.AirPurifier.CurrentHeaterCoolerState = this.hap.Characteristic.CurrentHeaterCoolerState.IDLE
@@ -185,7 +185,7 @@ export class AirPurifier extends irdeviceBase {
185
185
  }
186
186
 
187
187
  async pushAirPurifierDetailsChanges(): Promise<void> {
188
- this.debugLog(`pushAirPurifierDetailsChanges Active: ${this.AirPurifier.Active}, disablePushOff: ${this.disablePushOff}, disablePushOn: ${this.disablePushOn}`)
188
+ this.debugLog(`pushAirPurifierDetailsChanges Active: ${this.AirPurifier.Active}, disablePushOff: ${this.disablePushOff}, disablePushOn: ${this.disablePushOn}`)
189
189
  this.CurrentAPTemp = this.TemperatureSensor!.CurrentTemperature ?? 24
190
190
  this.CurrentAPMode = this.CurrentMode ?? 1
191
191
  this.CurrentAPFanSpeed = this.CurrentFanSpeed ?? 1
package/src/platform.ts CHANGED
@@ -589,6 +589,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
589
589
  'MeterPlus': this.createMeterPlus.bind(this),
590
590
  'Meter Plus (JP)': this.createMeterPlus.bind(this),
591
591
  'Meter Pro': this.createMeterPro.bind(this),
592
+ 'MeterPro(CO2)': this.createMeterPro.bind(this),
592
593
  'WoIOSensor': this.createIOSensor.bind(this),
593
594
  'Water Detector': this.createWaterDetector.bind(this),
594
595
  'Motion Sensor': this.createMotion.bind(this),
package/src/settings.ts CHANGED
@@ -52,7 +52,7 @@ export interface options {
52
52
  logging?: string
53
53
  };
54
54
 
55
- export type devicesConfig = botConfig | meterConfig | indoorOutdoorSensorConfig | humidifierConfig | curtainConfig | blindTiltConfig | contactConfig | motionConfig | waterDetectorConfig | plugConfig | colorBulbConfig | stripLightConfig | ceilingLightConfig | lockConfig | hubConfig
55
+ export type devicesConfig = botConfig | meterConfig | meterProConfig | indoorOutdoorSensorConfig | humidifierConfig | curtainConfig | blindTiltConfig | contactConfig | motionConfig | waterDetectorConfig | plugConfig | colorBulbConfig | stripLightConfig | ceilingLightConfig | lockConfig | hubConfig
56
56
 
57
57
  export interface BaseDeviceConfig extends device {
58
58
  bleMac?: string
@@ -96,12 +96,20 @@ export interface botConfig extends BaseDeviceConfig {
96
96
  };
97
97
 
98
98
  export interface meterConfig extends BaseDeviceConfig {
99
- configDeviceType: 'Meter' | 'MeterPlus' | 'Meter Pro' | 'Meter Pro CO2'
99
+ configDeviceType: 'Meter' | 'MeterPlus'
100
100
  hide_temperature?: boolean
101
101
  convertUnitTo?: string
102
102
  hide_humidity?: boolean
103
103
  };
104
104
 
105
+ export interface meterProConfig extends BaseDeviceConfig {
106
+ configDeviceType: 'Meter Pro' | 'MeterPro(CO2)'
107
+ hide_temperature?: boolean
108
+ convertUnitTo?: string
109
+ hide_humidity?: boolean
110
+ hide_co2?: boolean
111
+ };
112
+
105
113
  export interface indoorOutdoorSensorConfig extends BaseDeviceConfig {
106
114
  configDeviceType: 'WoIOSensor'
107
115
  hide_temperature?: boolean
@@ -1,13 +0,0 @@
1
- name: AutoDependabot
2
-
3
- on:
4
- pull_request:
5
- branches: [ beta, latest ]
6
- pull_request_target:
7
- branches: [ beta, latest ]
8
-
9
- jobs:
10
- dependabot:
11
- uses: OpenWonderLabs/.github/.github/workflows/dependabot.yml@latest
12
- secrets:
13
- token: ${{ secrets.GITHUB_TOKEN }}