<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Text2command und javascript]]></title><description><![CDATA[<p dir="auto">Hallo iobroker-Gemeinde,</p>
<p dir="auto">ich habe ein Problem mit dem "External rules with javascript" vom github: <a href="https://github.com/ioBroker/ioBroker.text2command" rel="nofollow ugc">https://github.com/ioBroker/ioBroker.text2command</a></p>
<p dir="auto">Wenn ich das Script einbaue und in dem Object javascript.0.textProcessor einen Text eingebe, z.B. Mist, dann erhalte ich im Log eine Fehlermeldung.</p>
<p dir="auto">javascript.0 2017-04-17 18:33:40.920 error at Object.parse (native)</p>
<p dir="auto">javascript.0 2017-04-17 18:33:40.920 error SyntaxError: Unexpected token M</p>
<p dir="auto">javascript.0 2017-04-17 18:33:40.912 error message javascript.0.textProcessor [object Object] Unexpected token M</p>
<pre><code>createState("textProcessor", '', function () {
  // text2command writes the value with ack=false. Change "any" is important too, to process repeated commands.
  on({id: "javascript.0.textProcessor", ack: false, change: 'any'}, function (obj) {
    var task = JSON.parse(obj.state.val);
//    log (obj.state.val);
    if (task.command === "Test") {
      log ("Keywort gefunden","info");
       setState("javascript.0.textProcessor", 'Testnachricht empfangen.', true);
    } else {
        // let it process with predefined rules
        log ("Keywort nicht gefunden","info");
        setState("javascript.0.textProcessor", '', true);
    }
  });
});
</code></pre>
<p dir="auto">Mir ist nicht klar, warum dieser Fehler entsteht. Ersetze ich task.command durch obj.state.val scheint es zu funktionieren, aber viele andere scheinen das Original zu nutzen.</p>
]]></description><link>https://forum.iobroker.net/topic/5753/text2command-und-javascript</link><generator>RSS for Node</generator><lastBuildDate>Tue, 21 Apr 2026 12:59:16 GMT</lastBuildDate><atom:link href="https://forum.iobroker.net/topic/5753.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 17 Apr 2017 16:43:04 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Text2command und javascript on Mon, 17 Apr 2017 17:51:51 GMT]]></title><description><![CDATA[<p dir="auto">Hallo Bluefox,</p>
<p dir="auto">vielen Dank für die schnelle Antwort. Hat prima funktioniert. Und mit deiner Erklärung kann ich auch zukünftig etwas anfangen.</p>
<p dir="auto">Problem gelöst.</p>
]]></description><link>https://forum.iobroker.net/post/76634</link><guid isPermaLink="true">https://forum.iobroker.net/post/76634</guid><dc:creator><![CDATA[Kamikaze]]></dc:creator><pubDate>Mon, 17 Apr 2017 17:51:51 GMT</pubDate></item><item><title><![CDATA[Reply to Text2command und javascript on Mon, 17 Apr 2017 17:43:54 GMT]]></title><description><![CDATA[<p dir="auto">Diese Variable ist nicht für manuelle Bedienung.</p>
<p dir="auto">text2Command schriebt ein JSON Objekt rein. Du einfach Text.</p>
<p dir="auto">Modifiziere die Zeile:</p>
<pre><code>var task = JSON.parse(obj.state.val);
</code></pre>
<p dir="auto">auf</p>
<pre><code>var task = obj.state.val[0] === '{' ? JSON.parse(obj.state.val) : {command: obj.state.val};
</code></pre>
]]></description><link>https://forum.iobroker.net/post/76632</link><guid isPermaLink="true">https://forum.iobroker.net/post/76632</guid><dc:creator><![CDATA[Bluefox]]></dc:creator><pubDate>Mon, 17 Apr 2017 17:43:54 GMT</pubDate></item></channel></rss>