Skip to content

Commit

Permalink
(simatec) Cloud URL Check added
Browse files Browse the repository at this point in the history
  • Loading branch information
simatec committed Jan 2, 2024
1 parent 20eb137 commit d86fe02
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 13 deletions.
18 changes: 7 additions & 11 deletions admin/jsonConfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"apiToken": {
"newLine": true,
"repeat": false,
"visible": false,
"visible": true,
"hidden": "data.localConnection && data.expertSettings",
"disabled": "data.localConnection",
"sm": 12,
Expand All @@ -18,8 +18,6 @@
},
"serialNumber": {
"newLine": false,
"repeat": false,
"visible": false,
"hidden": "data.localConnection && data.expertSettings",
"disabled": "data.localConnection'",
"sm": 12,
Expand All @@ -44,8 +42,6 @@
},
"hostIP": {
"newLine": true,
"repeat": false,
"visible": false,
"hidden": "!data.localConnection || !data.expertSettings",
"disabled": "!data.localConnection",
"sm": 12,
Expand All @@ -58,7 +54,7 @@
"passwordWifi": {
"newLine": false,
"repeat": false,
"visible": false,
"visible": true,
"hidden": "!data.localConnection || !data.expertSettings",
"disabled": "!data.localConnection",
"sm": 12,
Expand Down Expand Up @@ -196,14 +192,14 @@
"lg": 8
},
"_helpLink": {
"newLine": true,
"hidden": "!data.expertSettings",
"type": "staticLink",
"variant": "outlined",
"color": "primary",
"hidden": "!data.expertSettings",
"button": true,
"variant": "contained",
"icon": "info",
"label": "Readme Expert Settings",
"href": "https://github.com/simatec/ioBroker.solax/blob/master/README.md#experteneinstellungen"
"href": "https://github.com/simatec/ioBroker.solax/blob/master/README.md#experteneinstellungen",
"newLine": true
}
}
}
34 changes: 32 additions & 2 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -224,13 +224,43 @@ async function sunPos() {
}

/*************************** Cloud Mode **********************/
async function validateURL() {
return new Promise(async (resolve, reject) => {

const cloudURL = {
0: 'https://www.eu.solaxcloud.com:9443/proxy/api/getRealtimeInfo.do',
1: 'https://www.eu.solaxcloud.com/proxyApp/proxy/api/getRealtimeInfo.do'
}

for (const url in cloudURL) {
let available;

try {
// @ts-ignore
available = await axios({
method: 'get',
url: cloudURL[url],
validateStatus: () => true
});
} catch (err) {
adapter.log.warn('Solax Cloud is not available: ' + err);
reject(err);
}
if (available && available.status) {
adapter.log.debug('Solax Cloud is available ... Status: ' + available.status);
resolve(cloudURL[url]);
break;
}
}
});
}

let num = 0;

async function requestAPI() {
return new Promise(async (resolve) => {
const solaxURL = (`https://www.eu.solaxcloud.com:9443/proxy/api/getRealtimeInfo.do?tokenId=${adapter.config.apiToken}&sn=${adapter.config.serialNumber}`);
//const solaxURL = (`https://www.eu.solaxcloud.com/proxyApp/proxy/api/getRealtimeInfo.do?tokenId=${adapter.config.apiToken}&sn=${adapter.config.serialNumber}`);
const url = await validateURL();
const solaxURL = (`${url}?tokenId=${adapter.config.apiToken}&sn=${adapter.config.serialNumber}`);

try {
// @ts-ignore
Expand Down

0 comments on commit d86fe02

Please sign in to comment.