@switchbot/homebridge-switchbot 2.8.0 → 2.8.1-beta.0
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/.github/npm-version-script.js +81 -0
- package/dist/device/blindtilt.d.ts +21 -23
- package/dist/device/blindtilt.d.ts.map +1 -1
- package/dist/device/blindtilt.js +71 -73
- package/dist/device/blindtilt.js.map +1 -1
- package/dist/device/bot.d.ts +11 -15
- package/dist/device/bot.d.ts.map +1 -1
- package/dist/device/bot.js +38 -34
- package/dist/device/bot.js.map +1 -1
- package/dist/device/ceilinglight.d.ts +10 -14
- package/dist/device/ceilinglight.d.ts.map +1 -1
- package/dist/device/ceilinglight.js +33 -23
- package/dist/device/ceilinglight.js.map +1 -1
- package/dist/device/colorbulb.d.ts +16 -24
- package/dist/device/colorbulb.d.ts.map +1 -1
- package/dist/device/colorbulb.js +49 -43
- package/dist/device/colorbulb.js.map +1 -1
- package/dist/device/contact.d.ts +16 -24
- package/dist/device/contact.d.ts.map +1 -1
- package/dist/device/contact.js +49 -51
- package/dist/device/contact.js.map +1 -1
- package/dist/device/curtain.d.ts +21 -26
- package/dist/device/curtain.d.ts.map +1 -1
- package/dist/device/curtain.js +49 -47
- package/dist/device/curtain.js.map +1 -1
- package/dist/device/hub.d.ts +9 -8
- package/dist/device/hub.d.ts.map +1 -1
- package/dist/device/hub.js +42 -30
- package/dist/device/hub.js.map +1 -1
- package/dist/device/humidifier.d.ts +8 -10
- package/dist/device/humidifier.d.ts.map +1 -1
- package/dist/device/humidifier.js +27 -17
- package/dist/device/humidifier.js.map +1 -1
- package/dist/device/iosensor.d.ts +16 -21
- package/dist/device/iosensor.d.ts.map +1 -1
- package/dist/device/iosensor.js +35 -26
- package/dist/device/iosensor.js.map +1 -1
- package/dist/device/lightstrip.d.ts +1 -5
- package/dist/device/lightstrip.d.ts.map +1 -1
- package/dist/device/lightstrip.js +2 -4
- package/dist/device/lightstrip.js.map +1 -1
- package/dist/device/lock.d.ts +15 -21
- package/dist/device/lock.d.ts.map +1 -1
- package/dist/device/lock.js +64 -26
- package/dist/device/lock.js.map +1 -1
- package/dist/device/meter.d.ts +4 -9
- package/dist/device/meter.d.ts.map +1 -1
- package/dist/device/meter.js +8 -16
- package/dist/device/meter.js.map +1 -1
- package/dist/device/meterplus.d.ts +5 -10
- package/dist/device/meterplus.d.ts.map +1 -1
- package/dist/device/meterplus.js +8 -16
- package/dist/device/meterplus.js.map +1 -1
- package/dist/device/motion.d.ts +4 -8
- package/dist/device/motion.d.ts.map +1 -1
- package/dist/device/motion.js +10 -23
- package/dist/device/motion.js.map +1 -1
- package/dist/device/plug.d.ts +1 -5
- package/dist/device/plug.d.ts.map +1 -1
- package/dist/device/plug.js +2 -4
- package/dist/device/plug.js.map +1 -1
- package/dist/device/robotvacuumcleaner.d.ts +4 -8
- package/dist/device/robotvacuumcleaner.d.ts.map +1 -1
- package/dist/device/robotvacuumcleaner.js +7 -16
- package/dist/device/robotvacuumcleaner.js.map +1 -1
- package/dist/irdevice/fan.d.ts +0 -1
- package/dist/irdevice/fan.d.ts.map +1 -1
- package/dist/irdevice/fan.js.map +1 -1
- package/dist/irdevice/tv.d.ts +0 -1
- package/dist/irdevice/tv.d.ts.map +1 -1
- package/dist/irdevice/tv.js.map +1 -1
- package/dist/settings.d.ts +3 -1
- package/dist/settings.d.ts.map +1 -1
- package/dist/settings.js.map +1 -1
- package/package.json +2 -2
- package/src/device/blindtilt.ts +96 -95
- package/src/device/bot.ts +54 -54
- package/src/device/ceilinglight.ts +46 -39
- package/src/device/colorbulb.ts +68 -69
- package/src/device/contact.ts +69 -77
- package/src/device/curtain.ts +75 -74
- package/src/device/hub.ts +53 -38
- package/src/device/humidifier.ts +33 -26
- package/src/device/iosensor.ts +53 -48
- package/src/device/lightstrip.ts +4 -10
- package/src/device/lock.ts +84 -49
- package/src/device/meter.ts +13 -25
- package/src/device/meterplus.ts +14 -27
- package/src/device/motion.ts +16 -32
- package/src/device/plug.ts +4 -10
- package/src/device/robotvacuumcleaner.ts +13 -25
- package/src/irdevice/fan.ts +0 -3
- package/src/irdevice/tv.ts +0 -3
- package/src/settings.ts +5 -1
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
#!/bin/env node
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* This scripts queries the npm registry to pull out the latest version for a given tag.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
const fs = require("fs");
|
|
8
|
+
const semver = require("semver");
|
|
9
|
+
const child_process = require("child_process");
|
|
10
|
+
const assert = require("assert");
|
|
11
|
+
|
|
12
|
+
const BRANCH_VERSION_PATTERN = /^([A-Za-z]*)-(\d+.\d+.\d+)$/
|
|
13
|
+
|
|
14
|
+
// Load the contents of the package.json file
|
|
15
|
+
const packageJSON = JSON.parse(fs.readFileSync("package.json", "utf8"));
|
|
16
|
+
|
|
17
|
+
let refArgument = process.argv[2];
|
|
18
|
+
let tagArgument = process.argv[3] || "latest";
|
|
19
|
+
|
|
20
|
+
if (refArgument == null) {
|
|
21
|
+
console.error("ref argument is missing");
|
|
22
|
+
console.error("Usage: npm-version-script.js <ref> [tag]");
|
|
23
|
+
process.exit(1);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Queries the NPM registry for the latest version for the provided tag.
|
|
28
|
+
* @param tag The tag to query for.
|
|
29
|
+
* @returns {string} Returns the version.
|
|
30
|
+
*/
|
|
31
|
+
function getTagVersionFromNpm(tag) {
|
|
32
|
+
try {
|
|
33
|
+
return child_process.execSync(`npm info ${packageJSON.name} version --tag="${tag}"`).toString("utf8").trim();
|
|
34
|
+
} catch (e) {
|
|
35
|
+
throw e;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function desiredTargetVersion(ref) {
|
|
40
|
+
// ref is a GitHub action ref string
|
|
41
|
+
if (ref.startsWith("refs/pull/")) {
|
|
42
|
+
throw Error("The version script was executed inside a PR!");
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
assert(ref.startsWith("refs/heads/"))
|
|
46
|
+
let branchName = ref.slice("refs/heads/".length);
|
|
47
|
+
|
|
48
|
+
let results = branchName.match(BRANCH_VERSION_PATTERN);
|
|
49
|
+
if (results != null) {
|
|
50
|
+
if (results[1] !== tagArgument) {
|
|
51
|
+
console.warn(`The base branch name (${results[1]}) differs from the tag name ${tagArgument}`);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
return results[2];
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// legacy mode were we use the `betaVersion` property in the package.json
|
|
58
|
+
if (branchName === "beta" && packageJSON.betaVersion) {
|
|
59
|
+
return packageJSON.betaVersion
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
throw new Error("Malformed branch name for ref: " + ref + ". Can't derive the base version. Use a branch name like: beta-x.x.x!");
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
// derive the base version from the branch ref
|
|
66
|
+
const baseVersion = desiredTargetVersion(refArgument);
|
|
67
|
+
|
|
68
|
+
// query the npm registry for the latest version of the provided tag name
|
|
69
|
+
const latestReleasedVersion = getTagVersionFromNpm(tagArgument); // e.g. 0.7.0-beta.12
|
|
70
|
+
const latestReleaseBase = semver.inc(latestReleasedVersion, "patch"); // will produce 0.7.0 (removing the preid, needed for the equality check below)
|
|
71
|
+
|
|
72
|
+
let publishTag;
|
|
73
|
+
if (semver.eq(baseVersion, latestReleaseBase)) { // check if we are releasing another version for the latest beta
|
|
74
|
+
publishTag = latestReleasedVersion; // set the current latest beta to be incremented
|
|
75
|
+
} else {
|
|
76
|
+
publishTag = baseVersion; // start of with a new beta version
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
// save the package.json
|
|
80
|
+
packageJSON.version = publishTag;
|
|
81
|
+
fs.writeFileSync("package.json", JSON.stringify(packageJSON, null, 2));
|
|
@@ -5,7 +5,7 @@ import { MqttClient } from 'mqtt';
|
|
|
5
5
|
import { Subject } from 'rxjs';
|
|
6
6
|
import { SwitchBotPlatform } from '../platform';
|
|
7
7
|
import { Service, PlatformAccessory, CharacteristicValue } from 'homebridge';
|
|
8
|
-
import { device, devicesConfig, serviceData,
|
|
8
|
+
import { device, devicesConfig, serviceData, deviceStatus } from '../settings';
|
|
9
9
|
declare enum BlindTiltMappingMode {
|
|
10
10
|
OnlyUp = "only_up",
|
|
11
11
|
OnlyDown = "only_down",
|
|
@@ -17,36 +17,34 @@ export declare class BlindTilt {
|
|
|
17
17
|
private readonly platform;
|
|
18
18
|
private accessory;
|
|
19
19
|
device: device & devicesConfig;
|
|
20
|
-
|
|
20
|
+
batteryService: Service;
|
|
21
21
|
lightSensorService?: Service;
|
|
22
|
-
|
|
23
|
-
|
|
22
|
+
windowCoveringService: Service;
|
|
23
|
+
BatteryLevel: CharacteristicValue;
|
|
24
24
|
PositionState: CharacteristicValue;
|
|
25
25
|
TargetPosition: CharacteristicValue;
|
|
26
|
+
CurrentPosition: CharacteristicValue;
|
|
27
|
+
StatusLowBattery: CharacteristicValue;
|
|
26
28
|
CurrentAmbientLightLevel?: CharacteristicValue;
|
|
27
|
-
BatteryLevel?: CharacteristicValue;
|
|
28
|
-
StatusLowBattery?: CharacteristicValue;
|
|
29
|
-
CurrentHorizontalTiltAngle: CharacteristicValue;
|
|
30
29
|
TargetHorizontalTiltAngle: CharacteristicValue;
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
30
|
+
CurrentHorizontalTiltAngle: CharacteristicValue;
|
|
31
|
+
OpenAPI_InMotion: deviceStatus['moving'];
|
|
32
|
+
OpenAPI_BatteryLevel: serviceData['battery'];
|
|
33
|
+
OpenAPI_Direction: deviceStatus['direction'];
|
|
34
|
+
OpenAPI_Calibration: serviceData['calibration'];
|
|
35
|
+
OpenAPI_CurrentPosition: serviceData['position'];
|
|
36
|
+
OpenAPI_FirmwareRevision: deviceStatus['version'];
|
|
37
|
+
OpenAPI_CurrentAmbientLightLevel: deviceStatus['brightness'];
|
|
38
38
|
Mode: string;
|
|
39
|
+
setPositionMode?: string | number;
|
|
39
40
|
mappingMode: BlindTiltMappingMode;
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
41
|
+
BLE_InMotion: serviceData['inMotion'];
|
|
42
|
+
BLE_BatteryLevel: serviceData['battery'];
|
|
43
|
+
BLE_Calibration: serviceData['calibration'];
|
|
44
|
+
BLE_CurrentPosition: serviceData['position'];
|
|
45
|
+
BLE_CurrentAmbientLightLevel: serviceData['lightLevel'];
|
|
46
|
+
BLE_IsConnected?: boolean;
|
|
43
47
|
spaceBetweenLevels: number;
|
|
44
|
-
address: ad['address'];
|
|
45
|
-
calibration: serviceData['calibration'];
|
|
46
|
-
battery: serviceData['battery'];
|
|
47
|
-
position: serviceData['position'];
|
|
48
|
-
inMotion: serviceData['inMotion'];
|
|
49
|
-
lightLevel: serviceData['lightLevel'];
|
|
50
48
|
setNewTarget: boolean;
|
|
51
49
|
setNewTargetTimer: NodeJS.Timeout;
|
|
52
50
|
mqttClient: MqttClient | null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"blindtilt.d.ts","sourceRoot":"","sources":["../../src/device/blindtilt.ts"],"names":[],"mappings":";;AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,IAAI,CAAC;AAG7B,OAAO,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;AAClC,OAAO,EAAY,OAAO,EAAE,MAAM,MAAM,CAAC;AAEzC,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAEhD,OAAO,EAAE,OAAO,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAC7E,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,WAAW,EAAE,
|
|
1
|
+
{"version":3,"file":"blindtilt.d.ts","sourceRoot":"","sources":["../../src/device/blindtilt.ts"],"names":[],"mappings":";;AAAA,OAAO,EAAE,OAAO,EAA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AAE,GAAG,EAAE,GAAG,IAAI;IAM7B,aAAa,CAAC,GAAG,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI;IAQlC,QAAQ,CAAC,GAAG,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI;IAU7B,qBAAqB,IAAI,OAAO;CAGjC"}
|
package/dist/device/blindtilt.js
CHANGED
|
@@ -112,22 +112,11 @@ class BlindTilt {
|
|
|
112
112
|
})
|
|
113
113
|
.onSet(this.TargetHorizontalTiltAngleSet.bind(this));
|
|
114
114
|
// Battery Service
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
else if (this.BLE && !this.batteryService) {
|
|
121
|
-
this.debugLog(`${this.device.deviceType}: ${accessory.displayName} Add Battery Service`);
|
|
122
|
-
(this.batteryService = this.accessory.getService(this.platform.Service.Battery) || this.accessory.addService(this.platform.Service.Battery)),
|
|
123
|
-
`${accessory.displayName} Battery`;
|
|
124
|
-
this.batteryService.setCharacteristic(this.platform.Characteristic.Name, `${accessory.displayName} Battery`);
|
|
125
|
-
if (!this.batteryService.testCharacteristic(this.platform.Characteristic.ConfiguredName)) {
|
|
126
|
-
this.batteryService.addCharacteristic(this.platform.Characteristic.ConfiguredName, `${accessory.displayName} Battery`);
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
else {
|
|
130
|
-
this.debugLog(`${this.device.deviceType}: ${accessory.displayName} Battery Service Not Added`);
|
|
115
|
+
(this.batteryService = this.accessory.getService(this.platform.Service.Battery) || accessory.addService(this.platform.Service.Battery)),
|
|
116
|
+
`${accessory.displayName} Battery`;
|
|
117
|
+
this.batteryService.setCharacteristic(this.platform.Characteristic.Name, `${accessory.displayName} Battery`);
|
|
118
|
+
if (!this.batteryService.testCharacteristic(this.platform.Characteristic.ConfiguredName)) {
|
|
119
|
+
this.batteryService.addCharacteristic(this.platform.Characteristic.ConfiguredName, `${accessory.displayName} Battery`);
|
|
131
120
|
}
|
|
132
121
|
// Update Homekit
|
|
133
122
|
this.updateHomeKitCharacteristics();
|
|
@@ -186,13 +175,13 @@ class BlindTilt {
|
|
|
186
175
|
async BLEparseStatus() {
|
|
187
176
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} BLEparseStatus`);
|
|
188
177
|
// CurrentPosition
|
|
189
|
-
this.CurrentPosition = 100 - Number(this.
|
|
178
|
+
this.CurrentPosition = 100 - Number(this.BLE_CurrentPosition);
|
|
190
179
|
await this.setMinMax();
|
|
191
180
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} CurrentPosition ${this.CurrentPosition}`);
|
|
192
181
|
if (this.setNewTarget) {
|
|
193
182
|
this.infoLog(`${this.device.deviceType}: ${this.accessory.displayName} Checking Status ...`);
|
|
194
183
|
}
|
|
195
|
-
if (this.setNewTarget && this.
|
|
184
|
+
if (this.setNewTarget && this.BLE_InMotion) {
|
|
196
185
|
await this.setMinMax();
|
|
197
186
|
if (Number(this.TargetPosition) > this.CurrentPosition) {
|
|
198
187
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Closing, CurrentPosition: ${this.CurrentPosition}`);
|
|
@@ -226,54 +215,54 @@ class BlindTilt {
|
|
|
226
215
|
this.set_maxLux = this.maxLux();
|
|
227
216
|
this.spaceBetweenLevels = 9;
|
|
228
217
|
// Brightness
|
|
229
|
-
switch (this.
|
|
218
|
+
switch (this.BLE_CurrentAmbientLightLevel) {
|
|
230
219
|
case 1:
|
|
231
220
|
this.CurrentAmbientLightLevel = this.set_minLux;
|
|
232
|
-
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} LightLevel: ${this.
|
|
221
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} LightLevel: ${this.BLE_CurrentAmbientLightLevel}`);
|
|
233
222
|
break;
|
|
234
223
|
case 2:
|
|
235
224
|
this.CurrentAmbientLightLevel = (this.set_maxLux - this.set_minLux) / this.spaceBetweenLevels;
|
|
236
|
-
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} LightLevel: ${this.
|
|
225
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} LightLevel: ${this.BLE_CurrentAmbientLightLevel},` +
|
|
237
226
|
` Calculation: ${(this.set_maxLux - this.set_minLux) / this.spaceBetweenLevels}`);
|
|
238
227
|
break;
|
|
239
228
|
case 3:
|
|
240
229
|
this.CurrentAmbientLightLevel = ((this.set_maxLux - this.set_minLux) / this.spaceBetweenLevels) * 2;
|
|
241
|
-
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} LightLevel: ${this.
|
|
230
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} LightLevel: ${this.BLE_CurrentAmbientLightLevel}`);
|
|
242
231
|
break;
|
|
243
232
|
case 4:
|
|
244
233
|
this.CurrentAmbientLightLevel = ((this.set_maxLux - this.set_minLux) / this.spaceBetweenLevels) * 3;
|
|
245
|
-
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} LightLevel: ${this.
|
|
234
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} LightLevel: ${this.BLE_CurrentAmbientLightLevel}`);
|
|
246
235
|
break;
|
|
247
236
|
case 5:
|
|
248
237
|
this.CurrentAmbientLightLevel = ((this.set_maxLux - this.set_minLux) / this.spaceBetweenLevels) * 4;
|
|
249
|
-
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} LightLevel: ${this.
|
|
238
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} LightLevel: ${this.BLE_CurrentAmbientLightLevel}`);
|
|
250
239
|
break;
|
|
251
240
|
case 6:
|
|
252
241
|
this.CurrentAmbientLightLevel = ((this.set_maxLux - this.set_minLux) / this.spaceBetweenLevels) * 5;
|
|
253
|
-
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} LightLevel: ${this.
|
|
242
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} LightLevel: ${this.BLE_CurrentAmbientLightLevel}`);
|
|
254
243
|
break;
|
|
255
244
|
case 7:
|
|
256
245
|
this.CurrentAmbientLightLevel = ((this.set_maxLux - this.set_minLux) / this.spaceBetweenLevels) * 6;
|
|
257
|
-
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} LightLevel: ${this.
|
|
246
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} LightLevel: ${this.BLE_CurrentAmbientLightLevel}`);
|
|
258
247
|
break;
|
|
259
248
|
case 8:
|
|
260
249
|
this.CurrentAmbientLightLevel = ((this.set_maxLux - this.set_minLux) / this.spaceBetweenLevels) * 7;
|
|
261
|
-
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} LightLevel: ${this.
|
|
250
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} LightLevel: ${this.BLE_CurrentAmbientLightLevel}`);
|
|
262
251
|
break;
|
|
263
252
|
case 9:
|
|
264
253
|
this.CurrentAmbientLightLevel = ((this.set_maxLux - this.set_minLux) / this.spaceBetweenLevels) * 8;
|
|
265
|
-
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} LightLevel: ${this.
|
|
254
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} LightLevel: ${this.BLE_CurrentAmbientLightLevel}`);
|
|
266
255
|
break;
|
|
267
256
|
case 10:
|
|
268
257
|
default:
|
|
269
258
|
this.CurrentAmbientLightLevel = this.set_maxLux;
|
|
270
259
|
this.debugLog();
|
|
271
260
|
}
|
|
272
|
-
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} LightLevel: ${this.
|
|
261
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} LightLevel: ${this.BLE_CurrentAmbientLightLevel},` +
|
|
273
262
|
` CurrentAmbientLightLevel: ${this.CurrentAmbientLightLevel}`);
|
|
274
263
|
}
|
|
275
264
|
// Battery
|
|
276
|
-
this.BatteryLevel = Number(this.
|
|
265
|
+
this.BatteryLevel = Number(this.BLE_BatteryLevel);
|
|
277
266
|
if (this.BatteryLevel < 10) {
|
|
278
267
|
this.StatusLowBattery = this.platform.Characteristic.StatusLowBattery.BATTERY_LEVEL_LOW;
|
|
279
268
|
}
|
|
@@ -284,8 +273,8 @@ class BlindTilt {
|
|
|
284
273
|
}
|
|
285
274
|
async openAPIparseStatus() {
|
|
286
275
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} openAPIparseStatus`);
|
|
287
|
-
const [homekitPosition, homekitTiltAngle] = this.mapDeviceValuesToHomekitValues(Number(this.
|
|
288
|
-
this.debugLog(` device: ${this.
|
|
276
|
+
const [homekitPosition, homekitTiltAngle] = this.mapDeviceValuesToHomekitValues(Number(this.OpenAPI_CurrentPosition), String(this.OpenAPI_Direction));
|
|
277
|
+
this.debugLog(` device: ${this.OpenAPI_CurrentPosition} => HK: ${homekitPosition}`);
|
|
289
278
|
this.CurrentPosition = homekitPosition;
|
|
290
279
|
// CurrentPosition
|
|
291
280
|
await this.setMinMax();
|
|
@@ -297,7 +286,7 @@ class BlindTilt {
|
|
|
297
286
|
if (this.setNewTarget) {
|
|
298
287
|
this.infoLog(`${this.device.deviceType}: ${this.accessory.displayName} Checking Status ...`);
|
|
299
288
|
}
|
|
300
|
-
if (this.setNewTarget && this.
|
|
289
|
+
if (this.setNewTarget && this.OpenAPI_InMotion) {
|
|
301
290
|
await this.setMinMax();
|
|
302
291
|
if (this.TargetPosition > this.CurrentPosition || (homekitTiltAngle && this.TargetHorizontalTiltAngle !== this.CurrentHorizontalTiltAngle)) {
|
|
303
292
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Closing, CurrentPosition: ${this.CurrentPosition} `);
|
|
@@ -333,7 +322,7 @@ class BlindTilt {
|
|
|
333
322
|
this.set_minLux = this.minLux();
|
|
334
323
|
this.set_maxLux = this.maxLux();
|
|
335
324
|
// Brightness
|
|
336
|
-
switch (this.
|
|
325
|
+
switch (this.OpenAPI_CurrentAmbientLightLevel) {
|
|
337
326
|
case 'dim':
|
|
338
327
|
this.CurrentAmbientLightLevel = this.set_minLux;
|
|
339
328
|
break;
|
|
@@ -380,27 +369,25 @@ class BlindTilt {
|
|
|
380
369
|
.then(async () => {
|
|
381
370
|
// Set an event hander
|
|
382
371
|
switchbot.onadvertisement = async (ad) => {
|
|
383
|
-
this.address = ad.address;
|
|
384
372
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Config BLE Address: ${this.device.bleMac},` +
|
|
385
|
-
` BLE Address Found: ${
|
|
386
|
-
this.
|
|
387
|
-
this.
|
|
388
|
-
this.
|
|
389
|
-
this.
|
|
390
|
-
this.
|
|
391
|
-
this.lightLevel = ad.serviceData.lightLevel;
|
|
373
|
+
` BLE Address Found: ${ad.address}`);
|
|
374
|
+
this.BLE_Calibration = ad.serviceData.calibration;
|
|
375
|
+
this.BLE_BatteryLevel = ad.serviceData.battery;
|
|
376
|
+
this.BLE_InMotion = ad.serviceData.inMotion;
|
|
377
|
+
this.BLE_CurrentPosition = ad.serviceData.position;
|
|
378
|
+
this.BLE_CurrentAmbientLightLevel = ad.serviceData.lightLevel;
|
|
392
379
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} serviceData: ${JSON.stringify(ad.serviceData)}`);
|
|
393
380
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} calibration: ${ad.serviceData.calibration}, ` +
|
|
394
381
|
`position: ${ad.serviceData.position}, lightLevel: ${ad.serviceData.lightLevel}, battery: ${ad.serviceData.battery}, ` +
|
|
395
382
|
`inMotion: ${ad.serviceData.inMotion}`);
|
|
396
|
-
if (
|
|
397
|
-
this.
|
|
398
|
-
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} connected: ${this.
|
|
383
|
+
if (ad.serviceData) {
|
|
384
|
+
this.BLE_IsConnected = true;
|
|
385
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} connected: ${this.BLE_IsConnected}`);
|
|
399
386
|
await this.stopScanning(switchbot);
|
|
400
387
|
}
|
|
401
388
|
else {
|
|
402
|
-
this.
|
|
403
|
-
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} connected: ${this.
|
|
389
|
+
this.BLE_IsConnected = false;
|
|
390
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} connected: ${this.BLE_IsConnected}`);
|
|
404
391
|
}
|
|
405
392
|
};
|
|
406
393
|
// Wait
|
|
@@ -432,10 +419,12 @@ class BlindTilt {
|
|
|
432
419
|
this.statusCode(statusCode);
|
|
433
420
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Headers: ${JSON.stringify(headers)}`);
|
|
434
421
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} refreshStatus: ${JSON.stringify(deviceStatus)}`);
|
|
435
|
-
this.
|
|
436
|
-
this.
|
|
437
|
-
this.
|
|
438
|
-
this.
|
|
422
|
+
this.OpenAPI_CurrentPosition = deviceStatus.body.slidePosition;
|
|
423
|
+
this.OpenAPI_Direction = deviceStatus.body.direction;
|
|
424
|
+
this.OpenAPI_InMotion = deviceStatus.body.moving;
|
|
425
|
+
this.OpenAPI_CurrentAmbientLightLevel = deviceStatus.body.brightness;
|
|
426
|
+
this.OpenAPI_BatteryLevel = deviceStatus.body.battery;
|
|
427
|
+
this.OpenAPI_FirmwareRevision = deviceStatus.body.version;
|
|
439
428
|
this.openAPIparseStatus();
|
|
440
429
|
this.updateHomeKitCharacteristics();
|
|
441
430
|
}
|
|
@@ -715,29 +704,38 @@ class BlindTilt {
|
|
|
715
704
|
` updateCharacteristic CurrentAmbientLightLevel: ${this.CurrentAmbientLightLevel}`);
|
|
716
705
|
}
|
|
717
706
|
}
|
|
718
|
-
if (this.
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
this.mqttPublish('BatteryLevel', this.BatteryLevel);
|
|
725
|
-
}
|
|
726
|
-
this.accessory.context.BatteryLevel = this.BatteryLevel;
|
|
727
|
-
this.batteryService?.updateCharacteristic(this.platform.Characteristic.BatteryLevel, this.BatteryLevel);
|
|
728
|
-
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} updateCharacteristic BatteryLevel: ${this.BatteryLevel}`);
|
|
729
|
-
}
|
|
730
|
-
if (this.StatusLowBattery === undefined) {
|
|
731
|
-
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} StatusLowBattery: ${this.StatusLowBattery}`);
|
|
707
|
+
if (this.BatteryLevel === undefined) {
|
|
708
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} BatteryLevel: ${this.BatteryLevel}`);
|
|
709
|
+
}
|
|
710
|
+
else {
|
|
711
|
+
if (this.device.mqttURL) {
|
|
712
|
+
this.mqttPublish('BatteryLevel', this.BatteryLevel);
|
|
732
713
|
}
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
714
|
+
this.accessory.context.BatteryLevel = this.BatteryLevel;
|
|
715
|
+
this.batteryService?.updateCharacteristic(this.platform.Characteristic.BatteryLevel, this.BatteryLevel);
|
|
716
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} updateCharacteristic BatteryLevel: ${this.BatteryLevel}`);
|
|
717
|
+
}
|
|
718
|
+
if (this.StatusLowBattery === undefined) {
|
|
719
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} StatusLowBattery: ${this.StatusLowBattery}`);
|
|
720
|
+
}
|
|
721
|
+
else {
|
|
722
|
+
if (this.device.mqttURL) {
|
|
723
|
+
this.mqttPublish('StatusLowBattery', this.StatusLowBattery);
|
|
740
724
|
}
|
|
725
|
+
this.accessory.context.StatusLowBattery = this.StatusLowBattery;
|
|
726
|
+
this.batteryService?.updateCharacteristic(this.platform.Characteristic.StatusLowBattery, this.StatusLowBattery);
|
|
727
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} updateCharacteristic StatusLowBattery: ${this.StatusLowBattery}`);
|
|
728
|
+
}
|
|
729
|
+
// FirmwareRevision
|
|
730
|
+
if (this.OpenAPI_FirmwareRevision === undefined) {
|
|
731
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} FirmwareRevision: ${this.OpenAPI_FirmwareRevision}`);
|
|
732
|
+
}
|
|
733
|
+
else {
|
|
734
|
+
this.accessory.context.OpenAPI_FirmwareRevision = this.OpenAPI_FirmwareRevision;
|
|
735
|
+
this.accessory.getService(this.platform.Service.AccessoryInformation)
|
|
736
|
+
.updateCharacteristic(this.platform.Characteristic.FirmwareRevision, this.OpenAPI_FirmwareRevision);
|
|
737
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} `
|
|
738
|
+
+ `updateCharacteristic CurrentTemperature: ${this.OpenAPI_FirmwareRevision}`);
|
|
741
739
|
}
|
|
742
740
|
}
|
|
743
741
|
/*
|
|
@@ -773,7 +771,7 @@ class BlindTilt {
|
|
|
773
771
|
}
|
|
774
772
|
async stopScanning(switchbot) {
|
|
775
773
|
await switchbot.stopScan();
|
|
776
|
-
if (this.
|
|
774
|
+
if (this.BLE_IsConnected) {
|
|
777
775
|
await this.BLEparseStatus();
|
|
778
776
|
await this.updateHomeKitCharacteristics();
|
|
779
777
|
}
|