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:
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.
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…)
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.
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.