Monitor CSV file from heatpump

I have a heatpump which logs all the information into a CSV file in 15s intervall. This file is directly acessable over http (1 file per day)
I want to get some of these values into openhab. I don’t know which is the best way to do this and how.
The file looks like this:

T/E; Timestamp; Te_Amb; Te_Amb_21h; Te_WE_VL1; Te_WE_RL; Te_VL2_Act
T; 2018-02-05 00:00:04.467; -4.8; -1; 25.1; 24.8; 24.8
T; 2018-02-05 00:00:19.467; -4.8; -1; 26.1; 24.8; 24.7
T; 2018-02-05 00:00:34.467; -4.8; -1; 28.1; 24.8; 24.9

Is it possible to update an item only if a value changed? I also thought about monitoring the file in python and doing a mqtt_pub but if it is possible in OH I would like it better.

Plz help

You are going to struggle doing that in OH
Your python solution is probably the way to go.
I would use node-red personally

I never used node-red before - can you point me in the right direction?

Install node-red on the same machine as your OH server

Then it is a graphical programming tool,
Very intuitive
There are nodes with different functionality
There is a tail node to check if a file has changed
As CSV node to convert a CSV value in a JS object
and so on…
OpenHAB2 nodes to update items via the rest api
MQTT nodes to publish values
Function nodes to write custom code…

And hundred of nodes created by the community to add more functions… (Thermostat, blind control…)

1 Like

I would suggest the exec binding, using a script with curl, tail and awk (the tools i know, maybe something better exists).

  • curl to get the file from http
  • tail to get the last line only
  • awk to separate the colums

I think I will give node-red a try


It is not better, it is just another solution. I am not very fluent in scripting and baby walking with python, so I use what I know.

What I like with node-red is the flexibility, the instant visual feedback and still the ability to run advanced js code.

As always, there are many ways to achieve the same result, we all use the tools that we know best. Whether or not they are the best tools to achieve that particular result is a matter of preference.

All the best

I actually don’t think this would be too hard to work within OH rules.

val csv = sendHttpGetRequest("url to heat pump").split("\n")
val lastLine = cvs.get(csv.size-1).split(";")

val T = lastLine.get(0).trim
val TimeStamp = lastLine.get(1).trim
val Te_Amb = lastLine.get(2).trim

if(Te_Amb_Item.state.toString != Te_Amb) Te_Amb_Item.postUpdate(Te_Amb)

I’m assuming you only care about the last row in the CSV.

I really don’t see this as being any harder than the other recommendations. Obviously, the best approach is the one that uses the tools the developer is most familiar with. But in this particular case, the data is structured enough to easily be managed using the standard String manipulation functions.

1 Like