How to start coding in openhab

Hello folks,

I am totally new to openhab, i have been able to install my zwave network and make it work, my netatmo station. Now i would like to understand how to make http request to get json values then parse it and display result in dummy, and i would like to do it every 5minutes.

I have seen example but i don’t understant where i have to put that code ! nobody explain where is the “code editor”…

Thanks in advance .

You may also want to setup VS Code and the OH extension…

Thanks … I have already installer visual studio code connected to openhabian. But if someone could show me a small tuto with some details i would really appreciate.

Strange… that first link was not what I thought it was. This one is more complete.

Do you have the Netatmo binding installed? What sort of tutorial are you looking for?

I believe @5iver have pointer you to the tutorial as you requested

For the http look for the http binding
For json look for the JSONPATH transformation service
Both are documented in the add-ons section of the docs

We are not here to write code for you. The question you ask has been answered many a times before.
All you need is in the docs and in the answers in the forum.
Come up with your own code and if doesn’t work, we’ll help you make it work and tell you where you are wrong and why (most of the time)

1 Like

I never asked people to write anything for me :slight_smile: I would not have choosed openhab in that case.

What i don’t understand is where to start. I will keep searching.

Have a nice day.

So here is a clear question :

I have this code :

String Sensor_Data "Data" { http="<[http://192.168.1.92/data.json:60000:REGEX((.*))]" }
var String data = Sensor_Data.state.toString
var String d0 = transform("JSONPATH", "$.sensors[0].data0", data)
var String d1 = transform("JSONPATH", "$.sensors[0].data1", data)

I put this code in openhab test.items in item folder of openhab.

What is the next step where do you i find this item in openhab?

I understand this look like a ver noobie question, but i have to start somewhere …

Thanks for help

This would go in the .items file

String Sensor_Data "Data" { http="<[http://192.168.1.92/data.json:60000:REGEX((.*))]" }

This would go in a .rules file in the rules directory, but you’re missing the actual rule-when-then-end body to catch when the item changes.

var String data = Sensor_Data.state.toString
var String d0 = transform("JSONPATH", "$.sensors[0].data0", data)
var String d1 = transform("JSONPATH", "$.sensors[0].data1", data)

Try

rule "Name for your rule"
when
    Item Sensor_Data changed
then
    var String data = Sensor_Data.state.toString
    var String d0 = transform("JSONPATH", "$.sensors[0].data0", data)
    var String d1 = transform("JSONPATH", "$.sensors[0].data1", data)
    // Do other stuff
end

Thank you Mark, i am on the path now, i appreciate !

1 Like