Note that OH REGEX’s are ‘unique’ in that you have to match the WHOLE input line (i.e. prefix and postfix with .*). You an see from the transport I use that it matches a MAC address… Which is the identifier for each sensor I have on my 1 mqtt topic. (I actually have two REGEX’s for each sensor. Temp and Humid so you can pull multiple data from each entry just by configuring a separate channel) - I did wonder if you can pull two items per channel, but haven’t investigated how I’d do that yet and 2x channels works anyway.
Add an item to the channel. Make sure you select ‘default’ for the items profile or the item won’t get the read value set.
I’ve never understood why people use MQTT like this (it’s not you, it’s who ever implemented the firmware). One of the guiding principles of MQTT is that you should not impose a processing burden on your subscribers. Sending such diverse messages that need to be processed just to figure out whether or not you care about the message is imposing pretty heavily on the subscribers. At a minimum each sensor should have its own topic. Even better would be to skip the JSON and publish each piece of data on its own topic.
Anyway, assuming you can’t fix this at the source, the overall pattern for a REGEX filter is as follows:
where “unique string” is the unique sequence of characters that identifies this as a message the Channel cares about and $.field is the JSONPATH to the JSON field to extract. Pay close attention to the nesting in the JSON.
Given the examples above you would use something like
to extract the temperature from that specific Flora device.
When things don’t work, break it down. Create a String Channel and set it up with the REGEX filter. Does it only capture the messages that match? Once you have that working then try adding the JSONPATH transform. But do it little by little.