Speedtest data to influxDB

My Openhab System is working. Also a InfluxDB/Grafana installation is working well. I get nice graphs for my heating actors. So far so good. I like to have also statistic data from the speedtest. But no data are comming to the influxdb database.

my item look like this:

Group gSpeedtest (Whg)
String      SpeedtestSummary        "Speedtest [%s]"             <"speedtest_network">       (gSpeedtest)
Number      SpeedtestResultPing     "Ping [%.3f ms]"             <"speedtest_next5">         (gSpeedtest,gSpeedtestGraph)
Number      SpeedtestResultDown     "Downlink [%.2f Mbit/s]"     <"speedtest_download">      (gSpeedtest,gSpeedtestGraph)
Number      SpeedtestResultUp       "Uplink [%.2f Mbit/s]"       <"speedtest_upload">        (gSpeedtest,gSpeedtestGraph)
String      SpeedtestRunning        "Speedtest running ... [%s]" <"speedtest_new">           (gSpeedtest)
Switch      SpeedtestRerun          "Start manually"             <"speedtest_reload2">       (gSpeedtest)
DateTime    SpeedtestResultDate     "Last executed [%1$td.%1$tm.%1$tY, %1$tH:%1$tM Uhr]"   <"speedtest_problem4">      (gSpeedtest)

the persitance file look like that:

Strategies {
    everyMinute : "0 * * * * ?"
    everyHour   : "0 0 * * * ?"
    everyDay    : "0 0 0 * * ?"
}

Items {
    Temps*                            : strategy = everyChange, everyMinute, restoreOnStartup
    gSpeedtestGraph*                  : strategy = everyChange, everyHour, everyMinute, restoreOnStartup
    gSpeedtest*                       : strategy = everyChange, everyHour, everyMinute, restoreOnStartup
}

This is my sitemap part:

Frame label="Speedtest" {
    Text item=SpeedtestSummary {
      Frame label="Ergebnisse" {
        Text item=SpeedtestResultDown
        Text item=SpeedtestResultUp
        Text item=SpeedtestResultPing
      }
      Frame label="Steuerung" {
        Text item=SpeedtestResultDate
        Text item=SpeedtestRunning label="Speedtest [%s]" visibility=[SpeedtestRunning != "-"]
        Switch item=SpeedtestRerun mappings=[ON="Start"]
      }
      Frame label="Statistik" {
        Text label="speedtest" icon="speedtest_analytics8"
      }
    }
  }

and at least the speedtest rule data:


val String filename = "speedtest.rules"

rule "Speedtest init"
when
    System started
then
    createTimer(now.plusSeconds(195)) [|
        if (SpeedtestRerun.state == NULL) SpeedtestRerun.postUpdate(OFF)
        if (SpeedtestRunning.state == NULL) SpeedtestRunning.postUpdate("-")
        if (SpeedtestSummary.state == NULL || SpeedtestSummary.state == "") SpeedtestSummary.postUpdate("(unbekannt)")
    ]
end

rule "Speedtest"
when
    //Time cron "0 0 5 * * ?" or
    //Time cron "0 0 13 * * ?"
    Time cron "0 0 0 ? * * *" or
    Item SpeedtestRerun received command ON
then
    //logInfo(filename, "--> speedtest executed...")
    SpeedtestRunning.postUpdate("Messung laeuft...")

    // update timestamp for last execution
    SpeedtestResultDate.postUpdate(new DateTimeType())

    // execute the script, you may have to change the path depending on your system
    var String speedtestCliOutput = executeCommandLine("/usr/local/bin/speedtest-cli@@--simple", 120*1000)

    // for debugging:
    //logInfo(filename, "--> speedtest output:\n" + speedtestCliOutput + "\n\n")

    SpeedtestRunning.postUpdate("Datenauswertung...")

    // starts off with a fairly simple error check, should be enough to catch all problems I can think of
    if (speedtestCliOutput.startsWith("Ping") && speedtestCliOutput.endsWith("Mbit/s")) {
        var String[] results = speedtestCliOutput.split("\\r?\\n")
        var float ping = new java.lang.Float(results.get(0).split(" ").get(1))
        var float down = new java.lang.Float(results.get(1).split(" ").get(1))
        var float up   = new java.lang.Float(results.get(2).split(" ").get(1))
        SpeedtestResultPing.postUpdate(ping)
        SpeedtestResultDown.postUpdate(down)
        SpeedtestResultUp.postUpdate(up)
        SpeedtestSummary.postUpdate(String::format("Down %.1f Mbs  Up %.1f Mbs (Ping %.0f ms)", down, up, ping))
        SpeedtestRunning.postUpdate("-")
        //logInfo(filename, "--> speedtest finished.")
    } else {
        SpeedtestResultPing.postUpdate(0)
        SpeedtestResultDown.postUpdate(0)
        SpeedtestResultUp.postUpdate(0)
        SpeedtestSummary.postUpdate("(unbekannt)")
        SpeedtestRunning.postUpdate("Fehler bei der Ausfuehrung")
        logError(filename, "--> speedtest failed. Output:\n" + speedtestCliOutput + "\n\n")
    }
    SpeedtestRerun.postUpdate(OFF)
end

In the influxdb is no data for the speedtest. Whats wrong?

Bfo

@bforpc

Did you ever resolve this? I’m setting up SpeedTest to run every 30 mins and I can see the general speed test results in a sitemap. But my chart in grafana does not show any information.

I have the same groups, items, rules, and persistence as you do. But I think it may be an issue into configuring grafana correctly?

I have grafana looking at my openhab_db and speed up and down in the query, but do data shows in the charts.

run the influxdb client and check you have measurements in the database, thats the first step. Also check your persistance file.