diff --git a/README.md b/README.md index 9ef43c8..328c0ea 100644 --- a/README.md +++ b/README.md @@ -59,6 +59,11 @@ It is possible to control the extensions GPIO 1, GPIO 2, OUT 1 and OUT 2 of the ### Work in progress * Add timePickers to Admin UI for rest times as soon as they work properly +### 1.3.2 (2023-10-04) + +* (grizzelbee) Fix: Switching of extensions works now +* (grizzelbee) Fix: Fixed false error message when switching extensions + ### 1.3.1 (2023-10-02) * (grizzelbee) Chg: removed unnecessary Info log entries diff --git a/io-package.json b/io-package.json index bc2729b..ee67505 100644 --- a/io-package.json +++ b/io-package.json @@ -1,8 +1,21 @@ { "common": { "name": "robonect", - "version": "1.3.1", + "version": "1.3.2", "news": { + "1.3.2": { + "en": "Fix: Switching of extensions works now\nFix: Fixed false error message when switching extensions", + "de": "Fix: Das Umschalten von Erweiterungen funktioniert jetzt\nFix: Falsche Fehlermeldung beim Umschalten von Erweiterungen behoben", + "ru": "Исправлено: переключение расширений теперь работает\nИсправлено: исправлено ложное сообщение об ошибке при переключении расширений.", + "pt": "Correção: a troca de extensões funciona agora\n Correção: corrigida a falsa mensagem de erro ao trocar de extensões", + "nl": "Fix: wisselen van extensie werkt nu\nFix: foutieve foutmelding opgelost bij het wisselen van extensie", + "fr": "Correctif : le changement d'extension fonctionne maintenant\nCorrection : correction d'un faux message d'erreur lors du changement d'extension", + "it": "Correzione: il cambio di estensione ora funziona\nCorrezione: corretto il messaggio di errore falso quando si cambia estensione", + "es": "Solución: el cambio de extensiones funciona ahora \n Solución: se corrigió un mensaje de error falso al cambiar de extensión", + "pl": "Poprawka: przełączanie rozszerzeń działa teraz \n Poprawka: naprawiono fałszywy komunikat o błędzie podczas przełączania rozszerzeń", + "uk": "Виправлення: перемикання розширень працює зараз\nВиправлення: виправлено помилкове повідомлення про помилку під час перемикання розширень", + "zh-cn": "修复:现在可以切换扩展程序\n修复:修复切换扩展程序时出现的错误消息" + }, "1.3.1": { "en": "Chg: removed unnecessary Info log entries", "de": "Änderung: unnötige Info-Log-Einträge entfernt", diff --git a/main.js b/main.js index f3da7c7..23af2e1 100644 --- a/main.js +++ b/main.js @@ -106,7 +106,7 @@ class Robonect extends utils.Adapter { // this.ps_host = this.config.pushServiceIp; this.ps_port = this.config.pushServicePort; - this.apiUrl = `http://${this.robonectIp}/api/json?&cmd=`; + this.apiUrl = `http://${this.robonectIp}/api/json?cmd=`; if (isNaN(this.statusInterval) || this.statusInterval < 1) { this.statusInterval = 60; @@ -691,29 +691,33 @@ class Robonect extends utils.Adapter { * @param {*} status */ updateExtensionStatus(ext, status) { - let paramStatus; - if (status === true) { - paramStatus = 1; + const adapter = this; + const PARAMS = {cmd:'ext'}; + if (status) { + PARAMS[ext]=1; } else { - paramStatus = 0; + PARAMS[ext]=0; } - const apiUrl =`${this.apiUrl}ext&${ext}=${paramStatus}`; - const adapter = this; - this.log.debug('API call [' + apiUrl + '] started'); - axios.post(adapter.apiUrl, {}, {auth: {username: this.username, password: this.password}}) + axios.interceptors.request.use(function(config){ + adapter.log.debug(JSON.stringify(config));return config; + }, function(error) { + return Promise.reject(error); + }); + axios.get(`http://${this.robonectIp}/api/json`, {auth: {username: this.username, password: this.password}, + params:PARAMS }) .then((response)=>{ try { if (response.data.successful === true) { adapter.setState('extension.gpio1.inverted', { val: response.data['ext']['gpio1']['inverted'], ack: true }); - adapter.setState('extension.gpio1.status', { val: response.data['ext']['gpio1']['status'], ack: true }); + adapter.setState('extension.gpio1.status', { val: response.data['ext']['gpio1']['status'], ack: true }); adapter.setState('extension.gpio2.inverted', { val: response.data['ext']['gpio2']['inverted'], ack: true }); - adapter.setState('extension.gpio2.status', { val: response.data['ext']['gpio2']['status'], ack: true }); - adapter.setState('extension.out1.inverted', { val: response.data['ext']['out1']['inverted'], ack: true }); - adapter.setState('extension.out1.status', { val: response.data['ext']['out1']['status'], ack: true }); - adapter.setState('extension.out2.inverted', { val: response.data['ext']['out2']['inverted'], ack: true }); - adapter.setState('extension.out2.status', { val: response.data['ext']['out2']['status'], ack: true }); + adapter.setState('extension.gpio2.status', { val: response.data['ext']['gpio2']['status'], ack: true }); + adapter.setState('extension.out1.inverted', { val: response.data['ext']['out1']['inverted'], ack: true }); + adapter.setState('extension.out1.status', { val: response.data['ext']['out1']['status'], ack: true }); + adapter.setState('extension.out2.inverted', { val: response.data['ext']['out2']['inverted'], ack: true }); + adapter.setState('extension.out2.status', { val: response.data['ext']['out2']['status'], ack: true }); this.log.debug(`updateExtensionStatus: Response: ${JSON.stringify(response.data)}`); - if (response.data['ext'][ext]['status'] === paramStatus) { + if (response.data['ext'][ext]['status'] === status) { adapter.log.info(ext + ' set to ' + status); } else { this.log.error(ext + ' could not be set to ' + status + '. Is the extension mode set to API?'); @@ -725,12 +729,10 @@ class Robonect extends utils.Adapter { catch (errorMessage) { this.doErrorHandling(errorMessage); } - }) .catch((err)=>{ adapter.log.error(`updateExtensionStatus: ${err}`); }); - this.log.debug('API call ' + apiUrl + ' done'); } /** diff --git a/package.json b/package.json index cbe2164..be4ee08 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "iobroker.robonect", - "version": "1.3.1", + "version": "1.3.2", "description": "Robonect HX for lawn mower robots from Husquarna, Flymo, McCulloch and Gardena", "keywords": [ "ioBroker",