Navigation

    Logo
    • Register
    • Login
    • Search
    • Recent
    • Tags
    • Unread
    • Categories
    • Unreplied
    • Popular
    • GitHub
    • Docu
    • Hilfe
    1. Home
    2. Deutsch
    3. Einsteigerfragen
    4. Datenpunkt in influxdb speichern

    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

    Datenpunkt in influxdb speichern

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

      Hallo,

      ich versuche ohne Erfolg in einem Skript selbst einen Datenpunkt in influx mit dem Adapter influxdb zu speichern.

      In der Raspberry-Konsole bei Influx funktioniert es wunderbar:

      pi@raspberrypi:~ $ influx
      Connected to http://localhost:8086 version 1.8.10
      InfluxDB shell version: 1.8.10
      > use iobroker
      Using database iobroker
      > INSERT energy_consumption value=3
      > select * from energy_consumption
      name: energy_consumption
      time                hour value
      ----                ---- -----
      1685196703747955711 10   17
      1685197180244637788 11   90
      1685288023379343768 12   0
      1685349356267094122      3
      1685349386812894845      3
      1685349387563445028      3
      1685351947017987008      3
      

      Mit folgendem Javascript-Befehl unter iobroker:

      sendTo('influxdb.0', 'query', 'INSERT energy_consumption value=3', function (result) {
          if (result.error) {
              console.error(result.error);
          } else {
               console.log('Rows: ' + JSON.stringify(result.result[0]));
          }
      });
      

      Kommt folgende Fehlermeldung im Log:

      influxdb.0
      	2023-05-29 11:05:05.298	error	query: Error: error parsing query: found INSERT, expected SELECT, DELETE, SHOW, CREATE, DROP, EXPLAIN, GRANT, REVOKE, ALTER, SET, KILL at line 1, char 1
      

      Das funktioniert übrigens wunderbar:

      sendTo('influxdb.0', 'query', 'SELECT * FROM energy_consumption LIMIT 100', function (result) {
          if (result.error) {
              console.error(result.error);
          } else {
              // show result
               console.log('Rows: ' + JSON.stringify(result.result[0]));
          }
      });
      

      Was mache ich falsch?

      "storeState" des Adapters influxdb funktioniert auch nicht.
      Befehl:

      sendTo('influxdb.0', 'storeState', {
          id: 'energy_consumption',
          state: {val: 3}
      }, function (result) {
          console.log('added');
      });
      

      Fehlermeldung:

      influxdb.0
      	2023-05-29 11:26:57.652	warn	Error on writePoint("{"value":3,"time":null,"from":"","q":0,"ack":false}): Error: {"error":"unable to parse 'energy_consumption value=3,from=\"\",q=0,ack=false NaN': bad timestamp"} / "{\"error\":\"unable to parse 'energy_consumption value=3,from=\\\"\\\",q=0,ack=false NaN': bad timestamp\"}\n""
      
      Homoran 1 Reply Last reply Reply Quote 0
      • Homoran
        Homoran Global Moderator Administrators @WasserStrom last edited by

        @wasserstrom sagte in dantenpunkt in influxdb speichern:

        in einem Skript selbst einen Datenpunkt in influx mit dem Adapter influxdb zu speichern.

        ich bin in der influxdb-Materie nicht wirklich tief drin.
        Aber meines Wissens schreibt der Adapter nur die historisierten Werte eines konfigurierten Datenpunktes.

        Alles darüber hinaus gehende wäre das Programmieren direkt in deine Datenbank

        W 1 Reply Last reply Reply Quote 1
        • W
          WasserStrom @Homoran last edited by

          @homoran

          Besten Dank. Tatsächlich funktioniert "storeState" nur mit konfigurierten Datenpunkten wie im folgenden Beispiel:

          sendTo('influxdb.0', 'storeState', {
              id: 'javascript.0.energycounter.ec_dailycounter',
              state: {ts: 1685311202820, val: 6, ack: false, from: 'system.adapter.whatever.0'}
          }, function (result) {
              console.log('added');
          });
          

          Aber beim "query" löst der Befehl "insert" auch bei konfiguriertem Datenpunkt nach wie vor dieselbe Fehlermeldung aus.

          Aber das ist nicht schlimm, ich komme erstmal mit "storeState" weiter.

          ps: Du kannst gerne den Schreibfehler im Thread-Titel korrigieren. Ich schaffe das nicht.

          DJMarc75 Homoran 2 Replies Last reply Reply Quote 0
          • DJMarc75
            DJMarc75 @WasserStrom last edited by DJMarc75

            @wasserstrom sagte in dantenpunkt in influxdb speichern:

            Ich schaffe das nicht

            ???
            Deinen Startbeitrag editieren (im Startbeitrag die 3 Punkte rechts unten) und dann den Titel editieren 🙂

            W 1 Reply Last reply Reply Quote 0
            • W
              WasserStrom @DJMarc75 last edited by

              @djmarc75

              Vielen Dank! Wieder was gelernt 🙂

              1 Reply Last reply Reply Quote 0
              • Homoran
                Homoran Global Moderator Administrators @WasserStrom last edited by

                @wasserstrom sagte in dantenpunkt in influxdb speichern:

                den Schreibfehler im Thread-Titel

                Was hast du gegen Dante Alighieri?
                die göttliche Komödie ist doch gut gelungen.

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

                Support us

                ioBroker
                Community Adapters
                Donate

                961
                Online

                31.9k
                Users

                80.1k
                Topics

                1.3m
                Posts

                3
                6
                559
                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