Navigation

    Logo
    • Register
    • Login
    • Search
    • Recent
    • Tags
    • Unread
    • Categories
    • Unreplied
    • Popular
    • GitHub
    • Docu
    • Hilfe
    1. Home
    2. Deutsch
    3. Skripten / Logik
    4. [erledigt] History Adapter per JavaScript -> Doku?

    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

    [erledigt] History Adapter per JavaScript -> Doku?

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

      Hallo

      Ich suche eine "API Doku vom History Adapter"
      An 2-3 Stellen finde ich hier im Forum, dass man per sendTo() auf den history-Adapter zugreifen kann und Werte abholt um sie im JS zu verarbeiten.
      Gibts da eine generische Doku für?

      Konkret möchte ich die letzte n Werte eines String-Objektes abfragen inkl. den Timestamps.
      Die Samples im Forum sind allerdings alle auf Zeitrahmen-Abfrage.

      Gruss -

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

        @adarof sagte:

        Gibts da eine generische Doku für?

        Readme

        1 Reply Last reply Reply Quote 0
        • A
          adarof last edited by

          Hallo
          Danke - offensichtlich hab ich die unterschiedlichen Stellen noch nicht überblickt o_O.

          VIelleicht hilfts mal jemandem:

          sendTo('sql.0', 'getHistory', {
              id: 'javascript.0.localLoggerMailStripped'/*LoggerMail*/,
              options: {
                  end:       new Date().getTime(),
                  count:     3,
                  aggregate: 'onchange'
              }
          }, function (result) {
                var monthNames = [
              "Jan", "Feb", "Mär",
              "Apr", "Mai", "Jun", "Jul",
              "Aug", "Sep", "Okt",
              "Nov", "Dez"];
              var resultString = '<table>'; 
              for (var i = 0; i < result.result.length; i++) {
                  var d = new Date(result.result[2-i].ts);  
                  //var datestring = ("0" + d.getDate()).slice(-2) + "." + monthNames[d.getMonth()] + " " + ("0" + d.getHours()).slice(-2) + ":" + ("0" + d.getMinutes()).slice(-2);
                  //resultString += '<tr><td style="font-size:small;>' + datestring + '</td> <td style="font-size:normal;font-weight:bold">'+ result.result[4-i].val + '</td></tr>';  
                  var datestringDate = ("0" + d.getDate()).slice(-2) + "." + monthNames[d.getMonth()] + " ";
                  var datestringTime = ("0" + d.getHours()).slice(-2) + ":" + ("0" + d.getMinutes()).slice(-2);
                  resultString += '<tr><td style="font-size:large;padding-top:11px"> '+ datestringDate + '<br/>'
                               +'<span style="font-size:x-large">' + datestringTime + '</span>'
                               +'</td> <td style="font-size:x-large;padding-left:10px;padding-top:11px">'+ result.result[2-i].val + '</td></tr>';  
                  //console.log(JSON.stringify(result.result[i]));
              }
              resultString += "</table>"; 
              //console.log(resultString);
              setState('javascript.0.scriptEnabled.LastMessagesFiFoHTML'/*LastMessagesFiFoHTML*/, resultString);
          });
          
          
          1 Reply Last reply Reply Quote 0
          • First post
            Last post

          Support us

          ioBroker
          Community Adapters
          Donate

          747
          Online

          31.8k
          Users

          79.9k
          Topics

          1.3m
          Posts

          javascript
          2
          3
          437
          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