Skip to content

Commit

Permalink
add restartinterval function
Browse files Browse the repository at this point in the history
  • Loading branch information
josephdadams committed Apr 27, 2022
1 parent 175d82c commit fc7e1e6
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "tplink-taposmartplug",
"version": "1.0.1",
"version": "1.0.2",
"api_version": "1.0",
"keywords": [
"plug",
Expand Down
10 changes: 9 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ instance.prototype.PLUGINFO = {
mac: '',

hw_id: '',
hw_id: '',
fw_id: '',
oem_id: '',

on_time: '',
Expand Down Expand Up @@ -129,6 +129,13 @@ instance.prototype.stopInterval = function () {
}
};

instance.prototype.restartInterval = function() {
let self = this;

self.status(self.STATUS_OK);
self.setupInterval();
};

instance.prototype.handleError = function(err) {
let self = this;

Expand All @@ -146,6 +153,7 @@ instance.prototype.handleError = function(err) {
error = 'Unable to communicate with Device. Connection refused. Is this the right IP address? Is it still online?';
self.log('error', error);
self.status(self.STATUS_ERROR);
setTimeout(self.restartInterval.bind(self), 30000); //restart interval after 30 seconds
break;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/variables.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ module.exports = {
self.setVariable('oem_id', self.PLUGINFO.oem_id);

self.setVariable('on_time', self.PLUGINFO.on_time);
self.setVariable('overheated', (self.PLUGINFO.overheated == true ? 'On' : 'Off'));
self.setVariable('overheated', (self.PLUGINFO.overheated == true ? 'Yes' : 'No'));
self.setVariable('nickname', self.PLUGINFO.nickname);
self.setVariable('location', self.PLUGINFO.location);

Expand Down

0 comments on commit fc7e1e6

Please sign in to comment.