How to parse a file

Hi all,

I wish a Happy Easter to all of you.

I’m looking for a good solution how to parse a file and retrieve some data to use in my items.

the command I’m using to create the file is:

/usr/bin/curl -s -XGET ‘’ -H “x-access-token: xxxmyAPIkeyxxx” > /etc/openhab2/myscripts/openuv.txt

and the command to retrieve, for example, the current uv index is:

sed -e ‘s/.“uv”:(.),“uv_time”.*/\1/’ openuv.txt

Another application of this kind of rule should be to detect the alarms from But in that case I don’t maybe need to create a file, just parse directly the html online.

Any suggestion how to approach this piece?


What is the content of the file?

considering just the first example:



Unfortunately I can’t use (or at least, I failed every time) curl in a rule because of that header with the API key in the request. Also HTTP binding seems not a viable solution.

The site is saying I can use also other solutions, not only curl:

  • javascript
  • node.js
  • ruby
  • java
  • swift


Buona Pasqua

Put the file in the conf/html folder

Retreive the file with the http binding with the url address as `localhost:8080/openuv.txt
and then use a JSONPATH transform to retreive you data

1 Like

“Put the file in the conf/html folder”

how can put the output of this curl in conf/html folder? via rule is possible? or do I need to put an action in the cron (but not sure I can create as openhab:openhab).

Simply change the destination file in your command:

/usr/bin/curl -s -XGET ‘’ -H “x-access-token: xxxmyAPIkeyxxx” > /etc/openhab2/myscripts/openuv.txt

You can use executeCommand in OH to run the command

mmm I think I will receive an error, I don’t know if openhab user can do curl + https.

Let me try right now


If it doesn’t work, you will need to change the permissions for openhab user.
Not very good at that… I google it everytime

it seems working fine … the file is ok, with right permissions.

conf/html is /etc/openhab2/html in OH2?

It is on my machine. I did an apt based installation.

WOW it works :slight_smile: thanks @vzorglub :slight_smile: much appreciated.

Now I need to work on parsing the html from
In that case I can’t use jsonpath … maybe a script with “sed” will do the trick

What data do you get from

directly from the source:


this is an example with 2 alerts. As you know, Wunderground is not publishing alerts data anymore, so I need to find another way.

Idea is to parse directly the html, find the right words (Alert/Level), and in case of multiple alerts put the output in array and put in OH items.

I should use also the RSS … maybe easier. We have also today and tomorrow in the same page:

In this case I should try to find:

  • “Today”
  • “awt:1 level:2” -> that means alert 1 level 2
  • “Tomorrow”

any suggestion?

XPATH transform?
Sorry I haven’t really touched these. More of a json kind of guy.
You could get the html into a js transform…