Did you install the JSONPATH Transformation through Paper UI and mor important:
Is the JSONPATH Transformation useful for your case?
I can see that you didnt change any values there.
Please read this for explanation:
So
// Check if Data arrived and is valid for your usecase
if(transform("JSONPATH","$.non_field_errors",output) != null){
throw new Exception(transform("JSONPATH","$.non_field_errors",output))
}
could possibly be removed and
wantedItem.postUpdate(transform("JSONPATH","$.token",output))
could changed to something you want to have.
That depends on the format which will be send from your water softener.
If you can post a raw result here, i can give you a better hint on that.
From your first Post this could be an xml output, but i am not sure.
If its XML you can use the XPATH Transformation for getting the Value directly.
See http://docs.openhab.org/addons/transformations/xpath/readme.html for further information and examples.
So a possible rule for exactly your case could look this:
rule "Grab http POST requested Data"
when
Time cron "*/10 * * * * ?"
then
var url = "http://192.168.222.15/mux_http"
var postUserData = "id=625&show=D_C_4_2~"
// POST Request
var output = sendHttpPostRequest(url , "application/x-www-form-urlencoded", postUserData)
logInfo("Grünbeck 1:", output);
// No errors. Update corrsponding Item
logInfo("Grünbeck 2:", "POST update done succesfully.")
var DurchflussString = transform("XPATH","//D_C_4_2/text()",output)
Enthaertung_Durchfluss.postUpdate(Float::parseFloat(DurchflussString))
logInfo("Grünbeck 3:", "Grüni result Durchfluss: " + Enthaertung_Durchfluss.state + " loop: " + loop_counter)
end
No guarantee for the XPATH, i didnt use it in rules before, but i think this could be the correct way to use it.
For testing XPATh you could use something like:
https://www.freeformatter.com/xpath-tester.html
I hope this can help you solve the Problem.
Edit:
And of course the Transformation you want to use, has to be installed with Paper UI.
Edit 2 - Since this is the solution post now:
There occurred problems due to the long answer time of that water softener.
The solution for this partly problem was to extend the POST request with a larger timeout (5000
in this case).
var output = sendHttpPostRequest(url, "application/x-www-form-urlencoded", postUserData, 5000)