[SOLVED ]MQTT 2.4.0 Transformation

I managed to transfer my mqtt stuff to new 2.4 version.

I still have an issue with some channels of type number.
In normal case I get a numeric value. Though sometime a get an array of value in the form:

300;50;300;5;225

I for that case wanted to use REGEX transformation

transformationPattern="REGEX:(.*?);"

Here my channel defintion as whole:

Type number : ventStep3 "Vent Step 4 Value" [ stateTopic="ebusd/wolfcwl/LuftmengeStufe3", commandTopic="ebusd/wolfcwl/LuftmengeStufe3/set", transformationPattern="REGEX:(.*?);" ]

The incomming mqtt message look like:

ebusd/wolfcwl/LuftmengeStufe3 300;50;300;5;225

the item:

Number CWLStep3Vol "Vent Step 3" { channel="mqtt:topic:vevedock:wolfCWL:ventStep3" }

As a result I am always getting following error in the log:

2019-02-15 20:05:36.451 [WARN ] [eneric.internal.generic.ChannelState] - Incoming payload '300;50;300;5;225' not supported by type 'NumberValue'

When I change the channel definition from number to string I do not get updates of the item.

What am I doing wrong here, or is it a bug?

How should I put it… . The OH 2.4 “stable” release is far from stable if you think of MQTT. It was the premiere release for the MQTT binding and a lot of fixes arrived since then. And as far as I remember also a number channel fix. It might be a good idea to change to OH 2.5M1.

Brought up the M1 docker container on my test system.
The situation seems to be the same:

2019-02-16 09:23:58.727 [WARN ] [eneric.internal.generic.ChannelState] - Incoming payload '300;50;300;5;225' not supported by type 'NumberValue'

seems to be a bug of my transformation definition is somehow wrong?

Try this REGEX:
REGEX:(.*?);.*

If you look at https://regex101.com/r/TwGHVb/1
you’ll see that regex is greedy matching.

Maybe something like “([^;]*?);” instead?

both suggestions do not work
the warning is comming from

...generic.internal.generic.ChannelState

it seems that the test of type match is done before doing transformation

What about this one: REGEX:(\d*);.*

I did following:

Changes both the channel definition and item to string/String

Type string : ventStep3 "Vent Step 4 Value" [ stateTopic="ebusd/wolfcwl/LuftmengeStufe3", commandTopic="ebusd/wolfcwl/LuftmengeStufe3/set", transformationPattern="REGEX:(.*?);.*" ]

Number CWLStep3Vol "Vent Step 3" { channel="mqtt:topic:vevedock:wolfCWL:ventStep3" }
REGEX:(.*?);.*

is not ok

2019-02-16 09:40:37.604 [vent.ItemStateChangedEvent] - CWLStep3Vol changed from UNDEF to 300;50;300;5;225
REGEX:(.*?);.*

parses ok

2019-02-16 09:42:10.394 [vent.ItemStateChangedEvent] - CWLStep3Vol changed from 300;50;300;5;225 to 300

Conclusion:

Type check is done prior to making the transformation.
I will open a case on git

You could try using a profile:
Revert your thing and item to numbers

Item:

Number CWLStep3Vol "Vent Step 3" { channel="mqtt:topic:vevedock:wolfCWL:ventStep3" [profile="transform:REGEX", function="(\d*);.*"]}

Hm. The code says no:

First the transformation is applied then then the type is determined (L168). I wonder why it does not work in your case.

I’ll give it another try

and keeping the channel as string?

I meant channel and item, both to number

I have set set :slight_smile:

Type number : ventStep3 "Vent Step 4 Value" [ stateTopic="ebusd/wolfcwl/LuftmengeStufe3", commandTopic="ebusd/wolfcwl/LuftmengeStufe3/set", transformationPattern="REGEX:(.*?);.*" ]
Number CWLStep3Vol "Vent Step 3" { channel="mqtt:topic:vevedock:wolfCWL:ventStep3" }

after restarting the container it was working as expected.
I will test on 2.4.0 and mark it resolved, and close the opened git.
seems that my setting back and forth was not accepted by the thing

Works on 2.4.0

On 2.4, OH needs to be restarted after modifying the things file
I would advise you to use the paperUI to define your things and channels instead

I separated the bridge from the things/channels and it seems that restart is not needed, mostly.
I prefer to have the definitions in files as I am heavily using Visual Studio Code.