Read JSON and show it

beginners
Tags: #<Tag:0x00007fe0520aa020>

(Jens) #1

I have data in JSON (I can change format if need be to anything) that I want to parse with OpenHAB to show it and make some rules.
But I simply can’t get the data in OpenHAB, after many hours of google and forum searches.
What am I doing wrong?
I’ve attached my config and the JSON data.

/etc/openhab2/items/default.items

Switch Presence_Mobile_OnePlus “Boeghs mobil” { channel=“network:pingdevice:172_16_10_45:online” }
//String Voltage “Current Voltage” { http="<http://172.16.10.200/volt.json:3000:JS(getValue.js)]" }
Text Battery_Voltage_Last { http="<[volt:1000:JSONPATH($.Voltage)]" }
DateTime VoltageUpdate
Text Battery_Time_Last { http="<[volt:1000:JSONPATH($.Time)]" }
DateTime TimeUpdated
Text Battery_Date_Last { http="<[volt:1000:JSONPATH($.Date)]" }
DateTime DateUpdated

/etc/openhab2/sitemaps/default.sitemap

sitemap default label="HomeSite"
{
        Switch item=Presence_Mobile_OnePlus label="Boeghs mobil"
        Text item=Battery_Voltage_Last label="[%s v]"
}

/etc/openhab2/services/html.cfg

volt.url=http://172.16.10.200/volt.json
volt.updateInterval=1000

JSON Data

{“Voltage”: “53.3”, “Time”: “2018-12-16T10:35:22Z”, “Date”: “2018-12-16”}

Thanks in advance for any tips and hints that will get me going.


(Jürgen Baginski) #2

Did you install the JSONPath Transformation Addon at all?


(lipp_markus) #3

I am not an expert for the http binding, but I think you may have more luck to get a response if you add missing info: what OH version, what system, what bindings did you install, do you see any errors?, your thing definition (OH2 only), etc
Start here:


(Jens) #4

Yes.


(Jens) #5

Version 2.3
I buddy told me to try using mqtt instead, but not having much luck there either.
So frustrating.


(lipp_markus) #6

@Azuria, I am sure you are frustrated, but it is hard to help without you sharing details


(Jens) #7

Yeah.
I finally got it working.
I used mqtt instead, but thanks to everyone for taking the time to help out. :slight_smile: