@switchbot/homebridge-switchbot 4.3.8 → 4.3.10
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.
- package/CHANGELOG.md +1334 -0
- package/README.md +4 -1
- package/config.schema.json +273 -12
- package/dist/device/airpurifier.d.ts +45 -0
- package/dist/device/airpurifier.d.ts.map +1 -0
- package/dist/device/airpurifier.js +520 -0
- package/dist/device/airpurifier.js.map +1 -0
- package/dist/device/device.d.ts.map +1 -1
- package/dist/device/device.js +47 -0
- package/dist/device/device.js.map +1 -1
- package/dist/platform.d.ts +1 -0
- package/dist/platform.d.ts.map +1 -1
- package/dist/platform.js +67 -0
- package/dist/platform.js.map +1 -1
- package/dist/settings.d.ts +5 -2
- package/dist/settings.d.ts.map +1 -1
- package/dist/settings.js +1 -0
- package/dist/settings.js.map +1 -1
- package/docs/index.html +11 -2
- package/docs/variables/default.html +1 -1
- package/package.json +1 -1
- package/src/device/airpurifier.ts +561 -0
- package/src/device/device.ts +47 -0
- package/src/platform.ts +69 -0
- package/src/settings.ts +6 -2
package/src/platform.ts
CHANGED
|
@@ -26,6 +26,7 @@ import { CeilingLight } from './device/ceilinglight.js'
|
|
|
26
26
|
import { ColorBulb } from './device/colorbulb.js'
|
|
27
27
|
import { Contact } from './device/contact.js'
|
|
28
28
|
import { Curtain } from './device/curtain.js'
|
|
29
|
+
import { AirPurifier as AirPurifierDevice } from './device/airpurifier.js'
|
|
29
30
|
import { Fan } from './device/fan.js'
|
|
30
31
|
import { Hub } from './device/hub.js'
|
|
31
32
|
import { Humidifier } from './device/humidifier.js'
|
|
@@ -580,6 +581,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
580
581
|
'Humidifier': this.createHumidifier.bind(this),
|
|
581
582
|
'Humidifier2': this.createHumidifier.bind(this),
|
|
582
583
|
'Hub 2': this.createHub2.bind(this),
|
|
584
|
+
'Hub Mini 2': this.createHub2.bind(this),
|
|
583
585
|
'Hub 3': this.createHub2.bind(this),
|
|
584
586
|
'Bot': this.createBot.bind(this),
|
|
585
587
|
'Relay Switch 1': this.createRelaySwitch.bind(this),
|
|
@@ -618,6 +620,12 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
618
620
|
'Ceiling Light Pro': this.createCeilingLight.bind(this),
|
|
619
621
|
'Strip Light': this.createStripLight.bind(this),
|
|
620
622
|
'Battery Circulator Fan': this.createFan.bind(this),
|
|
623
|
+
'Air Purifier': this.createAirPurifierDevice.bind(this),
|
|
624
|
+
'Air Purifier Table': this.createAirPurifierDevice.bind(this),
|
|
625
|
+
'Air Purifier VOC': this.createAirPurifierDevice.bind(this),
|
|
626
|
+
'Air Purifier Table VOC': this.createAirPurifierDevice.bind(this),
|
|
627
|
+
'Air Purifier PM2.5': this.createAirPurifierDevice.bind(this),
|
|
628
|
+
'Air Purifier Table PM2.5': this.createAirPurifierDevice.bind(this),
|
|
621
629
|
}
|
|
622
630
|
|
|
623
631
|
if (deviceTypeHandlers[device.deviceType!]) {
|
|
@@ -1955,6 +1963,67 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
1955
1963
|
}
|
|
1956
1964
|
}
|
|
1957
1965
|
|
|
1966
|
+
private async createAirPurifierDevice(device: device & devicesConfig) {
|
|
1967
|
+
const uuid = this.api.hap.uuid.generate(`${device.deviceId}-${device.deviceType}`)
|
|
1968
|
+
|
|
1969
|
+
// see if an accessory with the same uuid has already been registered and restored from
|
|
1970
|
+
// the cached devices we stored in the `configureAccessory` method above
|
|
1971
|
+
const existingAccessory = this.accessories.find(accessory => accessory.UUID === uuid)
|
|
1972
|
+
|
|
1973
|
+
if (existingAccessory) {
|
|
1974
|
+
// the accessory already exists
|
|
1975
|
+
if (await this.registerDevice(device)) {
|
|
1976
|
+
// if you need to update the accessory.context then you should run `api.updatePlatformAccessories`. eg.:
|
|
1977
|
+
existingAccessory.context.device = device
|
|
1978
|
+
existingAccessory.context.deviceId = device.deviceId
|
|
1979
|
+
existingAccessory.context.deviceType = device.deviceType
|
|
1980
|
+
existingAccessory.context.model = device.deviceType?.includes('Table') ? SwitchBotModel.AirPurifierTable : SwitchBotModel.AirPurifier
|
|
1981
|
+
existingAccessory.displayName = device.configDeviceName
|
|
1982
|
+
? await this.validateAndCleanDisplayName(device.configDeviceName, 'configDeviceName', device.configDeviceName)
|
|
1983
|
+
: await this.validateAndCleanDisplayName(device.deviceName, 'deviceName', device.deviceName)
|
|
1984
|
+
existingAccessory.context.connectionType = await this.connectionType(device)
|
|
1985
|
+
existingAccessory.context.version = device.firmware ?? device.version ?? this.version ?? '0.0.0'
|
|
1986
|
+
this.infoLog(`Restoring existing accessory from cache: ${existingAccessory.displayName} deviceId: ${device.deviceId}`)
|
|
1987
|
+
this.api.updatePlatformAccessories([existingAccessory])
|
|
1988
|
+
// create the accessory handler for the restored accessory
|
|
1989
|
+
// this is imported from `platformAccessory.ts`
|
|
1990
|
+
new AirPurifierDevice(this, existingAccessory, device)
|
|
1991
|
+
this.debugLog(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${existingAccessory.UUID})`)
|
|
1992
|
+
} else {
|
|
1993
|
+
this.unregisterPlatformAccessories(existingAccessory)
|
|
1994
|
+
}
|
|
1995
|
+
} else if (await this.registerDevice(device)) {
|
|
1996
|
+
// create a new accessory
|
|
1997
|
+
const accessory = new this.api.platformAccessory(device.configDeviceName
|
|
1998
|
+
? await this.validateAndCleanDisplayName(device.configDeviceName, 'configDeviceName', device.configDeviceName)
|
|
1999
|
+
: await this.validateAndCleanDisplayName(device.deviceName, 'deviceName', device.deviceName), uuid)
|
|
2000
|
+
|
|
2001
|
+
// store a copy of the device object in the `accessory.context`
|
|
2002
|
+
// the `context` property can be used to store any data about the accessory you may need
|
|
2003
|
+
accessory.context.device = device
|
|
2004
|
+
accessory.context.deviceId = device.deviceId
|
|
2005
|
+
accessory.context.deviceType = device.deviceType
|
|
2006
|
+
accessory.context.model = device.deviceType?.includes('Table') ? SwitchBotModel.AirPurifierTable : SwitchBotModel.AirPurifier
|
|
2007
|
+
accessory.displayName = device.configDeviceName
|
|
2008
|
+
? await this.validateAndCleanDisplayName(device.configDeviceName, 'configDeviceName', device.configDeviceName)
|
|
2009
|
+
: await this.validateAndCleanDisplayName(device.deviceName, 'deviceName', device.deviceName)
|
|
2010
|
+
accessory.context.connectionType = await this.connectionType(device)
|
|
2011
|
+
accessory.context.version = device.firmware ?? device.version ?? this.version ?? '0.0.0'
|
|
2012
|
+
const newOrExternal = !device.external ? 'Adding new' : 'Loading external'
|
|
2013
|
+
this.infoLog(`${newOrExternal} accessory: ${accessory.displayName} deviceId: ${device.deviceId}`)
|
|
2014
|
+
// create the accessory handler for the newly create accessory
|
|
2015
|
+
// this is imported from `platformAccessory.ts`
|
|
2016
|
+
new AirPurifierDevice(this, accessory, device)
|
|
2017
|
+
this.debugLog(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${accessory.UUID})`)
|
|
2018
|
+
|
|
2019
|
+
// publish device externally or link the accessory to your platform
|
|
2020
|
+
this.externalOrPlatform(device, accessory)
|
|
2021
|
+
this.accessories.push(accessory)
|
|
2022
|
+
} else {
|
|
2023
|
+
this.debugLog(`Device not registered: ${device.deviceName} ${device.deviceType} deviceId: ${device.deviceId}`)
|
|
2024
|
+
}
|
|
2025
|
+
}
|
|
2026
|
+
|
|
1958
2027
|
private async createRobotVacuumCleaner(device: device & devicesConfig) {
|
|
1959
2028
|
const uuid = this.api.hap.uuid.generate(`${device.deviceId}-${device.deviceType}`)
|
|
1960
2029
|
|
package/src/settings.ts
CHANGED
|
@@ -53,7 +53,7 @@ export interface options {
|
|
|
53
53
|
logging?: string
|
|
54
54
|
};
|
|
55
55
|
|
|
56
|
-
export type devicesConfig = botConfig | relaySwitch1Config | relaySwitch1PMConfig | meterConfig | meterProConfig | indoorOutdoorSensorConfig | humidifierConfig | curtainConfig | blindTiltConfig | contactConfig | motionConfig | waterDetectorConfig | plugConfig | colorBulbConfig | stripLightConfig | ceilingLightConfig | lockConfig | hubConfig
|
|
56
|
+
export type devicesConfig = botConfig | relaySwitch1Config | relaySwitch1PMConfig | meterConfig | meterProConfig | indoorOutdoorSensorConfig | humidifierConfig | curtainConfig | blindTiltConfig | contactConfig | motionConfig | waterDetectorConfig | plugConfig | colorBulbConfig | stripLightConfig | ceilingLightConfig | lockConfig | hubConfig | airPurifierConfig
|
|
57
57
|
|
|
58
58
|
export interface BaseDeviceConfig extends device {
|
|
59
59
|
bleMac?: string
|
|
@@ -224,7 +224,7 @@ export interface lockConfig extends BaseDeviceConfig {
|
|
|
224
224
|
};
|
|
225
225
|
|
|
226
226
|
export interface hubConfig extends BaseDeviceConfig {
|
|
227
|
-
configDeviceType: 'Hub 2' | 'Hub 3'
|
|
227
|
+
configDeviceType: 'Hub 2' | 'Hub Mini 2' | 'Hub 3'
|
|
228
228
|
hide_temperature?: boolean
|
|
229
229
|
convertUnitTo?: string
|
|
230
230
|
hide_humidity?: boolean
|
|
@@ -233,6 +233,10 @@ export interface hubConfig extends BaseDeviceConfig {
|
|
|
233
233
|
set_maxLux?: number
|
|
234
234
|
};
|
|
235
235
|
|
|
236
|
+
export interface airPurifierConfig extends BaseDeviceConfig {
|
|
237
|
+
configDeviceType: 'Air Purifier' | 'Air Purifier Table' | 'Air Purifier VOC' | 'Air Purifier Table VOC' | 'Air Purifier PM2.5' | 'Air Purifier Table PM2.5'
|
|
238
|
+
};
|
|
239
|
+
|
|
236
240
|
export type irDevicesConfig = irFanConfig | irLightConfig | irAirConfig | irOtherConfig
|
|
237
241
|
|
|
238
242
|
export interface irBaseDeviceConfig extends irdevice {
|