Beginners question. Parsing MQTT payload. Ie string ' 1' to value 1. How?

I have some mySensors nodes that Im trying to get into Openhab 3. Currently in the process of migrating from mySensors-binding to generic MQTT.

I have a channel reporting a cumulative counter value. Problem is the value-payload cannot be parsed correctly for values < 10 due to a proceeding “space”-sign. So I would need some cast string->uint. Preferably I would like to solve this directly in the “thing”-definition, although a solution should be to define thing as string and make cast in the item.

Tried transformationPattern, but couldnt work out a working solution. Any help appreciated. Thanks!
Per

log:
2022-05-22 12:42:07.641 [WARN ] [ab.binding.mqtt.generic.ChannelState] - Incoming payload ' 1' not supported by type 'NumberValue'
 
 thing:
 Type number : cnt_flush "Cnt flush activations" [
             stateTopic="mys_gw_1_out/2/4/1/0/24"
         ]
 
 item:
 Number    cnt_flush_krypgrund          "Counter flush kondens krypgrund [%d]"      (gMySensors)                  {channel="mqtt:topic:ms_rfm_node_2:cnt_flush"}

Presumably you flashed the Arduino board to create your MySensors device? I would fix this problem at the source - change the code so there’s no proceeding space.

1 Like

Thanks! Format of the specific send string is within the mySensors-code did not want to dig into it. However followed your suggestion and found a work-around and increased the number of decimals from 0 to 1 apparently filling up the sent string. Problem solved.

image

1 Like