ioBroker / ioBroker.text2command

Convert text into commands
MIT License
29 stars 16 forks source link

Response text2command #39

Closed mariomm closed 3 years ago

mariomm commented 5 years ago

Ich nutze iobroker mit dem telegram, simple api, javascript und text2command Adpater. Ziel ist es im Moment per Restcall text2command anzusteuern und somit einen Befehl auszulösen. Das Ganze funktioniert auch Prima. Allerdings scheitere ich an der Response des text2command Adapters. Je nach Art der Regel bekomme ich keine Respone in den Datenpunkt: javascript.0.textProcessor bzw. es steht die task.command drin. Im Log steht allerdings die korrekte Antwort Der T2C Ausgabe der jeweiligen aufgerufenen Regel. Auch andere Datenpunkte im Objektbaum enthalten nicht diese Response. Sie ist nur im iobroker log zu finden.

In text2command ist ein Regel hinterlegt: Wie heisst du? mit dem Trigger du Ich rufe das Ganze z.B. so auf: http://iobroker:8087/set/javascript.0.t ... r?value=du Als Antwort ist Mario hinterlegt. Im Log steht das dann auch: text2command.0 2019-01-20 21:24:58.002 info Response: Mario Im Datenpunkt text2command.0.response steht nichts und im Objekt javascript.0.textProcessor auch nicht, bzw. je nach Art der Regel die task.command. Das Ganze wird über einen Textprocessor als Javascript, wie in der Doku beschrieben, aufgerufen:

Code: Alles auswählen

createState("textProcessor", '', function() {
    on({
        id: "javascript.0.textProcessor",
        ack: false,
        change: 'any'
    }, function(obj) {
        var task = obj.state.val[0] === '{' ? JSON.parse(obj.state.val) : {
            command: obj.state.val
        };
        if (task.command !== "") {
            sendTo(
                'text2command', task.command,
                function(err, response) {
                    console.log('Response is: ' + response);
                }
            );
        }
    });
    on("text2command.0.response" /*Answer on requested question*/ , "javascript.0.textProcessor");
});

Der console.log logeintrag in dem o.a. Snippet wird offenbar nicht verarbeitet. Das Objekt response ist auch leer. Das Ganze lässt sich auch mit anderen T2C Regeln wiederholen. Das Schalten einer Leuchte schaltet die Leuchte ein, bzw aus. Die Response erscheint im log. Führe ich die gleiche Regel per Telegram aus, wird sowohl geschaltet, als auch die Response im Telegram Channel ausgegeben, und somit verarbeitet T2C alles richtig. In einem Datenpunkt konnte ich die Response aber trotzdem nicht finden

mariomm commented 5 years ago

Ich habe einen Workaround gefunden. In der main.js unterhalb der Zeile

adapter.log.info('aResponse: ' + response);

Füge ich dies ein:

adapter.setState('response', response, true);

Dann wird der Datenpunkt entsprechend korrekt gefüllt. die zwei on Zeile oben in dem Snippet muss dann raus. Ob das Ganze jetzt als Bug zu werten ist, kann ich nicht sagen.

GermanBluefox commented 4 years ago

2.0.3 image

stale[bot] commented 3 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs within the next 7 days. Please check if the issue is still relevant in the most current version of the adapter and tell us. Also check that all relevant details, logs and reproduction steps are included and update them if needed. Thank you for your contributions. Dieses Problem wurde automatisch als veraltet markiert, da es in letzter Zeit keine Aktivitäten gab. Es wird geschlossen, wenn nicht innerhalb der nächsten 7 Tage weitere Aktivitäten stattfinden. Bitte überprüft, ob das Problem auch in der aktuellsten Version des Adapters noch relevant ist, und teilt uns dies mit. Überprüft auch, ob alle relevanten Details, Logs und Reproduktionsschritte enthalten sind bzw. aktualisiert diese. Vielen Dank für Eure Unterstützung.

stale[bot] commented 3 years ago

This issue has been automatically closed because of inactivity. Please open a new issue if still relevant and make sure to include all relevant details, logs and reproduction steps. Thank you for your contributions. Dieses Problem wurde aufgrund von Inaktivität automatisch geschlossen. Bitte öffnet ein neues Issue, falls dies noch relevant ist und stellt sicher das alle relevanten Details, Logs und Reproduktionsschritte enthalten sind. Vielen Dank für Eure Unterstützung.