Navigation

    Logo
    • Register
    • Login
    • Search
    • Recent
    • Tags
    • Unread
    • Categories
    • Unreplied
    • Popular
    • GitHub
    • Docu
    • Hilfe
    1. Home
    2. Deutsch
    3. Skripten / Logik
    4. JavaScript
    5. Grafana Heatmap für Autofahrten

    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

    Grafana Heatmap für Autofahrten

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

      Hallo

      Ich möchte mit einer Heatmap von Grafana meine Autofahrten darstellen.
      Die Koordinaten der Fahren bekomme ich bereits über Homekit.
      Dazu muss ich eine Influxdb Datenbank erstellen, die von den Feldern abweicht von dem, was iobroker über den Adapter erzeugt. Derzeit habe ich Influxdb 1.x installiert.
      Im Prinzip möchte die Befehl von Influx mit Javascript absetzen.

      USE geolocation
      INSERT location,lat=48.2990 lon=11.284317 
      

      mit dem "Exec" Befehl funktioniert es leider nicht, weil ich die influxdb in einem anderen Docker laufen lasse als iobroker. Irgendwie kann man das sicherlich über http POST machen.

      Ein andere Idee wäre in einem Datenpunkt ein JSON zu persistieren und dann in der Abfrage in Grafana die lat und lon zu extrahieren.

      Hat jemand einen Tip für mich?

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

        Damit konnte ich in dem gewünschten Format schreiben.

        function persist_geo(lon,lat) {
            var url = 'curl -i -XPOST "http://localhost:8086/write?db=geolocation" --data-binary "location,lat=' + lat + " lon=" + lon + '"'
            log(url)
            
            exec(url, function (error, stdout, stderr) {
                log(stdout)
            }); 
        }
        

        Bildschirmfoto 2024-04-04 um 11.56.10.jpg

        Meine Test Heatmap mit 3 Fahrten in München und 2 Fahrten in Hamburg.

        haus-automatisierung 1 Reply Last reply Reply Quote 0
        • haus-automatisierung
          haus-automatisierung Developer Most Active @Marty56 last edited by haus-automatisierung

          @marty56 In den aktuellen Versionen vom JavaScript-Adapter kannst Du auch ein httpPost direkt ausführen (ohne Umweg über exec/curl):

          https://github.com/ioBroker/ioBroker.javascript/blob/master/docs/en/javascript.md#httppost

          Gern mal testen

          httpPost('http://localhost:8086/write?db=geolocation', `location,lat=${lat} lon=${lon}`, { timeout: 1000 }, (error, response) => {
              if (error) {
                  console.error(error);
              }
          });
          
          M 1 Reply Last reply Reply Quote 0
          • M
            Marty56 @haus-automatisierung last edited by Marty56

            @haus-automatisierung sagte in Grafana Heatmap für Autofahrten:

                                                                                                                                        httpPost('http://localhost:8086/write?db=geolocation', `location,lat=${lat} lon=${lon}`, { timeout: 1000 }, (error, response) => {                                                                                                                                                                                if (error) {                                                                                                                                                                                    console.error(error);                                                                                                                                                                                }                                                                                                                                                                            });                                            
            

            Danke für die Rückmeldung.
            bekomme

            ReferenceError: httpPost is not defined
            

            Benötige ich da noch irgendein ein require("")?

            Update: ich habe noch die stable Version 7.8.0 installiert. Vermutlich geht das erst mit 7.9.0

            haus-automatisierung 1 Reply Last reply Reply Quote 0
            • haus-automatisierung
              haus-automatisierung Developer Most Active @Marty56 last edited by

              @marty56 Genau, ab 7.9.0

              M 1 Reply Last reply Reply Quote 0
              • M
                Marty56 @haus-automatisierung last edited by Marty56

                @haus-automatisierung

                Ich hab es mal versucht.
                mit der neusten Version gibt es keine Fehlermeldung mehr, aber es wird nichts in die Influxdb geschrieben.
                Ich vermute, dass der Parameter "--data-binary" von dem curl Kommando nicht richtig "übersetzt" wurde.

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

                Support us

                ioBroker
                Community Adapters
                Donate

                560
                Online

                31.8k
                Users

                80.0k
                Topics

                1.3m
                Posts

                javascript
                2
                6
                358
                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