Navigation

    Logo
    • Register
    • Login
    • Search
    • Recent
    • Tags
    • Unread
    • Categories
    • Unreplied
    • Popular
    • GitHub
    • Docu
    • Hilfe
    1. Home
    2. Deutsch
    3. Skripten / Logik
    4. Blockly
    5. JS-Funktion mit Ergebnis - Result aus SQL an Blockly

    NEWS

    • Neuer Blog: Fotos und Eindrücke aus Solingen

    • ioBroker@Smart Living Forum Solingen, 14.06. - Agenda added

    • ioBroker goes Matter ... Matter Adapter in Stable

    JS-Funktion mit Ergebnis - Result aus SQL an Blockly

    This topic has been deleted. Only users with topic management privileges can see it.
    • M
      Mystisch @paul53 last edited by

      @paul53 wie kann ich dann das ergebnis aus der query an blockly schicken? geht dann nur der Umweg über setstate?

      paul53 1 Reply Last reply Reply Quote 0
      • paul53
        paul53 @Mystisch last edited by

        @mystisch sagte: wie kann ich dann das ergebnis aus der query an blockly schicken?

        Du kannst eine Blockly-Funktion erstellen und diese aus der Callback-Funktion aufrufen.
        Weshalb nutzt Du nicht das Blockly-sendTo() ?

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

          @paul53 Ich habe erst vor ein paar monaten mit ioBroker angefangen und finde mich erst solangsam rein, daher sind mir noch nicht alle Funktionen geläufig.
          Und das sendTo mit SQL hat auch nicht zum gewünschten Ziel geführt. Bei dem sendTo bekomme gar kein Ergebnis zurück oder was auch immer.

          paul53 1 Reply Last reply Reply Quote 0
          • M
            Mystisch last edited by

            Vielleicht kann mir hier einer mal ein Beispiel dazu schicken oder einen Hinweis im Netz schicken wo das mal näher beschrieben wird. Komme hier grad nicht weiter.

            1 Reply Last reply Reply Quote 0
            • paul53
              paul53 @Mystisch last edited by

              @mystisch sagte: sendTo mit SQL hat auch nicht zum gewünschten Ziel geführt.

              Dann solltest Du die Überschrift ändern, damit SQL-kundige helfen.

              M 1 Reply Last reply Reply Quote 0
              • M
                Mystisch @paul53 last edited by

                @paul53 das SQL ist nicht das Problem, in der JavaScript bekomme ich mein gewünchstes Ergebnis in der Console, nur bekomme ich das Ergebnis nicht ins Blockly.
                Bei dem Blockly SendTo bekomme ich gar nichts zurück, bin mir aber auch nicht sicher, ob ich das Richtig nutze, da ich in Google auch keine Beschreibung fand.

                paul53 1 Reply Last reply Reply Quote 0
                • paul53
                  paul53 @Mystisch last edited by paul53

                  @mystisch sagte in JS-Funktion mit Ergebnis - Result aus SQL an Blockly:

                  bekomme ich das Ergebnis nicht ins Blockly.

                  Dann erstelle eine Blockly-Funktion zur Auswertung der SQL-Abfrage

                  Bild_2021-09-05_184836.png

                  In der Javascript-Funktion ersetze

                  return result.result[0];
                  

                  durch

                  auswertung(result.result[0]);
                  

                  besser in einer Javascript-Funktion (ohne Ergebnis).

                  M Jey Cee 2 Replies Last reply Reply Quote 0
                  • M
                    Mystisch @paul53 last edited by

                    @paul53 Super vielen Dank. Das hat mir jetzt weiter geholfen.

                    liv-in-sky 1 Reply Last reply Reply Quote 0
                    • liv-in-sky
                      liv-in-sky @Mystisch last edited by liv-in-sky

                      @mystisch

                      es gibt auch noch die gethistory

                      ein beispiel - dort bekommst , je nach zeitangabe, die daten in ein array und kannst dann dieses arr verarbeiten

                      var end = new Date().getTime();
                      let myArrTemp=[]
                      getHistory('sql.0', {
                              id:         'javascript.0.variables.test', //''0_userdata.0.CONTROL-OWN.FUTRO.CPUTempNUC1',
                              start:      end - 60000000,
                              end:        end,
                            //  aggregate:  'm4',
                              timeout:    2000
                          }, function (err, result) {
                              if (err) console.error(err);
                              if (result) {
                                //  log(JSON.stringify(result))
                                  for (var i = 0; i < result.length; i++) {
                                      myArrTemp.push({
                                          "ts": new Date(result[i].ts).toISOString(),
                                          "val":result[i].val
                                      })
                              //    console.log(result[i].val + ' ' + new Date(result[i].ts).toISOString());
                                
                                  } // log ("ende func1 "+JSON.stringify(myArrTemp)) ;
                              // return 
                              log(JSON.stringify(myArrTemp));
                              }
                          });
                      

                      bin mir nicht ganz sicher, ob ich verstehe, was du machen willst 😞

                      1 Reply Last reply Reply Quote 0
                      • Jey Cee
                        Jey Cee Developer @paul53 last edited by Jey Cee

                        @paul53 was ist das den für ein Block? Ich finde keinen mit Ergebnis.

                        Edit: Hat sich erledigt.
                        Für andere mit der gleichen Frage: Funktionen -> etwas tun -> Zahnrad -> Variable in Parameter ziehen
                        Dann kann man die Variable unter Variablen finden.

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

                        Support us

                        ioBroker
                        Community Adapters
                        Donate

                        410
                        Online

                        31.9k
                        Users

                        80.1k
                        Topics

                        1.3m
                        Posts

                        4
                        12
                        1380
                        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