Thank you! It turns out it’s not two different files (two blocks of code as the author of the article showed), but one file. I put it in the rules folder and it all worked. But unfortunately the data record does not work in influxdb (collectd works) and openhab does not transfer data to the database. The empty database is created from scratch and a separate openhab user is created for it, all privileges are set for both writing and reading.
First make sure to reboot OH. There is some weird behavior right now with groups where changes in group membership are not picked up properly until a reboot.
no work. reboot OH did not help
there are more ideas? can provide some more data? I need very much what would have worked, I have been fighting for many days.
Thank you! My icons work with both quotation marks and without quotes. It did not affect the record in the database. It is not written. Empty. And rebooting the demons did not help either.
Hey @lysol, I do not but let me know what’s your actual question and we can probably work something out.
The easiest is probably to install a small openHAB instance on the second device, then send data over to the main instance. Another option would be to write a small script executed on the second device, that would then send data to the main openHAB system via openHAB REST API or MQTT. You’d need to write a small script for that yourself.
Don’t really have another question. Was curious as one of my HABpanel dashboards is sort of a “Home Status” page that I can get uncommon information related to the status/health of our “home”. While it’s not that big of a deal in a home environment, I like to practice separation of roles. In this sense, having this on a separate (and more powerful) server would make sense to me. I’ll mess around with it when I get time and see what I can come up with.
OK, I had a look and I set it up before I started running OH in Docker so I was using the executeCommandLine to run the program. So here is a quick set of configs that should get you close. I’m just typing these in so there will likely be errors.
sensorReporter.ini
NOTE: This is just the config for the execActuator, you will need to include all the other config sections as well.
I’m pretty sure that the code will not time out as speedtest takes awhile to run. If it does timeout let me know and I’ll update the code.
Items
NOTE: the below Items use an overly complicated naming scheme I used to use. Ignore the N_V crap.
NOTE2: Change the mqtt configs below to match yours
String RunSpeedTest { mqtt="<[broker:scripts/speedtest-cli/cmd:*:default]" } // Strings passed to this Item are command line arguments to speedtest_cli
String SpeedTestResults { mqtt="<[broker:scripts/speedtest-cli/results:command:default]" }
String N_V_Speedtest_Summary "Speedtest [%s]" <network>
Number N_V_Speedtest_Ping "Ping [%.3f msec]" <network> (gChart)
Number N_V_Speedtest_Download "Download [%.2f Mb/s]" <network> (gChart)
Number N_V_Speedtest_Upload "Upload [%.2f Mb/s]" <network> (gChart)
String N_V_Speedtest_Running "Speedtest running ... [%s]" <network>
Switch T_C_Speedtest_Start "Start Speedtest" <network>
DateTime N_V_Speedtest_Lastupdate "Last Speedtest [%1$tm/%1$td/%1$tY %1$tT]" <clock>
Rules
rule "Initialize Speedtest"
when
System started
then
if(N_V_Speedtest_Summary.state == NULL || N_V_Speedtest_Summary.state == "") N_V_Speedtest_Summary.postUpdate("NA")
end
rule "Run Speedtest"
when
Time cron "0 0 */1 * * ?" or // not sure about this cron expression, I had it set to run every 15 minutes in my last version
Item T_C_Speedtest_Start received command
then
RunSpeedTest.sendCommand("")
N_V_Speedtest_Running.postUpdate("Running...")
end
rule "Process Speedtest Results"
when
Item SpeedTestResults received update
then
N_V_Speedtest_LastUpdate.postUpdate(new DateTimeType())
val results = SpeedTestResults.state.toString
if(results != "" && results.length >= 3 && results != "ERROR") {
val parts = results.split("\n")
val float ping = Float::parseFloat(parts.get(0).split(" ").get(1)) // I would do this differently these days, see the Type Conversions thread for details
val float down = Float::parseFloat(parts.get(1).split(" ").get(1))
val float up = Float::parseFloat(parts.get(2).split(" ").get(1))
N_V_Speedtest_Ping.postUpdate(ping)
N_V_Speedtest_Download.postUpdate(down)
N_V_Speedtest_Upload.postUpdate(up)
N_V_Speedtest_Summary.postUpdate(String::format("ᐁ %.1f Mbit/s ᐃ %.1f Mbit/s (%.0f ms)", down, up, ping))
}
else if(results == "ERROR"){
logError("Speedtest", "speedtest-cli returned an error code, see sensorReporter logs for details")
N_V_Speedtest_Summary.postUpdate("ERROR")
}
else {
logError("Speedtest", "Failed to parse results from speedtest-cli: " + results)
N_V_Speedtest_Summary.postUpdate("Failed to Parse")
}
N_V_Speedtest_Running.postUpdate("-")
end
Thanks a lot for this tutorial. Worked flawlessly.
One thing which is a bit unrelated but as it happens here I’m wondering if anybody knows a nice solution.
Now in the Android app on the phone in landscape mode the item overflows the text “Speedtest” and the results while in wider UIs or in landscape it looks perfectly fine. Does OpenHAB have any way to avoid that or is this an issue which would need to be handled in the app?
As far as I know, that’s the problem in HABDroid. I’m having it with a speedtest, but also with a longer TV Shows and Movies name when using Plex binding. You could add \n at the begining, so it would start a new line, but it is useful only for a text that could fit in one line itself - in case a length of caption + item text is too long.
This is a bug with the android app. It should be able to handle longer strings, e.g. by wrapping and scrolling it. Would you please comment and ask for a solution here: https://github.com/openhab/openhab.android/issues/169
While everything so far worked fine for me I’m now in the graphing part and somehow it seems I do not get data into influxdb. I tried to work with the other tutorial about influxdb and grafana but apparently I’m missing something.
My item definition looks like:
Group gSpeedtest <“network-icon”> (Sensors)
davorf,
Did you ever get a more concrete answer to the speed inconsistency? I am having a similar issue with my install. I’m on 1.0.7 right now (current newest) and I’m getting consistently about 1/3 of my actual download speed. From the same server (esxi hypervisor) I can get about 98% of my speed via a windows 10 speedtest so I don’t think it has anything to do with the server or OH VM itself. I have noticed that for some reason my ping times are substantially higher via the CLI (40-200ms vs. the 24ms average) and that the test seems to stall about half way in which may be the cause of the issues. I tried 1.0.2 as you mentioned and it didn’t make any difference from what I can tell.
Thanks! This was one of the first tutorials I followed when I setup on my first install of openHAB.
It runs every hour and logs the results and I have some graphs using Grafana.
I haven’t got any answer regarding the reason of those measuring differences. I’m still using 1.0.2 and I have pretty reliable measuring results (+/- 5% compared to SpeedTest website).