I am fairly new to openHAB, and I really love what everyone has been doing! I am using openHAB2.
My problem is around understanding REGEX. I have done quite a bit of research and just when I think I understand it, it does not work… Here we go:
In there a proper guide on REGEX and I think the flavour that works in openHAB. I have tried emulators that’s on the web, but that expression does not seem to work in openHAB.
I want to use regex in the Items file, which will avoid lots of scripts and rules. I have the following data from MQTT:
S:OPEN,P:1,N:"Workshop IR"
or
S:CLOSED,P:1,N:“Workshop IR”
And I need just the OPEN or CLOSED statements. I have tried various different one’s, but I am missing something. I have been using this site to test the expressions. https://regex101.com
Here is a sample of what I have tried:
String WorkshopIR “Workshop IR [%s]” (Alarm) {mqtt="<[mosquitto:Paradox/ZS/Z9:state:REGEX((OPEN)|(CLOSED))
]"}
Can’t remember the rest… but there has been plenty.
Please help? I would like to understand this, so I don’t have to ask…
Which paradox binding are you using? I’ve been playing with the v2 one, and have changed it to use logging, and also to output each zone to their own item (rather than requiring regex).
eg:
Paradox/Zone/Main Door ON
Paradox/Zone/Main Door OFF
So each sensor (as named in babyware) make their own Paradox/Zone/[zone name] entry meaning you can easily add each to a switch.
I’ve also added the partition arm/disarm to a similar item.
I think, looking at your entries of ZS etc you;'re using v1 of the paradox binding.
You are 100% correct, I am using V1. Question on V2, can you still use the iParadox app if the binding is connected to the system. As far as I have it when a user is connected, a second user can’t. That’s why I went for now with V1 as it binds to the web port. I have a 192Evo system.
The change you made to the logging, can it be done in V1 and how is it done?
I would still be happy to understand the regex, sure I will have to use it somewhere…
Sorry for the time, but I only got to this now again.
I have tried with what you suggested but i get the following error:
2017-03-01 20:06:53.024 [ERROR] [.mqtt.internal.MqttMessageSubscriber] - Error processing MQTT message.
java.util.regex.PatternSyntaxException: Unmatched closing ‘)’ near index 8
(.?),P.)
With the ^ pointing to the last * in the code. I tried adding another closing bracket, but that makes it not match an opening bracket. I also tired removing the * and the ,P.* - No luck…
And it resolve I think correctly, however openHAB does not think so. It said this:
Match 1
Full match
0-8 S:OPEN,P
Group 1.
n/a S:OPEN,P
Group 2.
n/a OPEN
Thanks, but I still don’t get it right… most of the stuff I tried gives me errors and I even added another “:” in the mqtt string, got a different error, but still no luck. 3hours later…
I got the map function working although i think this is not ideal
Contact WorkshopIR "Workshop IR [%s]" (Alarm) {
mqtt="<[mosquitto:Paradox/ZS/Z9:state:REGEX(.*(OPEN|CLOSED).*):.*Workshop IR.*]"
}
The REGEX(.*(OPEN|CLOSED).*) ought to capture that part of the string, which is directly usable by Contact items. The section after the next colon .*Workshop IR.* is meant to restrict the messages considered for this item to only those that match that RegEx, so this topic could be used for other IR devices as well.
If you can think of improvements to the README.md files here, making sure the improvements are relevant to Eclipse SmartHome, please submit pull requests!