[SOLVED] MQTT 2.4 transformations error

After much trial and error I have managed to get MQTT 2.4 updating a string item,

  1. Added a MQTT broker Thing pointing to my mosquittto mq
  2. Added a MQTT generic Thing using the Thing from 1 as the bridge
  3. Added a Channel to (2) selecting the MQ topic I want to catch
  4. Linked (3) to the item I want to receive the value

in the events log with a string item an no transformation I see

test_solar changed from NULL to <msg><time>2018-12-24 16:03:21</time><tmpr>20.2</tmpr><ch1><watts>00672</watts></ch1><ch2><watts>00028</watts></ch2></msg>

If I then add XPATH transformation on the channel definition XPATH:/msg/ch1/watts/text() I get

`test_solar changed from 2018-12-24 16:03:2120.20067200028 to 00658

… however I want the item to be a Number. If I just change the item type to number then I get

Tried to set invalid state 00658 (StringType) on item test_solar of type NumberItem, ignoring it

so I changed the XPATH to XPATH:/msg/ch1/watts/number(text()) which according to an online XPATH tester should return a Double=‘658’ but instead I get

Executing the XPATH-transformation failed: transformation throws exceptions

Can someone enlighten me on how to convert my string of numbers to an actual number ?

Thanks in advance

Is it a text channel or a number channel?

Thank you so much Vincent that was the problem, editing the channel to change the transformation doesnt give the option of changing the channel type so it was still a string. Deleted and recreated as a number type and now the transform works as expected :grin:

I spent a couple of hours looking at that and never spotted it.

Please mark the thread as solved, thanks
Merry Christmas