0

json problem with decode answer message with space

Gruyère Energie SA 3 years ago in Devices / Basic updated by Tomasz Michalak 2 years ago 2

Hello,

I try to get the value with the basic device and UDP request. 

The answer is in json and the answer is correct you can see below an example

{
"ID": "2",
"State": 1,
"Error1": 0,
"Error2": 0,
"Plug": 3,
"AuthON": 0,
"Authreq": 0,
"Enable sys": 1,
"Enable user": 1,
"Max curr": 0,
"Max curr %": 1000,
"Curr HW": 13000,
"Curr user": 63000,
"Curr FS": 0,
"Tmo FS": 0,
"Curr timer": 0,
"Tmo CT": 0,
"Setenergy": 0,
"Output": 0,
"Input": 0,
}

When I try to read the data with the space for exemple "Enable sys" I have the error  "Error parsing received data. : Unexpected character while parsing path:"


How to decode the value with space ?

I try somes codes for space but nothing work.


Can you help me please ?

Your json data has a problem.

There's an unexpected comma after the last value.

"Input": 0,
}

With that comma, the data outputs error on every expression tester I've used.

Paste it here as it is:

https://jsonpath.curiousconcept.com

Removing the , after the last value, and testing "Enable sys" as the expression, it outputs the correct value without any error. Please note that I had to use " ".

Expressions tested with good results on online testers:

"Enable sys"

["Enable sys"]

Test those tokens on bOS and see if it ignores the comma problem, otherwise you need to check why does your device outputs a bad formatted json response.

Hello,

Did you solve the problem with variables having spaces?

I also have the same problem with the KEBA charger.

I can handle the loading process via modbus and UDP at the same time. But it is inconvenient.


There is also a problem with the message "TCH-OK: done" being sent back.
I think that's why this invalid character error is getting displayed.

Have you tried to use REGEX?

PS.

I made an automation that reads the current energy balance of the house by reading from a SolarEdge inverter connected to a PRO380 modbus meter.

I charge the car with excess energy instead of sending it to the grid.