Navigation

    Logo
    • Register
    • Login
    • Search
    • Recent
    • Tags
    • Unread
    • Categories
    • Unreplied
    • Popular
    • GitHub
    • Docu
    • Hilfe
    1. Home
    2. Deutsch
    3. ioBroker Allgemein
    4. Pushover + Command = Telegram

    NEWS

    • Wir empfehlen: Node.js 22.x

    • Neuer Blog: Fotos und Eindrücke aus Solingen

    • ioBroker goes Matter ... Matter Adapter in Stable

    Pushover + Command = Telegram

    This topic has been deleted. Only users with topic management privileges can see it.
    • Bluefox
      Bluefox last edited by

      Es gibt neue Version text2command (github)

      https://github.com/ioBroker/ioBroker.te … javascript

      ` > There is a possibility to use javascript engine to process commands in text2command. To do that you must specify some state in "Processor state ID" (Advanced settings) and to listen on this state in some JS or Blockly script. You can create some state manually in admin or in script. Processing script can looks like this one:

      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);
               // value looks like
               // {
               //     "command":      "text to process", // command that was received by text2command
               //     "language":     "en",              // language in command or system language
               //     "withLanguage": false              // indicator if language was defined in command (true) or used default language (false)
               // }
               // response to text2command with ack=true
               if (task.command === 'switch light on') {
                  setState("hm-rpc.0.light", true);
                  setState("javascript.0.textProcessor", 'light is on', true);
               } else {
                  // let it process with predefined rules
                  setState("javascript.0.textProcessor", '', true);
               }
          });
      });
      

      Set in settings of text2command Processor state ID as javascript.0.textProcessor to let this example work.

      The command will be processed first with your javascript and if javascript will answer with '' or not answer in predefined time (1 second by default) the command will be processed by rules. `

      1 Reply Last reply Reply Quote 0
      • D
        dtp last edited by

        Klasse. Mal sehen, ob ich das noch vor meinem Urlaub ausprobiert bekomme.

        Gruß,

        Thorsten

        1 Reply Last reply Reply Quote 0
        • D
          dtp last edited by

          Hi Bluefox,

          Keyboard funktioniert nun. Top.

          Hier mal ein kleines Beispiel:

          on("telegram.0.communicate.request", function (obj) {
            log (obj.newState.val);
            if  (obj.newState.val == "[Thorsten]Test" || obj.newState.val == "[Thorsten]/Test") {      
              sendTo('telegram.0', {
                text:   'Testnachricht empfangen.',
                reply_markup: {
                  keyboard:          [['Taste 1','Taste 2'],['Taste 3','Taste 4']],
                  resize_keyboard:   true,
                  one_time_keyboard: true
              }
              });
            }
          });
          

          Und so sieht's in der App aus:

          996_img_0661.png

          Gruß,

          Thorsten

          1 Reply Last reply Reply Quote 0
          • Bluefox
            Bluefox last edited by

            Was passiert wenn du auf der Taste drückst?

            1 Reply Last reply Reply Quote 0
            • D
              dtp last edited by

              Dann sagt im Moment text2command noch: "Ich verstehe "taste 1" nicht. Aber da muss man dann ja nur einen entsprechenden Befehl hinterlegen.

              Übrigens, mit der chatID geht's natürlich auch:

              on("telegram.0.communicate.request", function (obj) {
                log (obj.newState.val);
                if  (obj.newState.val == "[Thorsten]Test") {      
                  sendTo('telegram.0', {
                    text:   'Testnachricht empfangen.',
                    chatId: 'xxxxxxxxxxx',
                    reply_markup: {
                      keyboard:          [['Taste 1','Taste 2'],['Taste 3','Taste 4']],
                      resize_keyboard:   true,
                      one_time_keyboard: true
                  }
                  });
                }
              });
              
              1 Reply Last reply Reply Quote 0
              • coyote
                coyote Most Active last edited by

                Hallo dtp,

                on("telegram.0.communicate.request", function (obj) {
                  log (obj.newState.val);
                  if  (obj.newState.val == "[Thorsten]Test" || obj.newState.val == "[Thorsten]/Test") {      
                    sendTo('telegram.0', {
                      text:   'Testnachricht empfangen.',
                      reply_markup: {
                        keyboard:          [['Taste 1','Taste 2'],['Taste 3','Taste 4']],
                        resize_keyboard:   true,
                        one_time_keyboard: true
                    }
                    });
                  }
                });
                

                Funktioniert bei mir leider nicht. Die Testnachricht kommt an, es öffnet sich aber kein Keyboard.

                Javascript Version: 2.3.1

                Telegram: 0.4.1

                Auf Android getestet

                Müsste ja auch ohne text2command adapter funktionieren

                1 Reply Last reply Reply Quote 0
                • D
                  dtp last edited by

                  Wird bei Dir im Log denn was zum Skript angezeigt? Da sollte nach Empfang von "Test" dann so etwas wie "[xxxxx]Test" stehen. Genau das musst Du dann in die nachfolgende if-Bedingung des Skripts eintragen.

                  filename="2016-08-17_21h39_08.png" index="0">~~

                  Falls gar nicht passiert, versuche es mal zunächst mit einem anderen Aufruf, z.B. "Hallo", ohne dass Du was im Skript änderst. Manchmal hängt das Skript etwas, wenn man hintereinander mehrmals denselben Begriff schickt.

                  1 Reply Last reply Reply Quote 0
                  • D
                    dtp last edited by

                    @Bluefox:

                    > To do that you must specify some state in "Processor state ID" (Advanced settings)

                    Das ist mir irgendwie nicht ganz klar. Wo genau muss ich da diese Einstellung vornehmen?

                    Gruß,

                    Thorsten

                    1 Reply Last reply Reply Quote 0
                    • coyote
                      coyote Most Active last edited by

                      Eine Nachricht mit dem Text bekomme ich ja vom javascript an mein Smartphone, nur öffnet sich kein Custom Keyboard.

                      > Manchmal hängt das Skript etwas, wenn man hintereinander mehrmals denselben Begriff schickt.

                      Füge mal````
                      setState("telegram.0.communicate.request","leer");

                      1 Reply Last reply Reply Quote 0
                      • D
                        dtp last edited by

                        @coyote:

                        Füge mal setState("telegram.0.communicate.request","leer");unter deinem Script ein…l `

                        Danke für den Tipp.

                        Was das Keyboard angeht. Erscheint irgend eine Fehlermeldung im Log? Falls nicht, könnte es ggf. noch an der Client App selbst liegen. Nutzt Du Telegram für iOS oder für ein anderes Betriebssystem? Hab's selber noch nicht unter Windows oder Android ausprobiert.

                        1 Reply Last reply Reply Quote 0
                        • coyote
                          coyote Most Active last edited by

                          Nein keine Fehlermeldung.

                          Genau, weder unter Windows noch Android kommt ein Keyboard, obwohl Android es eigentlich unterstützen sollte.

                          Gesendet von meinem Nexus 5X mit Tapatalk

                          1 Reply Last reply Reply Quote 0
                          • Bluefox
                            Bluefox last edited by

                            @dtp:

                            @Bluefox:

                            > To do that you must specify some state in "Processor state ID" (Advanced settings)

                            Das ist mir irgendwie nicht ganz klar. Wo genau muss ich da diese Einstellung vornehmen?

                            Gruß,

                            Thorsten `
                            48_2016-08-18_20_59_05-iobroker.admin.png

                            1 Reply Last reply Reply Quote 0
                            • coyote
                              coyote Most Active last edited by

                              @ Bluefox, funktioniert bei dir das Custom Keyboard unter Android?

                              1 Reply Last reply Reply Quote 0
                              • D
                                dtp last edited by

                                Hi coyote,

                                also unter Android konnte ich es gestern (noch) nicht testen. Aber in der Windows-App wird mir das Keyboard auch angezeigt. Ich gehe daher mal fest davon aus, dass es auch unter Android funktionieren sollte.

                                Was wird denn bei Dir im Log als Inhalt für obj.newState.val angezeigt, wenn Du eine Nachricht an telegram.0 sendest? Exakt dieser Inhalt muss dann, wie erwähnt, auch in die nachfolgende if-Bedingung des Skripts eingetragen werden.

                                Gruß,

                                Thorsten

                                1 Reply Last reply Reply Quote 0
                                • D
                                  dtp last edited by

                                  @Bluefox:

                                  Seltsam, obwohl mir unter iobroker.admin (Version 1.4.0) die installierte Version 1.1.0 des text2command-Adapters angezeigt wird, sehe ich das Zahnrad bei mir nicht im text2command-Adapter. Stattdessen werden bei mir hinter "Testsatz:" weiterhin noch "Sprache:" und "Antwort ins ID:" angezeigt.

                                  Muss ich da irgendwo noch eine andere Einstellung vornehmen?

                                  Gruß,

                                  Thorsten

                                  1 Reply Last reply Reply Quote 0
                                  • coyote
                                    coyote Most Active last edited by

                                    Hallo dtp,

                                    hier mein Script

                                    on("telegram.0.communicate.request", function (obj) {
                                      log (obj.newState.val);
                                      if  (obj.newState.val == "[Frank]Taste" || obj.newState.val == "[Frank]/Taste") {      
                                        sendTo('telegram.0', {
                                          text:   'Testnachricht empfangen.',
                                          reply_markup: {
                                            keyboard:          [['Taste 1','Taste 2'],['Taste 3','Taste 4']],
                                            resize_keyboard:   true,
                                            one_time_keyboard: true
                                    
                                        }
                                        });
                                           setState("telegram.0.communicate.request","leer"); 
                                      }
                                    });
                                    

                                    hier mein log:
                                    536_log.png

                                    Und in Telegram auf dem Android Smartphone bekommen ich zurück: Testnachricht empfangen

                                    EDIT: Hat sich erledigt :mrgreen:

                                    Nachdem es auf der Windows App auch nicht ging, hab ich "iobroker upload telegram" mal ausgeführt und siehe da, funktioniert

                                    1 Reply Last reply Reply Quote 0
                                    • M
                                      mp84 last edited by

                                      Moin,

                                      bin gerade auch ein wenig am experimentieren und habe -wie bereits hier vorgeschlagen wurde- festgestellt dass das setzten von "leer" nicht notwendig ist wenn

                                      on({id:"telegram.0.communicate.request",change:'any'}
                                      

                                      Verwendet wird.

                                      Habe mein Skript so gestaltet dass der TriggerBefehl immer mit "/" beginnen muss.

                                      Ausserdem schreibe ich die Datenpunkte und Bezeichnungen in ein zweidimensionales Array und überlasse das holen der Werte und die generierung des Ausgabetextes einer Schleife. Spart meines erachtens sehr viele Zeilen falls man mal mehrere Werte gleichzeitig holen und ausgeben möchte.

                                      Vielleicht kann der ein oder andere etwas damit anfangen…

                                      Gruß MP

                                      ! ```
                                      `on({id:"telegram.0.communicate.request",change:'any'}, function (obj) {
                                      //Hier "trigger" anpassen
                                      if (obj.newState.val.match(/([.+])/trigger/i)) {
                                      sendTemps();
                                      }
                                      });
                                      ! function sendTemps() {
                                      ! // Alle Objekte in Array rein, save code und so...
                                      var dataPoints = [
                                      ["Büro: ","hm-rpc.0.MEQxxxxxxx.4.ACTUAL_TEMPERATURE"],
                                      ["Server: ","hm-rpc.0.MEQxxxxxx.1.TEMPERATURE"],
                                      ["Garage: ","Variablen.0.Aussen.Garten.Temperatur.Garage"],
                                      ["Garten: ","Variablen.0.Aussen.Garten.Temperatur.Garten"],
                                      ["Pool: ","Variablen.0.Aussen.Garten.Temperatur.Pool"],
                                      ["Kollektor: ","Variablen.0.Aussen.Garten.Temperatur.Kollektor"],
                                      ];
                                      ! var text = "";
                                      ! for (i = 0; i < dataPoints.length; i++) {
                                      dataPoints[i][1] = getState(dataPoints[i][1]).val;
                                      text += dataPoints[i][0] + dataPoints[i][1] + "°C \n";
                                      }
                                      sendTo("telegram.0",text);

                                      }` [/i][/i][/i][/i]

                                      1 Reply Last reply Reply Quote 0
                                      • D
                                        dtp last edited by

                                        Hi Bluefox,

                                        war zwei Wochen im Urlaub. Hab gestern auf die aktuelle Version 1.1.3 des text2command-Adapters upgegradet und nutze sie in Verbindung mit dem Telegram-Adpater 0.4.3. Mittlerweile gibt es auch die Advanced-Options. Wenn ich da aber unter "Antwort ins ID:" den textProcessor von javascript.0 eintrage

                                        996_2016-09-04_12h41_50.png

                                        passiert leider nichts. Der text2command-Adpater schreibt dort die Antwort nicht hinein. Oder hab ich da was falsch verstanden, damit das mit dem entsprechend angelegten Javascript

                                        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 (task.command);
                                            if (task.command === "[Thorsten]Test") {
                                              sendTo('telegram.0', {
                                                text:   'Testnachricht empfangen.',
                                                reply_markup: {
                                                  keyboard:          [['Taste 1','Taste 2'],['Taste 3','Taste 4']],
                                                  resize_keyboard:   true,
                                                  one_time_keyboard: true
                                                }
                                              });
                                              setState("javascript.0.textProcessor", 'Testnachricht empfangen.', true);
                                            } else {
                                                // let it process with predefined rules
                                                setState("javascript.0.textProcessor", '', true);
                                            }
                                          });
                                        });
                                        

                                        funktioniert?

                                        Gruß,

                                        Thorsten

                                        1 Reply Last reply Reply Quote 0
                                        • Bluefox
                                          Bluefox last edited by

                                          @dtp:

                                          Hi Bluefox,

                                          war zwei Wochen im Urlaub. Hab gestern auf die aktuelle Version 1.1.3 des text2command-Adapters upgegradet und nutze sie in Verbindung mit dem Telegram-Adpater 0.4.3. Mittlerweile gibt es auch die Advanced-Options. Wenn ich da aber unter "Antwort ins ID:" den textProcessor von javascript.0 eintrage

                                          filename="2016-09-04_12h41_50.png" index="0">~~

                                          passiert leider nichts. Der text2command-Adpater schreibt dort die Antwort nicht hinein. Oder hab ich da was falsch verstanden, damit das mit dem entsprechend angelegten Javascript

                                          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 (task.command);
                                              if (task.command === "[Thorsten]Test") {
                                                sendTo('telegram.0', {
                                                  text:   'Testnachricht empfangen.',
                                                  reply_markup: {
                                                    keyboard:          [['Taste 1','Taste 2'],['Taste 3','Taste 4']],
                                                    resize_keyboard:   true,
                                                    one_time_keyboard: true
                                                  }
                                                });
                                                setState("javascript.0.textProcessor", 'Testnachricht empfangen.', true);
                                              } else {
                                                  // let it process with predefined rules
                                                  setState("javascript.0.textProcessor", '', true);
                                              }
                                            });
                                          });
                                          

                                          funktioniert?

                                          Gruß,

                                          Thorsten `
                                          Du solltest textProcessor in "Bearbeiter ID" eintragen und nicht in "Antwort ins ID"

                                          1 Reply Last reply Reply Quote 0
                                          • D
                                            dtp last edited by

                                            Ah. Alles klar.

                                            Hatte aber gerade das Problem, dass ich nach Aktualisierung des Admin-Adapters von Version 1.6.0 auf Version 1.6.1 nicht mehr auf das Web-Interface kam. Auch das Nachinstallieren des js-controllers brachte leider keinen Erfolg. Musste dann erst mal wieder auf die Stable-Versionen 1.5.3 des Admin-Adapters und 1.5.2 des Socket.io-Adapters downgraden.

                                            Vielleicht kannst Du mal schauen, warum es hier ein Problem mit der Version 1.6.1 des Admin-Adapters gibt.

                                            Gruß,

                                            Thorsten

                                            1 Reply Last reply Reply Quote 0
                                            • First post
                                              Last post

                                            Support us

                                            ioBroker
                                            Community Adapters
                                            Donate
                                            FAQ Cloud / IOT
                                            HowTo: Node.js-Update
                                            HowTo: Backup/Restore
                                            Downloads
                                            BLOG

                                            890
                                            Online

                                            32.0k
                                            Users

                                            80.5k
                                            Topics

                                            1.3m
                                            Posts

                                            23
                                            137
                                            30538
                                            Loading More Posts
                                            • Oldest to Newest
                                            • Newest to Oldest
                                            • Most Votes
                                            Reply
                                            • Reply as topic
                                            Log in to reply
                                            Community
                                            Impressum | Datenschutz-Bestimmungen | Nutzungsbedingungen
                                            The ioBroker Community 2014-2023
                                            logo