JSONPath value from string channel to number item

Hi,

Hopefully someone can point me into the right direction.

My config:

  1. http binding thing
  2. thing base url: http://localhost:4000
  3. string channel state url extension: /api/pressure
  4. linked string item jsonpath profile $.pressure

Above config works well, i get the pressure value as a string, thats all good; I can parse this value into a float in rules and do number stuff with that.
I’m wondering though if it is possible to link a number item to the string channel and get the pressure value as a number directly without using rules. Can this be done? And if yes, how should I do that?
Thanx in advance!

Best regards,
Jesse

Some of our experts might have a more detailed or other solution, but for the moment have a look at Transformations.
You could also try to play around with state description, but not sure if that leads to a solution, too.

The main difference is the location where these changes occur. Transformation changes the value before it gets forwarded to an item and state description just changes the view how the item value is presented to the GUI.
In your example if you persisted your value which is changed from string to number, transformation results in storing a number value of your item. state dewcription would leave everything as is and a string value would be persisted.

As long as you are sure that the string value can be parsed to a number, you should be able to just link the number item directly to the channel. The conversion will happen automatically in this case.

Hi guys,

Thanx for your replies, and pointing me into the right direction!
I created a number thing, and added
DSL:|(transform(“JSONPATH”, “$.[‘pressure’]”, input.toString)) as the state transformatuon option. I linked a number item to the number thing and that works for me. (The http binding seems to crap out very easely though, but that something for an other topic I suppose😄).

Best regards,
Jesse