@switchbot/homebridge-switchbot 2.0.0-beta.35 → 2.0.0-beta.37
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 +3 -0
- package/README.md +2 -0
- package/dist/device/ceilinglight.d.ts +137 -0
- package/dist/device/ceilinglight.d.ts.map +1 -0
- package/dist/device/ceilinglight.js +1127 -0
- package/dist/device/ceilinglight.js.map +1 -0
- package/dist/device/curtain.d.ts.map +1 -1
- package/dist/device/curtain.js +3 -0
- package/dist/device/curtain.js.map +1 -1
- package/dist/device/meter.d.ts.map +1 -1
- package/dist/device/meter.js +3 -0
- package/dist/device/meter.js.map +1 -1
- package/dist/device/meterplus.d.ts.map +1 -1
- package/dist/device/meterplus.js +3 -0
- package/dist/device/meterplus.js.map +1 -1
- package/dist/platform.d.ts +1 -0
- package/dist/platform.d.ts.map +1 -1
- package/dist/platform.js +56 -0
- package/dist/platform.js.map +1 -1
- package/dist/settings.d.ts +5 -0
- package/dist/settings.d.ts.map +1 -1
- package/dist/settings.js.map +1 -1
- package/package.json +1 -1
- package/src/device/ceilinglight.ts +1208 -0
- package/src/device/curtain.ts +3 -0
- package/src/device/meter.ts +3 -0
- package/src/device/meterplus.ts +3 -0
- package/src/platform.ts +59 -0
- package/src/settings.ts +6 -0
package/src/device/curtain.ts
CHANGED
|
@@ -1038,6 +1038,9 @@ export class Curtain {
|
|
|
1038
1038
|
if (device.external !== undefined) {
|
|
1039
1039
|
config['external'] = device.external;
|
|
1040
1040
|
}
|
|
1041
|
+
if (device.mqttURL !== undefined) {
|
|
1042
|
+
config['mqttURL'] = device.mqttURL;
|
|
1043
|
+
}
|
|
1041
1044
|
if (device.logging !== undefined) {
|
|
1042
1045
|
config['logging'] = device.logging;
|
|
1043
1046
|
}
|
package/src/device/meter.ts
CHANGED
|
@@ -649,6 +649,9 @@ export class Meter {
|
|
|
649
649
|
if (device.external !== undefined) {
|
|
650
650
|
config['external'] = device.external;
|
|
651
651
|
}
|
|
652
|
+
if (device.mqttURL !== undefined) {
|
|
653
|
+
config['mqttURL'] = device.mqttURL;
|
|
654
|
+
}
|
|
652
655
|
if (device.logging !== undefined) {
|
|
653
656
|
config['logging'] = device.logging;
|
|
654
657
|
}
|
package/src/device/meterplus.ts
CHANGED
|
@@ -658,6 +658,9 @@ export class MeterPlus {
|
|
|
658
658
|
if (device.external !== undefined) {
|
|
659
659
|
config['external'] = device.external;
|
|
660
660
|
}
|
|
661
|
+
if (device.mqttURL !== undefined) {
|
|
662
|
+
config['mqttURL'] = device.mqttURL;
|
|
663
|
+
}
|
|
661
664
|
if (device.logging !== undefined) {
|
|
662
665
|
config['logging'] = device.logging;
|
|
663
666
|
}
|
package/src/platform.ts
CHANGED
|
@@ -7,6 +7,7 @@ import { Contact } from './device/contact';
|
|
|
7
7
|
import { Curtain } from './device/curtain';
|
|
8
8
|
import { MeterPlus } from './device/meterplus';
|
|
9
9
|
import { ColorBulb } from './device/colorbulb';
|
|
10
|
+
import { CeilingLight } from './device/ceilinglight';
|
|
10
11
|
import { StripLight } from './device/striplight';
|
|
11
12
|
import { Humidifier } from './device/humidifier';
|
|
12
13
|
import { TV } from './irdevice/tv';
|
|
@@ -468,6 +469,10 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
468
469
|
this.debugLog(`Discovered ${device.deviceType}: ${device.deviceId}`);
|
|
469
470
|
this.createColorBulb(device);
|
|
470
471
|
break;
|
|
472
|
+
case 'Ceiling Light':
|
|
473
|
+
this.debugLog(`Discovered ${device.deviceType}: ${device.deviceId}`);
|
|
474
|
+
this.createCeilingLight(device);
|
|
475
|
+
break;
|
|
471
476
|
case 'Strip Light':
|
|
472
477
|
this.debugLog(`Discovered ${device.deviceType}: ${device.deviceId}`);
|
|
473
478
|
this.createStripLight(device);
|
|
@@ -1104,6 +1109,60 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
1104
1109
|
}
|
|
1105
1110
|
}
|
|
1106
1111
|
|
|
1112
|
+
private async createCeilingLight(device: device & devicesConfig) {
|
|
1113
|
+
const uuid = this.api.hap.uuid.generate(`${device.deviceId}-${device.deviceType}`);
|
|
1114
|
+
|
|
1115
|
+
// see if an accessory with the same uuid has already been registered and restored from
|
|
1116
|
+
// the cached devices we stored in the `configureAccessory` method above
|
|
1117
|
+
const existingAccessory = this.accessories.find((accessory) => accessory.UUID === uuid);
|
|
1118
|
+
|
|
1119
|
+
if (existingAccessory) {
|
|
1120
|
+
// the accessory already exists
|
|
1121
|
+
if (await this.registerDevice(device)) {
|
|
1122
|
+
// if you need to update the accessory.context then you should run `api.updatePlatformAccessories`. eg.:
|
|
1123
|
+
existingAccessory.context.model = device.deviceType;
|
|
1124
|
+
existingAccessory.context.deviceID = device.deviceId;
|
|
1125
|
+
existingAccessory.displayName = device.configDeviceName || device.deviceName;
|
|
1126
|
+
existingAccessory.context.firmwareRevision = device.firmware;
|
|
1127
|
+
existingAccessory.context.deviceType = `SwitchBot: ${device.deviceType}`;
|
|
1128
|
+
this.infoLog(`Restoring existing accessory from cache: ${existingAccessory.displayName} DeviceID: ${device.deviceId}`);
|
|
1129
|
+
existingAccessory.context.connectionType = await this.connectionType(device);
|
|
1130
|
+
this.api.updatePlatformAccessories([existingAccessory]);
|
|
1131
|
+
// create the accessory handler for the restored accessory
|
|
1132
|
+
// this is imported from `platformAccessory.ts`
|
|
1133
|
+
new CeilingLight(this, existingAccessory, device);
|
|
1134
|
+
this.debugLog(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${existingAccessory.UUID})`);
|
|
1135
|
+
} else {
|
|
1136
|
+
this.unregisterPlatformAccessories(existingAccessory);
|
|
1137
|
+
}
|
|
1138
|
+
} else if (await this.registerDevice(device)) {
|
|
1139
|
+
// the accessory does not yet exist, so we need to create it
|
|
1140
|
+
this.infoLog(`Adding new accessory: ${device.deviceName} ${device.deviceType} DeviceID: ${device.deviceId}`);
|
|
1141
|
+
|
|
1142
|
+
// create a new accessory
|
|
1143
|
+
const accessory = new this.api.platformAccessory(device.deviceName, uuid);
|
|
1144
|
+
|
|
1145
|
+
// store a copy of the device object in the `accessory.context`
|
|
1146
|
+
// the `context` property can be used to store any data about the accessory you may need
|
|
1147
|
+
accessory.context.device = device;
|
|
1148
|
+
accessory.context.model = device.deviceType;
|
|
1149
|
+
accessory.context.deviceID = device.deviceId;
|
|
1150
|
+
accessory.context.firmwareRevision = device.firmware;
|
|
1151
|
+
accessory.context.deviceType = `SwitchBot: ${device.deviceType}`;
|
|
1152
|
+
accessory.context.connectionType = await this.connectionType(device);
|
|
1153
|
+
// create the accessory handler for the newly create accessory
|
|
1154
|
+
// this is imported from `platformAccessory.ts`
|
|
1155
|
+
new CeilingLight(this, accessory, device);
|
|
1156
|
+
this.debugLog(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${accessory.UUID})`);
|
|
1157
|
+
|
|
1158
|
+
// publish device externally or link the accessory to your platform
|
|
1159
|
+
this.externalOrPlatform(device, accessory);
|
|
1160
|
+
this.accessories.push(accessory);
|
|
1161
|
+
} else {
|
|
1162
|
+
this.debugLog(`Device not registered: ${device.deviceName} ${device.deviceType} DeviceID: ${device.deviceId}`);
|
|
1163
|
+
}
|
|
1164
|
+
}
|
|
1165
|
+
|
|
1107
1166
|
private async createStripLight(device: device & devicesConfig) {
|
|
1108
1167
|
const uuid = this.api.hap.uuid.generate(`${device.deviceId}-${device.deviceType}`);
|
|
1109
1168
|
|
package/src/settings.ts
CHANGED
|
@@ -65,6 +65,7 @@ export interface devicesConfig extends device {
|
|
|
65
65
|
contact?: contact;
|
|
66
66
|
motion?: motion;
|
|
67
67
|
colorbulb?: colorbulb;
|
|
68
|
+
ceilinglight?: ceilinglight;
|
|
68
69
|
plug?: Record<any, any>;
|
|
69
70
|
lock?: lock;
|
|
70
71
|
}
|
|
@@ -118,6 +119,11 @@ export type colorbulb = {
|
|
|
118
119
|
adaptiveLightingShift?: number;
|
|
119
120
|
};
|
|
120
121
|
|
|
122
|
+
export type ceilinglight = {
|
|
123
|
+
set_minStep?: number;
|
|
124
|
+
adaptiveLightingShift?: number;
|
|
125
|
+
};
|
|
126
|
+
|
|
121
127
|
export type lock = {
|
|
122
128
|
hide_contactsensor?: boolean;
|
|
123
129
|
};
|