Skip to content

Commit

Permalink
Reformat
Browse files Browse the repository at this point in the history
  • Loading branch information
emilohman committed Oct 1, 2019
1 parent 97fac49 commit 610cc4f
Show file tree
Hide file tree
Showing 5 changed files with 157 additions and 157 deletions.
6 changes: 3 additions & 3 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ const Homey = require('homey');

class PlejdApp extends Homey.App {

async onInit() {
this.log('PlejdApp is running...');
}
async onInit() {
this.log('PlejdApp is running...');
}
}

module.exports = PlejdApp;
4 changes: 2 additions & 2 deletions app.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
"en": "Adds support for Plejd devices."
},
"tags": {
"en": [ "plejd, light, bluetooth, BLE, dimmer" ]
},
"en": [ "plejd, light, bluetooth, BLE, dimmer" ]
},
"category": [
"lights"
],
Expand Down
40 changes: 20 additions & 20 deletions drivers/plejd/device.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,17 @@ const Homey = require('homey');

class PlejdDevice extends Homey.Device {

onInit() {
const driver = this.getDriver();
this.log('Plejd Device (' + this.getName() + ') initialized');
this.log('id: ', this.getData().id);
this.log('plejdId: ', this.getData().plejdId);
this.log('count ', driver.getDevices().length);

this.registerCapabilityListener("onoff", async value => {
onInit() {
const driver = this.getDriver();
this.log('Plejd Device (' + this.getName() + ') initialized');
this.log('id: ', this.getData().id);
this.log('plejdId: ', this.getData().plejdId);
this.log('count ', driver.getDevices().length);

this.registerCapabilityListener("onoff", async value => {
this.log(`Power is set to: ${value} for id ${this.getData().plejdId}`);
if (value) {
return await driver.turnOn(parseInt(this.getData().plejdId));
return await driver.turnOn(parseInt(this.getData().plejdId));
} else {
return await driver.turnOff(parseInt(this.getData().plejdId));
}
Expand All @@ -30,28 +30,28 @@ class PlejdDevice extends Homey.Device {
return await driver.turnOn(this.getData().plejdId, brightness);
}
});
}
}

async onAdded() {
const driver = this.getDriver();
const driver = this.getDriver();

this.log('Adding device: ' + this.getName() + ' (' + this.getData().id + ')');
this.log('count ', driver.getDevices().length);
this.log('count ', driver.getDevices().length);

if (driver.getDevices().length === 1) {
await driver.connect();
}
if (driver.getDevices().length === 1) {
await driver.connect();
}
}

async onDeleted() {
const driver = this.getDriver();
const driver = this.getDriver();

this.log('device deleted: ' + this.getName());
this.log('count ', driver.getDevices().length);
this.log('count ', driver.getDevices().length);

if (driver.getDevices().length === 0) {
await driver.disconnect();
}
if (driver.getDevices().length === 0) {
await driver.disconnect();
}
}

}
Expand Down
Loading

0 comments on commit 610cc4f

Please sign in to comment.