JSONPATH transform with math?

911 views
Skip to first unread message

Nathan Stratton

unread,
May 1, 2015, 2:42:11 PM5/1/15
to openhab

I can pull Voltage with this:
{http="<[http://10.71.129.2/Dev_status.cgi?&Port=0:2000:JSONPATH($.devstatus.ports[?(@.Port==4)][0].Batt_V)]"}

And current with this:

I am looking for help on a transform that will make an item that is the result of the above two multiplied together.

><>
nathan stratton | vp technology | broadsoft, inc | +1-240-404-6580 | www.broadsoft.com

watou

unread,
May 13, 2015, 2:10:12 PM5/13/15
to ope...@googlegroups.com
JSONPath only allows expressions for names and indices, not for computing some final result.  XPath is a lot more capable (and complicated) by comparison.  You could try various things at http://jsonpath.herokuapp.com/ but I don't think either the Goessner or Jayway implementations support the syntax you are looking for.  

I think you will have to instead fall back to a JS(mult.js) transform, and write a mult.js that parses the JSON input and does the math on the extracted elements.
Reply all
Reply to author
Forward
0 new messages