Skip to content

Commit

Permalink
Classes
Browse files Browse the repository at this point in the history
  • Loading branch information
jghaanstra committed Mar 24, 2021
1 parent eb0216d commit 0cffb64
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 33 deletions.
1 change: 0 additions & 1 deletion drivers/shelly.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

const Homey = require('homey');
const Util = require('/lib/util.js');
const semver = require('semver');

class ShellyDevice extends Homey.Device {

Expand Down
34 changes: 2 additions & 32 deletions drivers/shelly1/device.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
'use strict';

const Homey = require('homey');
const Shelly = require('../shelly.js');
const Util = require('/lib/util.js');
const semver = require('semver');
const callbacks = [
Expand All @@ -17,7 +18,7 @@ const temp_callbacks = [
'longpush'
];

class Shelly1Device extends Homey.Device {
class Shelly1Device extends Shelly {

onInit() {
if (!this.util) this.util = new Util({homey: this.homey});
Expand Down Expand Up @@ -68,38 +69,7 @@ class Shelly1Device extends Homey.Device {
return;
}

async onDeleted() {
try {
clearInterval(this.pollingInterval);
const iconpath = "/userdata/" + this.getData().id +".svg";
await this.util.removeIcon(iconpath);
await this.homey.app.updateShellyCollection();
return;
} catch (error) {
this.log(error);
}
}

// HELPER FUNCTIONS
async bootSequence() {
try {
if (this.homey.settings.get('general_coap')) {
this.pollingInterval = setInterval(() => {
this.initialStateUpdate();
}, this.homey.settings.get('general_polling_frequency') * 1000 || 5000);
} else {
setTimeout(() => {
this.initialStateUpdate();
}, this.util.getRandomTimeout(10));
this.pollingInterval = setInterval(() => {
this.initialStateUpdate();
}, 60000);
}
} catch (error) {
this.log(error);
}
}

async initialStateUpdate() {
try {
let result = await this.util.sendCommand('/status', this.getSetting('address'), this.getSetting('username'), this.getSetting('password'));
Expand Down

0 comments on commit 0cffb64

Please sign in to comment.