Skip to content

Commit

Permalink
Merge pull request #31 from Grizzelbee/development
Browse files Browse the repository at this point in the history
v1.3.2
  • Loading branch information
Grizzelbee authored Oct 4, 2023
2 parents 7cb27a7 + f7adb45 commit a1e5eb3
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 20 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
15 changes: 14 additions & 1 deletion io-package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
38 changes: 20 additions & 18 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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?');
Expand All @@ -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');
}

/**
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down

0 comments on commit a1e5eb3

Please sign in to comment.