I have an MQTT message which looks like this:
TIME:0,INTE:21.90,INHU:33.68
I am trying to bind the INTE key’s value (in this example 21.90) to a Number item using a REGEX transformation. It wasn’t working, so I made it a String, and matched the entire message with REGEX:
String main_temperature "mainT [%.1f]" {mqtt="<[seal:weather:state:REGEX((.*))]" }
That worked, i.e. it gave the entire message. I added more of the message outside the capture group, and eventually got the value I wanted with this REGEX:
String main_temperature "mainT [%.1f]" {mqtt="<[seal:weather:state:REGEX(.*INTE.(.*),.*)]" }
Notice the single character pattern match “.” just after INTE to match the colon in the message. I would rather have an explicit colon, but this binding
String main_temperature "mainT [%.1f]" {mqtt="<[seal:weather:state:REGEX(.*INTE:(.*),.*)]" }
gives me an error, I think becase it sees the colon and thinks I am on to the next clause in the MQTT binding,
2017-12-28 13:25:29.196 [ERROR] [.mqtt.internal.MqttMessageSubscriber] - Error processing MQTT message.
java.util.regex.PatternSyntaxException: Unmatched closing ')' near index 6
(.*),.*)
And if I try escaping the colon like this “\:”
String main_temperature "mainT [%.1f]" {mqtt="<[seal:weather:state:REGEX(.*INTE\:(.*),.*)]" }
I get an error about bad configuration:
2017-12-28 13:27:50.993 [WARN ] [el.core.internal.ModelRepositoryImpl] - Configuration model 'mqtt.items' has errors, therefore ignoring it: [4,46]: mismatched character ':' expecting set null
[4,82]: mismatched input '(' expecting RULE_STRING
[4,87]: mismatched input '.' expecting RULE_ID
[4,91]: mismatched character '<EOF>' expecting '"'
How do I exactly match a colon in MQTT binding REGEX?