reconnect and version up

This commit is contained in:
Marcus Westin 2020-01-20 12:28:02 +00:00
parent 667beaa11f
commit ce84a296ab
3 changed files with 11 additions and 9 deletions

View file

@ -109,7 +109,6 @@ class PlejdService extends EventEmitter {
} }
this.objectManager.on('InterfacesAdded', this.onInterfacesAdded.bind(this)); this.objectManager.on('InterfacesAdded', this.onInterfacesAdded.bind(this));
this.objectManager.on('InterfacesRemoved', this.onInterfacesRemoved.bind(this));
this.adapter.SetDiscoveryFilter({ this.adapter.SetDiscoveryFilter({
'UUIDs': new dbus.Variant('as', [PLEJD_SERVICE]), 'UUIDs': new dbus.Variant('as', [PLEJD_SERVICE]),
@ -200,10 +199,6 @@ class PlejdService extends EventEmitter {
} }
} }
async onInterfacesRemoved(path, interfaces) {
const [adapter, dev, service, characteristic] = path.split('/').slice(3);
}
updateSettings(settings) { updateSettings(settings) {
if (settings.debug) { if (settings.debug) {
debug = 'console'; debug = 'console';

View file

@ -1,6 +1,6 @@
{ {
"name": "Plejd", "name": "Plejd",
"version": "0.2.8", "version": "0.3.0",
"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/",

View file

@ -3,7 +3,7 @@ const mqtt = require('./mqtt');
const fs = require('fs'); const fs = require('fs');
const PlejdService = require('./ble.bluez'); const PlejdService = require('./ble.bluez');
const version = "0.2.8"; const version = "0.3.0";
async function main() { async function main() {
console.log('starting Plejd add-on v. ' + version); console.log('starting Plejd add-on v. ' + version);
@ -15,7 +15,7 @@ async function main() {
const client = new mqtt.MqttClient(config.mqttBroker, config.mqttUsername, config.mqttPassword); const client = new mqtt.MqttClient(config.mqttBroker, config.mqttUsername, config.mqttPassword);
plejdApi.once('loggedIn', () => { plejdApi.once('loggedIn', () => {
plejdApi.getCryptoKey();//(cryptoKey) => { plejdApi.getCryptoKey();
plejdApi.on('ready', (cryptoKey) => { plejdApi.on('ready', (cryptoKey) => {
const devices = plejdApi.getDevices(); const devices = plejdApi.getDevices();
@ -28,8 +28,15 @@ async function main() {
// init the BLE interface // init the BLE interface
const plejd = new PlejdService(cryptoKey, true); const plejd = new PlejdService(cryptoKey, true);
plejd.on('connectFailed', () => {
setTimeout(() => {
console.log('plejd-ble: were unable to connect, will retry connection in 10 seconds.');
plejd.init();
}, 10000);
});
plejd.init(); plejd.init();
plejd.on('authenticated', () => { plejd.on('authenticated', () => {
console.log('plejd: connected via bluetooth.'); console.log('plejd: connected via bluetooth.');
}); });