@switchbot/homebridge-switchbot-ble
Advanced tools
Comparing version 1.2.2 to 1.2.3
@@ -11,10 +11,19 @@ "use strict"; | ||
this.scanDuration = scanDuration; | ||
this.switchService = new hap.Service.Switch(name); | ||
this.switchService.getCharacteristic(hap.Characteristic.On) | ||
this.botService = new hap.Service.Switch(name); | ||
this.botService.getCharacteristic(hap.Characteristic.On) | ||
.on("get" /* GET */, (callback) => { | ||
log.info("Current state of the switch was returned: " + (this.switchOn ? "ON" : "OFF")); | ||
log.info("Current state of Bot was returned: " + (this.switchOn ? "ON" : "OFF")); | ||
callback(undefined, this.switchOn); | ||
}) | ||
.on("set" /* SET */, (value, callback) => { | ||
var _a; | ||
const targetState = value; | ||
clearTimeout(this.runTimer); | ||
if (targetState === this.switchOn) { | ||
log.info("Target state of Bot has not changed: " + (this.switchOn ? "ON" : "OFF")); | ||
(_a = this.botService) === null || _a === void 0 ? void 0 : _a.getCharacteristic(hap.Characteristic.On).updateValue(this.switchOn); | ||
callback(); | ||
} | ||
// Target state has been changed. | ||
log.info("Target state of Bot setting: " + (targetState ? "ON" : "OFF")); | ||
const SwitchBot = require('node-switchbot'); | ||
@@ -47,13 +56,26 @@ const switchbot = new SwitchBot(); | ||
}; | ||
log.info('Pressing the switch...'); | ||
return targetDevice.press(); | ||
log.info('Bot is running...'); | ||
if (targetState) { | ||
return targetDevice.turnOn(); | ||
} | ||
else { | ||
return targetDevice.turnOff(); | ||
} | ||
} | ||
}).then(() => { | ||
log.info('Done.'); | ||
this.switchOn = value; | ||
log.info("Switch state has been set to: " + (this.switchOn ? "ON" : "OFF")); | ||
this.switchOn = targetState; | ||
this.runTimer = setTimeout(() => { | ||
var _a; | ||
(_a = this.botService) === null || _a === void 0 ? void 0 : _a.getCharacteristic(hap.Characteristic.On).updateValue(this.switchOn); | ||
}, 500); | ||
log.info("Bot state has been set to: " + (this.switchOn ? "ON" : "OFF")); | ||
callback(); | ||
}).catch((error) => { | ||
log.info("Switch state setting failed: " + (value ? "ON" : "OFF")); | ||
log.error(error); | ||
this.runTimer = setTimeout(() => { | ||
var _a; | ||
(_a = this.botService) === null || _a === void 0 ? void 0 : _a.getCharacteristic(hap.Characteristic.On).updateValue(this.switchOn); | ||
}, 500); | ||
log.info("Bot state failed to be set to: " + (targetState ? "ON" : "OFF")); | ||
callback(); | ||
@@ -66,3 +88,3 @@ }); | ||
.setCharacteristic(hap.Characteristic.SerialNumber, this.bleMac); | ||
log.info("Example switch '%s' created!", name); | ||
log.info("Bot '%s' created!", name); | ||
} | ||
@@ -83,3 +105,3 @@ /* | ||
this.informationService, | ||
this.switchService, | ||
this.botService, | ||
]; | ||
@@ -86,0 +108,0 @@ } |
@@ -19,3 +19,3 @@ "use strict"; | ||
.on("get" /* GET */, (callback) => { | ||
log.info("Current position of the Curtain was returned: " + this.currentPosition + "%"); | ||
log.info("Current position of Curtain was returned: " + this.currentPosition + "%"); | ||
callback(undefined, this.currentPosition); | ||
@@ -25,3 +25,3 @@ }); | ||
.on("get" /* GET */, (callback) => { | ||
log.info("Target position of the Curtain was returned: " + this.targetPosition + "%"); | ||
log.info("Target position of Curtain was returned: " + this.targetPosition + "%"); | ||
callback(undefined, this.targetPosition); | ||
@@ -32,3 +32,3 @@ }) | ||
this.targetPosition = value; | ||
log.info("Target position of the Curtain setting: " + this.targetPosition + "%"); | ||
log.info("Target position of Curtain setting: " + this.targetPosition + "%"); | ||
clearTimeout(this.moveTimer); | ||
@@ -78,6 +78,6 @@ if (this.targetPosition > this.currentPosition) { | ||
}; | ||
log.info('The Curtain is moving...'); | ||
log.info('Curtain is moving...'); | ||
/**opend - 0% in HomeKit, 100% in Curtain device. | ||
* closed - 100% in HomeKit, 0% in Curtain device. | ||
* To keep the status synchronized, convert the percentage of homekit to the percentage of curtain. | ||
* To keep the status synchronized, convert the percentage of homekit to the percentage of Curtain. | ||
*/ | ||
@@ -96,3 +96,3 @@ let covertToDevicePosition = 0; | ||
log.info('Done.'); | ||
log.info("Target position of the Curtain has been set to: " + this.targetPosition + "%"); | ||
log.info("Target position of Curtain has been set to: " + this.targetPosition + "%"); | ||
this.moveTimer = setTimeout(() => { | ||
@@ -118,3 +118,3 @@ var _a, _b; | ||
}, 1000); | ||
log.info("Target position of the Curtain setting failed!"); | ||
log.info("Target position of Curtain failed to be set to: " + this.targetPosition + "%"); | ||
callback(); | ||
@@ -126,3 +126,3 @@ }); | ||
.on("get" /* GET */, (callback) => { | ||
log.info("The position state of the Curtain was returned: " + this.positionState); | ||
log.info("The position state of Curtain was returned: " + this.positionState); | ||
callback(undefined, this.positionState); | ||
@@ -134,3 +134,3 @@ }); | ||
.setCharacteristic(hap.Characteristic.SerialNumber, this.bleMac); | ||
log.info("Example switch '%s' created!", name); | ||
log.info("Curtain '%s' created!", name); | ||
} | ||
@@ -137,0 +137,0 @@ /* |
@@ -34,3 +34,3 @@ "use strict"; | ||
this.config = config; | ||
log.info("Example platform finished initializing!"); | ||
log.info("SwitchBot platform finished initializing!"); | ||
} | ||
@@ -37,0 +37,0 @@ /* |
{ | ||
"name": "@switchbot/homebridge-switchbot-ble", | ||
"version": "1.2.2", | ||
"version": "1.2.3", | ||
"description": "Homebridge integration for SwitchBot BLE series products", | ||
@@ -34,8 +34,8 @@ "license": "ISC", | ||
], | ||
"author": "SwitchBot", | ||
"author": "SwitchBot <support@wondertechlabs.com> (https://github.com/SwitchBot)", | ||
"devDependencies": { | ||
"@types/node": "14.14.8", | ||
"@types/node": "14.14.10", | ||
"homebridge": "^1.1.6", | ||
"rimraf": "^3.0.2", | ||
"typescript": "^4.0.5" | ||
"typescript": "^4.1.2" | ||
}, | ||
@@ -42,0 +42,0 @@ "dependencies": { |
@@ -10,9 +10,9 @@ <span align="center"> | ||
The @switchbot/homebridge-switchbot-bleswitchbot is a nodejs module , and also a homebridge plug-in that directly controls SwitchBot products via BLE. | ||
The @switchbot/homebridge-switchbot-ble is a nodejs module , and also a homebridge plug-in that directly controls SwitchBot products via BLE. | ||
Now supports: | ||
* [SwitchBot (Bot)](https://www.switch-bot.com/products/switchbot-bot) | ||
* [SwitchBot Curtain(Curtain)](https://www.switch-bot.com/products/switchbot-curtain) | ||
* [SwitchBot Curtain (Curtain)](https://www.switch-bot.com/products/switchbot-curtain) | ||
* [SwitchBot Thermometer & Hygrometer (Meter)](https://www.switch-bot.com/products/switchbot-meter) | ||
## Installation | ||
@@ -100,2 +100,5 @@ ### Installing bluetooth libraries | ||
## Release Note | ||
* v1.2.3 (2020-11-30) | ||
* Fixed the incorrect state of Bot in Home APP when control fails. | ||
* Modify log messages. (Thanks to [@dnicolson](https://github.com/SwitchBot/homebridge-switchbot-ble/pull/15)) | ||
* v1.2.2 (2020-11-19) | ||
@@ -102,0 +105,0 @@ * Fixed Curtain state will not be updated in the Home APP. |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No bug tracker
MaintenancePackage does not have a linked bug tracker in package.json.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No bug tracker
MaintenancePackage does not have a linked bug tracker in package.json.
Found 1 instance in 1 package
42229
420
119