Skip to content

Commit

Permalink
* (mcm1957) required node 16 due to adapter-core 3.x.x
Browse files Browse the repository at this point in the history
* (bluefox) removed deprecated package - `request`
  • Loading branch information
GermanBluefox committed Sep 4, 2023
1 parent 52c1b8a commit 14ee7a4
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 26 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,10 @@ with the ioBroker CLI. You can change the port via `iob set hm-rega.<instance> -
Placeholder for the next version (at the beginning of the line):
### **WORK IN PROGRESS**
-->
### **WORK IN PROGRESS**
* (mcm1957) required node 16 due to adapter-core 3.x.x
* (bluefox) removed deprecated package - `request`
*
### 3.0.47 (2023-08-08)
* (bluefox) Updated packages

Expand Down
42 changes: 21 additions & 21 deletions lib/rega.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const http = require('http');
const https = require('https');
const xml2js = require('xml2js');
const iconv = require('iconv-lite');
const request = require('request');
const axios = require('axios');
const parser = new xml2js.Parser({ explicitArray: false });

class Rega {
Expand Down Expand Up @@ -42,31 +42,31 @@ class Rega {
this.pendingRequests = [];

if (this.options.ccuIp) {
// if specific webinterface port provided use it, else use default https/http
request(
{
url: `${this.protocol + this.options.ccuIp}:${this.options.webinterfacePort}/ise/checkrega.cgi`,
strictSSL: false
},
(error, response, body) => {
if (!error && response.statusCode === 200) {
if (body === 'OK') {
this.connected = true;
this.options.ready();
} else {
this.connected = false;
this.options.ready('ReGaHSS down');
// try again in X seconds
setTimeout(() => this.init(), this.options.reconnectionInterval * 1000);
}
const httpsAgent = new https.Agent({
rejectUnauthorized: false
});

// if a specific web-interface port provided, use it, else use default https/http
axios(`${this.protocol + this.options.ccuIp}:${this.options.webinterfacePort}/ise/checkrega.cgi`, {
httpsAgent
})
.then(response => {
if (response.data === 'OK') {
this.connected = true;
this.options.ready();
} else {
this.connected = false;
this.options.ready('CCU unreachable');
this.options.ready('ReGaHSS down');
// try again in X seconds
setTimeout(() => this.init(), this.options.reconnectionInterval * 1000);
}
}
);
})
.catch(() => {
this.connected = false;
this.options.ready('CCU unreachable');
// try again in X seconds
setTimeout(() => this.init(), this.options.reconnectionInterval * 1000);
});
} else {
this.options.ready('No IP defined!');
}
Expand Down
9 changes: 4 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,22 +27,21 @@
"dependencies": {
"@iobroker/adapter-core": "^3.0.3",
"iconv-lite": "^0.6.3",
"request": "^2.88.2",
"axios": "^1.5.0",
"xml2js": "^0.6.2"
},
"devDependencies": {
"@alcalzone/release-script": "^3.6.0",
"@alcalzone/release-script-plugin-iobroker": "^3.6.0",
"@alcalzone/release-script-plugin-license": "^3.5.9",
"@iobroker/testing": "^4.1.0",
"axios": "^1.4.0",
"chai": "^4.3.7",
"eslint": "^8.46.0",
"chai": "^4.3.8",
"eslint": "^8.48.0",
"eslint-config-prettier": "^9.0.0",
"eslint-plugin-prettier": "^5.0.0",
"gulp": "^4.0.2",
"mocha": "^10.2.0",
"prettier": "^3.0.1"
"prettier": "^3.0.3"
},
"bugs": {
"url": "https://github.com/ioBroker/ioBroker.hm-rega/issues"
Expand Down

0 comments on commit 14ee7a4

Please sign in to comment.