lukics
(Slaviša Lukić)
February 15, 2019, 7:09pm
1
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?
lukics:
2.4 version.
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.
lukics
(Slaviša Lukić)
February 16, 2019, 8:29am
3
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?
vzorglub
(Vincent Regaud)
February 16, 2019, 8:33am
4
lukics:
300;50;300;5;225
Try this REGEX:
REGEX:(.*?);.*
lukics:
300;50;300;5;225
If you look at regex101: build, test, and debug regex
you’ll see that regex is greedy matching.
Maybe something like “([^;]*?);” instead?
lukics
(Slaviša Lukić)
February 16, 2019, 8:38am
6
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
vzorglub
(Vincent Regaud)
February 16, 2019, 8:49am
7
vzorglub:
(.?);.
What about this one: REGEX:(\d*);.*
lukics
(Slaviša Lukić)
February 16, 2019, 8:49am
8
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
vzorglub
(Vincent Regaud)
February 16, 2019, 9:03am
9
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:
return;
}
if (cachedValue.isBinary()) {
cachedValue.update(payload);
channelStateUpdateListener.updateChannelState(channelUID, cachedValue.getChannelState());
receivedOrTimeout();
return;
}
// String value: Apply transformations
String strvalue = new String(payload, StandardCharsets.UTF_8);
for (ChannelStateTransformation t : transformationsIn) {
strvalue = t.processValue(strvalue);
}
// Is trigger?: Special handling
if (config.trigger) {
channelStateUpdateListener.triggerChannel(channelUID, strvalue);
receivedOrTimeout();
return;
First the transformation is applied then then the type is determined (L168). I wonder why it does not work in your case.
lukics
(Slaviša Lukić)
February 16, 2019, 9:51am
12
and keeping the channel as string?
vzorglub
(Vincent Regaud)
February 16, 2019, 9:52am
13
I meant channel and item, both to number
lukics
(Slaviša Lukić)
February 16, 2019, 10:03am
14
David_Graeff:
Hm. The code says no:
I have set set
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
vzorglub
(Vincent Regaud)
February 16, 2019, 10:26am
16
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
lukics
(Slaviša Lukić)
February 18, 2019, 11:36am
17
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.