Merge pull request #34 from icanos/dev
added error handling for writing to Plejd
This commit is contained in:
commit
f38c7ebce9
3 changed files with 17 additions and 7 deletions
10
plejd/ble.js
10
plejd/ble.js
|
|
@ -315,6 +315,7 @@ class PlejdService extends EventEmitter {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
const encryptedData = this._encryptDecrypt(this.cryptoKey, this.deviceAddress, data);
|
const encryptedData = this._encryptDecrypt(this.cryptoKey, this.deviceAddress, data);
|
||||||
this.characteristics.data.write(encryptedData, false);
|
this.characteristics.data.write(encryptedData, false);
|
||||||
|
|
||||||
|
|
@ -323,6 +324,15 @@ class PlejdService extends EventEmitter {
|
||||||
this.characteristics.data.write(this._encryptDecrypt(this.cryptoKey, this.deviceAddress, writeData), false);
|
this.characteristics.data.write(this._encryptDecrypt(this.cryptoKey, this.deviceAddress, writeData), false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
catch (error) {
|
||||||
|
console.log('error: writing to plejd: ' + error);
|
||||||
|
console.log('will reconnect and try again.');
|
||||||
|
this.writeQueue.push(data);
|
||||||
|
|
||||||
|
this.disconnect();
|
||||||
|
this.connect();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
onAuthenticated() {
|
onAuthenticated() {
|
||||||
// Start ping
|
// Start ping
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "Plejd",
|
"name": "Plejd",
|
||||||
"version": "0.2.3",
|
"version": "0.2.4",
|
||||||
"slug": "plejd",
|
"slug": "plejd",
|
||||||
"description": "Adds support for the Swedish home automation devices from Plejd.",
|
"description": "Adds support for the Swedish home automation devices from Plejd.",
|
||||||
"url": "https://github.com/icanos/hassio-plejd/",
|
"url": "https://github.com/icanos/hassio-plejd/",
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ const mqtt = require('./mqtt');
|
||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
const PlejdService = require('./ble');
|
const PlejdService = require('./ble');
|
||||||
|
|
||||||
const version = "0.2.3";
|
const version = "0.2.4";
|
||||||
|
|
||||||
async function main() {
|
async function main() {
|
||||||
console.log('starting Plejd add-on v. ' + version);
|
console.log('starting Plejd add-on v. ' + version);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue