added more logging and created new version
This commit is contained in:
parent
5ce48d1820
commit
a387aa0bf4
2 changed files with 14 additions and 11 deletions
23
plejd/ble.js
23
plejd/ble.js
|
|
@ -163,7 +163,7 @@ class PlejdService extends EventEmitter {
|
||||||
}
|
}
|
||||||
|
|
||||||
scan() {
|
scan() {
|
||||||
logger('scan()');
|
console.log('scan()');
|
||||||
|
|
||||||
if (this.state === STATE_SCANNING) {
|
if (this.state === STATE_SCANNING) {
|
||||||
console.log('error: already scanning, please wait.');
|
console.log('error: already scanning, please wait.');
|
||||||
|
|
@ -178,7 +178,7 @@ class PlejdService extends EventEmitter {
|
||||||
this.state = STATE_IDLE;
|
this.state = STATE_IDLE;
|
||||||
|
|
||||||
const foundDeviceCount = Object.values(this.devices).length;
|
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) {
|
if (foundDeviceCount == 0) {
|
||||||
console.log('warning: no devices found. will not do anything else.');
|
console.log('warning: no devices found. will not do anything else.');
|
||||||
|
|
@ -243,12 +243,12 @@ class PlejdService extends EventEmitter {
|
||||||
}
|
}
|
||||||
|
|
||||||
reset() {
|
reset() {
|
||||||
logger('reset()');
|
console.log('reset()');
|
||||||
this.state = STATE_IDLE;
|
this.state = STATE_IDLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
disconnect() {
|
disconnect() {
|
||||||
logger('disconnect()');
|
console.log('disconnect()');
|
||||||
if (this.state !== STATE_CONNECTED && this.state !== STATE_AUTHENTICATED) {
|
if (this.state !== STATE_CONNECTED && this.state !== STATE_AUTHENTICATED) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -266,7 +266,7 @@ class PlejdService extends EventEmitter {
|
||||||
}
|
}
|
||||||
|
|
||||||
authenticate() {
|
authenticate() {
|
||||||
logger('authenticate()');
|
console.log('authenticate()');
|
||||||
const self = this;
|
const self = this;
|
||||||
|
|
||||||
if (this.state !== STATE_CONNECTED) {
|
if (this.state !== STATE_CONNECTED) {
|
||||||
|
|
@ -323,7 +323,7 @@ class PlejdService extends EventEmitter {
|
||||||
}
|
}
|
||||||
|
|
||||||
startPing() {
|
startPing() {
|
||||||
logger('startPing()');
|
console.log('startPing()');
|
||||||
clearInterval(this.pingRef);
|
clearInterval(this.pingRef);
|
||||||
|
|
||||||
this.pingRef = setInterval(async () => {
|
this.pingRef = setInterval(async () => {
|
||||||
|
|
@ -399,7 +399,7 @@ class PlejdService extends EventEmitter {
|
||||||
}
|
}
|
||||||
|
|
||||||
onDeviceConnected(err) {
|
onDeviceConnected(err) {
|
||||||
logger('onDeviceConnected()');
|
console.log('onDeviceConnected()');
|
||||||
const self = this;
|
const self = this;
|
||||||
|
|
||||||
if (err) {
|
if (err) {
|
||||||
|
|
@ -500,17 +500,20 @@ class PlejdService extends EventEmitter {
|
||||||
}
|
}
|
||||||
|
|
||||||
onDeviceScanComplete() {
|
onDeviceScanComplete() {
|
||||||
logger('onDeviceScanComplete()');
|
console.log('onDeviceScanComplete()');
|
||||||
console.log('trying to connect to the mesh network.');
|
console.log('trying to connect to the mesh network.');
|
||||||
this.connect();
|
this.connect();
|
||||||
}
|
}
|
||||||
|
|
||||||
onInterfaceStateChanged(state) {
|
onInterfaceStateChanged(state) {
|
||||||
logger('onInterfaceStateChanged(' + state + ')');
|
console.log('onInterfaceStateChanged(' + state + ')');
|
||||||
|
|
||||||
if (state === 'poweredOn') {
|
if (state === 'poweredOn') {
|
||||||
this.scan();
|
this.scan();
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
noble.stopScanning();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
onLastDataUpdated(data, isNotification) {
|
onLastDataUpdated(data, isNotification) {
|
||||||
|
|
@ -556,7 +559,7 @@ class PlejdService extends EventEmitter {
|
||||||
}
|
}
|
||||||
|
|
||||||
wireEvents() {
|
wireEvents() {
|
||||||
logger('wireEvents()');
|
console.log('wireEvents()');
|
||||||
const self = this;
|
const self = this;
|
||||||
|
|
||||||
noble.on('stateChange', this.onInterfaceStateChanged.bind(self));
|
noble.on('stateChange', this.onInterfaceStateChanged.bind(self));
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "Plejd",
|
"name": "Plejd",
|
||||||
"version": "0.2.0",
|
"version": "0.2.1",
|
||||||
"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/",
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue