diff --git a/admin/jsonConfig.json b/admin/jsonConfig.json index 64bdb87..c1ccb9c 100644 --- a/admin/jsonConfig.json +++ b/admin/jsonConfig.json @@ -5,7 +5,7 @@ "apiToken": { "newLine": true, "repeat": false, - "visible": false, + "visible": true, "hidden": "data.localConnection && data.expertSettings", "disabled": "data.localConnection", "sm": 12, @@ -18,8 +18,6 @@ }, "serialNumber": { "newLine": false, - "repeat": false, - "visible": false, "hidden": "data.localConnection && data.expertSettings", "disabled": "data.localConnection'", "sm": 12, @@ -44,8 +42,6 @@ }, "hostIP": { "newLine": true, - "repeat": false, - "visible": false, "hidden": "!data.localConnection || !data.expertSettings", "disabled": "!data.localConnection", "sm": 12, @@ -58,7 +54,7 @@ "passwordWifi": { "newLine": false, "repeat": false, - "visible": false, + "visible": true, "hidden": "!data.localConnection || !data.expertSettings", "disabled": "!data.localConnection", "sm": 12, @@ -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 } } } \ No newline at end of file diff --git a/main.js b/main.js index dbb1a59..24017a2 100644 --- a/main.js +++ b/main.js @@ -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