[SOLVED] HOW transformationPattern=REGEX works on 2.4

Hi,
i have an mqtt topic that return
OFF 12315161
or
ON 15616814
and i want to separate the first word that is the command ( ON/OFF ) from the secondo word ( the timestamp )
i have tried to use

Type switch : state_arm_disarm “Alarm Arm State [%s]” [ stateTopic=“Paradox/Partition”, transformationPattern=“REGEX:^\S*” ]

but i get this error
Configuration model ‘mqtt.things’ has errors, therefore ignoring it: [5,114]: mismatched character ‘S’ expecting set null

[5,124]: no viable alternative at input ‘*’

[5,125]: mismatched character ‘<EOF>’ expecting ‘"’

i have tried also with

Type switch : state_arm_disarm “Alarm Arm State [%s]” [ stateTopic=“Paradox/Partition”, transformationPattern=“REGEX:(^\s*)” ]

REGEX transforms must match the full message and the part you want returned in parens. So something like REGEX:^(ON|OFF).* should work.

When dealing with \, often it is necessary to escape it, \\.

If you have access to the source code of the MQTT sender then I would recommend that you change the way the data is sent.
This a bit of a misuse of MQTT, you should be sending two payloads in 2 topics if possible.
Paradox/Partition/State : ON
Paradox/Partition/Value : 12315161

This way you can link your channels directly, no transformation needed and easier to maintain with a MQTT tool

1 Like

thx rlkoshak for the solution
thx u