HTTP Binding Data-Binary

Same result, the rule goes into the if statement.

val jsonString = JSON_SMA.state.toString

    if (jsonString != null) {
        number_SMA_DCVermogenA.postUpdate(transform("JSONPATH","$.result.XXXX-XXXXXXXX.XXXX_XXXXXXXX.1.0.val", jsonString))
    }
2018-03-18 08:09:37.300 [INFO ] [.eclipse.smarthome.model.script.RULE] - JSON from SMA inverter changed!
2018-03-18 08:09:37.301 [ERROR] [.script.engine.ScriptExecutionThread] - Rule 'Process JSON from SMA Inverter': The argument 'state' must not be null or empty.

The error is somewhere in the transform part:

if (jsonString != null) {
        //number_SMA_DCVermogenA.postUpdate(transform("JSONPATH","$.result.0156-76BC5229.6100_00411E00.1.0.val", jsonString))

        val tester = transform("JSONPATH","$.result.0156-76BC5229.6100_00411E00.1.0.val", jsonString)
        logInfo("RULE", tester)
        //postUpdate(number_SMA_DCVermogenA,tester)

    }

The loginfo rule for the tester is empty in the logging:

2018-03-18 08:26:54.200 [INFO ] [.eclipse.smarthome.model.script.RULE] - JSON from SMA inverter changed!
2018-03-18 08:26:54.201 [INFO ] [.eclipse.smarthome.model.script.RULE] -

But it looks like it doesn’t, your jsonString is "" and should contain the whole json.
Where is the json?

jsonString is not “”, that’s what we proved by outputting them to the log here, no?

So I checked if it really was empty or null, which it isn’t. I’m outputting both the item defined in the items file to the log and the jsonString val object and they both return the JSON in the log file…

If I comment out the number_SMA… transform rule, the error disappears in the logging. Additional strange thing is that I have multiple of these code-lines (vermogen means power in Dutch, so I have power,amperage,voltage etc) but I’m seeing the error only once though I would expect to see it the amount of times I have defined a statement to process a value…

The empty rule log line is coming from the

        logInfo("RULE", tester)

And tester should contain the transformed value but something is going wrong there I think, or am I misunderstanding you?

I misread. tester should contain the transformed value.
Can you post your json? Maybe the path is incorrect and the transform returns ""

You can check your path with:

Jup, that’s what I used to check it and it returns a number last time I checked :slight_smile:

This is my jsonpath.
$.result.0156-76BC5229.6100_00411E00.1.0.val

I have pasted my JSON here (it will expire in 1 hour)
https://pastebin.com/UNTNa0v6

Sorry, I missed it. I was at work.
Could you resend it, please
Thanks

Yeah it was pretty tight timing :smiley:

I have sent you a new pastebin link which is valid for a day.

The JSONPATH is:

$.result.0156-76BC5229.6100_00411E00.1[0].val

Well I’ll be dmnd :roll_eyes:

My JSONPATH gives the exact same result in the analyzer as yours and yours is working fine and mine doesn’t. :exploding_head:

I loaded your json in jsonpath.com and your jsonpath didn’t work, so I fiddled a bit and got that one.
Did you get all your items up and running?

Very bizarre because when I use mine in the json path analyzer I get the 4000 value too(?)

No, didn’t get them all up and running, it was a little bit too late on a sunday evening :slight_smile: . Will implement today.

That’s bizarre indeed.
Glad we got it sorted, eventually

Oooof, all items created and values showing up. Still have to do some polishing (icons, description etc) but I’m going to open a seperate topic for that: Working with values, substracting and checking if null

God, what a misery, once it works, it works forever but the whole rule syntax and the VSCode extension lacks so much useability… cc: @Kai @rlkoshak

Best results can be achieved when using an online validator which supports jayway as openhab transformation also uses jayway.

And just to tease you a bit, please try to get used to code fences. It increases the readability a lot. There are buttons for that above the textfiled, or just type the trippled quote.

```csv
your code goes here
```

@vzorglub @namraccr @rlkoshak

Everything has been working fine but for the last couple of days the logging suddenly stops. It’s not a session issue because when I use the URL used in the HTTP binding it responds with the JSON but after a restart of OpenHAB everything starts working again.

Openhab.log shows nothing apart from just suddenly stopping with processing the rule…

Somebody any idea’s?

@hyperbart could you post up your working thing please, I’m having the same problem with libcurl not supporting and I want to check my formatting against your solution. Thanks in advance

@hyperbart Could you post your solution (things, rules, etc) as an example or PM this to me? I am working on getting the info from my Diehl inverter in the same way as you did for your SMA inverter.

@hyperbart Similar like @flagg wrote before, I work on the same solution for reading out and accessing a heat pump by cURL commands with the HTTP binding. The returns are JSON data. This works fine with POSTMAN. Now I want to transfer this into my openHAB.

Would you please post your complete solution as example?

Thank you very much!