Merge pull request #25 from icanos/dev

0.2.1 extended logging
This commit is contained in:
Marcus Westin 2020-01-08 17:04:23 +01:00 committed by GitHub
commit 7918165a65
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 11 deletions

View file

@ -163,7 +163,7 @@ class PlejdService extends EventEmitter {
}
scan() {
logger('scan()');
console.log('scan()');
if (this.state === STATE_SCANNING) {
console.log('error: already scanning, please wait.');
@ -178,7 +178,7 @@ class PlejdService extends EventEmitter {
this.state = STATE_IDLE;
const foundDeviceCount = Object.values(this.devices).length;
logger('scan completed, found ' + foundDeviceCount + ' device(s).');
console.log('scan completed, found ' + foundDeviceCount + ' device(s).');
if (foundDeviceCount == 0) {
console.log('warning: no devices found. will not do anything else.');
@ -243,12 +243,12 @@ class PlejdService extends EventEmitter {
}
reset() {
logger('reset()');
console.log('reset()');
this.state = STATE_IDLE;
}
disconnect() {
logger('disconnect()');
console.log('disconnect()');
if (this.state !== STATE_CONNECTED && this.state !== STATE_AUTHENTICATED) {
return;
}
@ -266,7 +266,7 @@ class PlejdService extends EventEmitter {
}
authenticate() {
logger('authenticate()');
console.log('authenticate()');
const self = this;
if (this.state !== STATE_CONNECTED) {
@ -323,7 +323,7 @@ class PlejdService extends EventEmitter {
}
startPing() {
logger('startPing()');
console.log('startPing()');
clearInterval(this.pingRef);
this.pingRef = setInterval(async () => {
@ -399,7 +399,7 @@ class PlejdService extends EventEmitter {
}
onDeviceConnected(err) {
logger('onDeviceConnected()');
console.log('onDeviceConnected()');
const self = this;
if (err) {
@ -500,17 +500,20 @@ class PlejdService extends EventEmitter {
}
onDeviceScanComplete() {
logger('onDeviceScanComplete()');
console.log('onDeviceScanComplete()');
console.log('trying to connect to the mesh network.');
this.connect();
}
onInterfaceStateChanged(state) {
logger('onInterfaceStateChanged(' + state + ')');
console.log('onInterfaceStateChanged(' + state + ')');
if (state === 'poweredOn') {
this.scan();
}
else {
noble.stopScanning();
}
}
onLastDataUpdated(data, isNotification) {
@ -556,7 +559,7 @@ class PlejdService extends EventEmitter {
}
wireEvents() {
logger('wireEvents()');
console.log('wireEvents()');
const self = this;
noble.on('stateChange', this.onInterfaceStateChanged.bind(self));

View file

@ -1,6 +1,6 @@
{
"name": "Plejd",
"version": "0.2.0",
"version": "0.2.1",
"slug": "plejd",
"description": "Adds support for the Swedish home automation devices from Plejd.",
"url": "https://github.com/icanos/hassio-plejd/",