@switchbot/homebridge-switchbot 4.3.2-beta.2 → 4.3.2-beta.4
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/dist/device/airpurifier.d.ts +54 -0
- package/dist/device/airpurifier.d.ts.map +1 -0
- package/dist/device/airpurifier.js +527 -0
- package/dist/device/airpurifier.js.map +1 -0
- package/dist/device/blindtilt.d.ts.map +1 -1
- package/dist/device/blindtilt.js +2 -8
- package/dist/device/blindtilt.js.map +1 -1
- package/dist/device/bot.d.ts.map +1 -1
- package/dist/device/bot.js +2 -8
- package/dist/device/bot.js.map +1 -1
- package/dist/device/ceilinglight.d.ts.map +1 -1
- package/dist/device/ceilinglight.js +2 -8
- package/dist/device/ceilinglight.js.map +1 -1
- package/dist/device/colorbulb.d.ts.map +1 -1
- package/dist/device/colorbulb.js +2 -8
- package/dist/device/colorbulb.js.map +1 -1
- package/dist/device/contact.d.ts.map +1 -1
- package/dist/device/contact.js +1 -4
- package/dist/device/contact.js.map +1 -1
- package/dist/device/curtain.d.ts.map +1 -1
- package/dist/device/curtain.js +2 -8
- package/dist/device/curtain.js.map +1 -1
- package/dist/device/fan.d.ts.map +1 -1
- package/dist/device/fan.js +2 -8
- package/dist/device/fan.js.map +1 -1
- package/dist/device/hub.d.ts.map +1 -1
- package/dist/device/hub.js +1 -4
- package/dist/device/hub.js.map +1 -1
- package/dist/device/humidifier.d.ts.map +1 -1
- package/dist/device/humidifier.js +2 -8
- package/dist/device/humidifier.js.map +1 -1
- package/dist/device/iosensor.d.ts.map +1 -1
- package/dist/device/iosensor.js +1 -4
- package/dist/device/iosensor.js.map +1 -1
- package/dist/device/lightstrip.d.ts.map +1 -1
- package/dist/device/lightstrip.js +2 -8
- package/dist/device/lightstrip.js.map +1 -1
- package/dist/device/lock.d.ts.map +1 -1
- package/dist/device/lock.js +2 -8
- package/dist/device/lock.js.map +1 -1
- package/dist/device/meter.d.ts.map +1 -1
- package/dist/device/meter.js +1 -4
- package/dist/device/meter.js.map +1 -1
- package/dist/device/meterplus.d.ts.map +1 -1
- package/dist/device/meterplus.js +1 -4
- package/dist/device/meterplus.js.map +1 -1
- package/dist/device/meterpro.d.ts.map +1 -1
- package/dist/device/meterpro.js +3 -5
- package/dist/device/meterpro.js.map +1 -1
- package/dist/device/motion.d.ts.map +1 -1
- package/dist/device/motion.js +1 -4
- package/dist/device/motion.js.map +1 -1
- package/dist/device/plug.d.ts.map +1 -1
- package/dist/device/plug.js +2 -8
- package/dist/device/plug.js.map +1 -1
- package/dist/device/relayswitch.d.ts.map +1 -1
- package/dist/device/relayswitch.js +2 -8
- package/dist/device/relayswitch.js.map +1 -1
- package/dist/device/robotvacuumcleaner.d.ts.map +1 -1
- package/dist/device/robotvacuumcleaner.js +2 -8
- package/dist/device/robotvacuumcleaner.js.map +1 -1
- package/dist/device/waterdetector.d.ts.map +1 -1
- package/dist/device/waterdetector.js +1 -4
- package/dist/device/waterdetector.js.map +1 -1
- package/dist/irdevice/airpurifier.d.ts +1 -1
- package/dist/irdevice/airpurifier.d.ts.map +1 -1
- package/dist/irdevice/airpurifier.js +4 -4
- package/dist/irdevice/airpurifier.js.map +1 -1
- package/dist/platform.d.ts +2 -1
- package/dist/platform.d.ts.map +1 -1
- package/dist/platform.js +68 -7
- package/dist/platform.js.map +1 -1
- package/docs/assets/main.js +5 -5
- package/docs/assets/navigation.js +1 -0
- package/docs/assets/search.js +1 -0
- package/docs/assets/style.css +251 -229
- package/docs/hierarchy.html +1 -0
- package/docs/index.html +18 -19
- package/docs/modules.html +1 -2
- package/docs/variables/default.html +1 -0
- package/package.json +8 -10
- package/src/device/airpurifier.ts +563 -0
- package/src/device/blindtilt.ts +2 -6
- package/src/device/bot.ts +2 -6
- package/src/device/ceilinglight.ts +2 -6
- package/src/device/colorbulb.ts +2 -6
- package/src/device/contact.ts +1 -3
- package/src/device/curtain.ts +2 -6
- package/src/device/fan.ts +2 -6
- package/src/device/hub.ts +1 -3
- package/src/device/humidifier.ts +2 -6
- package/src/device/iosensor.ts +1 -3
- package/src/device/lightstrip.ts +2 -6
- package/src/device/lock.ts +2 -6
- package/src/device/meter.ts +2 -4
- package/src/device/meterplus.ts +1 -3
- package/src/device/meterpro.ts +3 -4
- package/src/device/motion.ts +1 -3
- package/src/device/plug.ts +2 -6
- package/src/device/relayswitch.ts +2 -6
- package/src/device/robotvacuumcleaner.ts +2 -6
- package/src/device/waterdetector.ts +1 -3
- package/src/irdevice/airpurifier.ts +4 -4
- package/src/platform.ts +78 -8
- package/typedoc.json +0 -4
- package/docs/assets/dmt/dmt-component-data.js +0 -1
- package/docs/assets/dmt/dmt-components.css +0 -20
- package/docs/assets/dmt/dmt-components.js +0 -67
- package/docs/assets/dmt/dmt-search.cmp +0 -0
- package/docs/assets/dmt/dmt-theme.css +0 -1
- package/docs/functions/default.html +0 -2
package/dist/platform.js
CHANGED
|
@@ -5,6 +5,7 @@ import fakegato from 'fakegato-history';
|
|
|
5
5
|
import { EveHomeKitTypes } from 'homebridge-lib/EveHomeKitTypes';
|
|
6
6
|
import { LogLevel, SwitchBotBLE, SwitchBotModel, SwitchBotOpenAPI } from 'node-switchbot';
|
|
7
7
|
import { queueScheduler } from 'rxjs';
|
|
8
|
+
import { AirPurifier } from './device/airpurifier.js';
|
|
8
9
|
import { BlindTilt } from './device/blindtilt.js';
|
|
9
10
|
import { Bot } from './device/bot.js';
|
|
10
11
|
import { CeilingLight } from './device/ceilinglight.js';
|
|
@@ -26,7 +27,7 @@ import { RelaySwitch } from './device/relayswitch.js';
|
|
|
26
27
|
import { RobotVacuumCleaner } from './device/robotvacuumcleaner.js';
|
|
27
28
|
import { WaterDetector } from './device/waterdetector.js';
|
|
28
29
|
import { AirConditioner } from './irdevice/airconditioner.js';
|
|
29
|
-
import {
|
|
30
|
+
import { AirPurifierIR } from './irdevice/airpurifier.js';
|
|
30
31
|
import { Camera } from './irdevice/camera.js';
|
|
31
32
|
import { IRFan } from './irdevice/fan.js';
|
|
32
33
|
import { Light } from './irdevice/light.js';
|
|
@@ -569,6 +570,7 @@ export class SwitchBotPlatform {
|
|
|
569
570
|
'Ceiling Light Pro': this.createCeilingLight.bind(this),
|
|
570
571
|
'Strip Light': this.createStripLight.bind(this),
|
|
571
572
|
'Battery Circulator Fan': this.createFan.bind(this),
|
|
573
|
+
'Air Purifier PM2.5': this.createAirPurifier.bind(this),
|
|
572
574
|
};
|
|
573
575
|
if (deviceTypeHandlers[device.deviceType]) {
|
|
574
576
|
this.debugLog(`Discovered ${device.deviceType}: ${device.deviceId}`);
|
|
@@ -602,8 +604,8 @@ export class SwitchBotPlatform {
|
|
|
602
604
|
'DIY Air Conditioner': this.createAirConditioner.bind(this),
|
|
603
605
|
'Light': this.createLight.bind(this),
|
|
604
606
|
'DIY Light': this.createLight.bind(this),
|
|
605
|
-
'Air Purifier': this.
|
|
606
|
-
'DIY Air Purifier': this.
|
|
607
|
+
'Air Purifier': this.createAirPurifierIR.bind(this),
|
|
608
|
+
'DIY Air Purifier': this.createAirPurifierIR.bind(this),
|
|
607
609
|
'Water Heater': this.createWaterHeater.bind(this),
|
|
608
610
|
'DIY Water Heater': this.createWaterHeater.bind(this),
|
|
609
611
|
'Vacuum Cleaner': this.createVacuumCleaner.bind(this),
|
|
@@ -1803,6 +1805,66 @@ export class SwitchBotPlatform {
|
|
|
1803
1805
|
this.debugLog(`Device not registered: ${device.deviceName} ${device.deviceType} deviceId: ${device.deviceId}`);
|
|
1804
1806
|
}
|
|
1805
1807
|
}
|
|
1808
|
+
async createAirPurifier(device) {
|
|
1809
|
+
const uuid = this.api.hap.uuid.generate(`${device.deviceId}-${device.deviceType}`);
|
|
1810
|
+
// see if an accessory with the same uuid has already been registered and restored from
|
|
1811
|
+
// the cached devices we stored in the `configureAccessory` method above
|
|
1812
|
+
const existingAccessory = this.accessories.find(accessory => accessory.UUID === uuid);
|
|
1813
|
+
if (existingAccessory) {
|
|
1814
|
+
// the accessory already exists
|
|
1815
|
+
if (await this.registerDevice(device)) {
|
|
1816
|
+
// if you need to update the accessory.context then you should run `api.updatePlatformAccessories`. eg.:
|
|
1817
|
+
existingAccessory.context.device = device;
|
|
1818
|
+
existingAccessory.context.deviceId = device.deviceId;
|
|
1819
|
+
existingAccessory.context.deviceType = device.deviceType;
|
|
1820
|
+
existingAccessory.context.model = SwitchBotModel.BatteryCirculatorFan;
|
|
1821
|
+
existingAccessory.displayName = device.configDeviceName
|
|
1822
|
+
? await this.validateAndCleanDisplayName(device.configDeviceName, 'configDeviceName', device.configDeviceName)
|
|
1823
|
+
: await this.validateAndCleanDisplayName(device.deviceName, 'deviceName', device.deviceName);
|
|
1824
|
+
existingAccessory.context.connectionType = await this.connectionType(device);
|
|
1825
|
+
existingAccessory.context.version = device.firmware ?? device.version ?? this.version ?? '0.0.0';
|
|
1826
|
+
this.infoLog(`Restoring existing accessory from cache: ${existingAccessory.displayName} deviceId: ${device.deviceId}`);
|
|
1827
|
+
this.api.updatePlatformAccessories([existingAccessory]);
|
|
1828
|
+
// create the accessory handler for the restored accessory
|
|
1829
|
+
// this is imported from `platformAccessory.ts`
|
|
1830
|
+
new AirPurifier(this, existingAccessory, device);
|
|
1831
|
+
this.debugLog(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${existingAccessory.UUID})`);
|
|
1832
|
+
}
|
|
1833
|
+
else {
|
|
1834
|
+
this.unregisterPlatformAccessories(existingAccessory);
|
|
1835
|
+
}
|
|
1836
|
+
}
|
|
1837
|
+
else if (await this.registerDevice(device)) {
|
|
1838
|
+
// create a new accessory
|
|
1839
|
+
const accessory = new this.api.platformAccessory(device.configDeviceName
|
|
1840
|
+
? await this.validateAndCleanDisplayName(device.configDeviceName, 'configDeviceName', device.configDeviceName)
|
|
1841
|
+
: await this.validateAndCleanDisplayName(device.deviceName, 'deviceName', device.deviceName), uuid);
|
|
1842
|
+
// store a copy of the device object in the `accessory.context`
|
|
1843
|
+
// the `context` property can be used to store any data about the accessory you may need
|
|
1844
|
+
accessory.context.device = device;
|
|
1845
|
+
accessory.context.deviceId = device.deviceId;
|
|
1846
|
+
accessory.context.deviceType = device.deviceType;
|
|
1847
|
+
accessory.context.model = SwitchBotModel.BatteryCirculatorFan;
|
|
1848
|
+
accessory.displayName = device.configDeviceName
|
|
1849
|
+
? await this.validateAndCleanDisplayName(device.configDeviceName, 'configDeviceName', device.configDeviceName)
|
|
1850
|
+
: await this.validateAndCleanDisplayName(device.deviceName, 'deviceName', device.deviceName);
|
|
1851
|
+
accessory.context.connectionType = await this.connectionType(device);
|
|
1852
|
+
accessory.context.connectionType = await this.connectionType(device);
|
|
1853
|
+
accessory.context.version = device.firmware ?? device.version ?? this.version ?? '0.0.0';
|
|
1854
|
+
const newOrExternal = !device.external ? 'Adding new' : 'Loading external';
|
|
1855
|
+
this.infoLog(`${newOrExternal} accessory: ${accessory.displayName} deviceId: ${device.deviceId}`);
|
|
1856
|
+
// create the accessory handler for the newly create accessory
|
|
1857
|
+
// this is imported from `platformAccessory.ts`
|
|
1858
|
+
new AirPurifier(this, accessory, device);
|
|
1859
|
+
this.debugLog(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${accessory.UUID})`);
|
|
1860
|
+
// publish device externally or link the accessory to your platform
|
|
1861
|
+
this.externalOrPlatform(device, accessory);
|
|
1862
|
+
this.accessories.push(accessory);
|
|
1863
|
+
}
|
|
1864
|
+
else {
|
|
1865
|
+
this.debugLog(`Device not registered: ${device.deviceName} ${device.deviceType} deviceId: ${device.deviceId}`);
|
|
1866
|
+
}
|
|
1867
|
+
}
|
|
1806
1868
|
async createRobotVacuumCleaner(device) {
|
|
1807
1869
|
const uuid = this.api.hap.uuid.generate(`${device.deviceId}-${device.deviceType}`);
|
|
1808
1870
|
// see if an accessory with the same uuid has already been registered and restored from
|
|
@@ -2108,7 +2170,7 @@ export class SwitchBotPlatform {
|
|
|
2108
2170
|
this.debugLog(`Device not registered: ${device.deviceName} ${device.remoteType} deviceId: ${device.deviceId}`);
|
|
2109
2171
|
}
|
|
2110
2172
|
}
|
|
2111
|
-
async
|
|
2173
|
+
async createAirPurifierIR(device) {
|
|
2112
2174
|
const uuid = this.api.hap.uuid.generate(`${device.deviceId}-${device.remoteType}`);
|
|
2113
2175
|
// see if an accessory with the same uuid has already been registered and restored from
|
|
2114
2176
|
// the cached devices we stored in the `configureAccessory` method above
|
|
@@ -2129,7 +2191,7 @@ export class SwitchBotPlatform {
|
|
|
2129
2191
|
this.api.updatePlatformAccessories([existingAccessory]);
|
|
2130
2192
|
// create the accessory handler for the restored accessory
|
|
2131
2193
|
// this is imported from `platformAccessory.ts`
|
|
2132
|
-
new
|
|
2194
|
+
new AirPurifierIR(this, existingAccessory, device);
|
|
2133
2195
|
this.debugLog(`${device.remoteType} uuid: ${device.deviceId}-${device.remoteType}, (${existingAccessory.UUID})`);
|
|
2134
2196
|
}
|
|
2135
2197
|
else {
|
|
@@ -2156,7 +2218,7 @@ export class SwitchBotPlatform {
|
|
|
2156
2218
|
this.infoLog(`${newOrExternal} accessory: ${accessory.displayName} deviceId: ${device.deviceId}`);
|
|
2157
2219
|
// create the accessory handler for the newly create accessory
|
|
2158
2220
|
// this is imported from `platformAccessory.ts`
|
|
2159
|
-
new
|
|
2221
|
+
new AirPurifierIR(this, accessory, device);
|
|
2160
2222
|
this.debugLog(`${device.remoteType} uuid: ${device.deviceId}-${device.remoteType}, (${accessory.UUID})`);
|
|
2161
2223
|
// publish device externally or link the accessory to your platform
|
|
2162
2224
|
this.externalOrPlatform(device, accessory);
|
|
@@ -2571,7 +2633,6 @@ export class SwitchBotPlatform {
|
|
|
2571
2633
|
hubDeviceId: '',
|
|
2572
2634
|
version: 0,
|
|
2573
2635
|
deviceName: '',
|
|
2574
|
-
enableCloudService: false,
|
|
2575
2636
|
}, statusCode: 500 };
|
|
2576
2637
|
}
|
|
2577
2638
|
async retryCommand(device, bodyChange, deviceMaxRetries, deviceDelayBetweenRetries) {
|