[SOLVED] Getting only the message from event log

I am using LogReader as add on for getting messages from my log and it work like a charm but…

What I want now is to get some of my custom message to be used in my rule and txtToSpeach it and show it as last notification on an Item…

LogReader output the whole message (with datestamp and all the rest) example:

2019-05-09 15:41:43.875 [WARN ] [home.model.script.Presence rules log] - Time of day set to DAY

What I want is everything after the -
Here what I’ve tried so far on this regex tester

I’ve put it on my rule like that:

val newValue = transform("REGEX", "(?<=- ).*", logreaderLastWarning.state.toString)
gSG_Notifications.sendCommand(newValue)

It output nothing: (empty received command)

2019-05-11 08:58:14.935 [ome.event.ItemCommandEvent] - Item 'gSG_Notifications' received command 

I know that my regex addon is working and I’ve try it on the item itself.

I need an openHab regex guru here…

The are two important things about regex in openHAB.

  1. The expression must match the entire string
  2. Only the parts in parens gets returned.

So at a minimum you have the parens in the wing place.

But I have no idea what ?<=- would match but I can’t see how it can possibly match the parts you want.

Something like .*model\.script.*\] - (.*) aught o work.

Ahhh ! I Understand!!!

So I do:

val newValue = transform("REGEX", ".* - (.*)", logreaderLastWarning.state.toString)

I’ts soooo simple with your explanations!!!

Another option without Regex :

		val lines = log.split(" - ")
		Alarm_Comment.postUpdate(lines.get(1))
1 Like