Using just a part of string item as a rule trigger

Hey everyone,

currently my heating has some technical issues. To not notice that something wrong by feeling that rooms are getting cold I need a info if there is a problem with the heating.
My heating can be connected to openhab and it’s working fine already. But the heating is sending “errors” in some scenarios which arent really errors. So nothing which bothers me. But as the rule can’t differ between “real errors” and “messages” my openhab is spamming my phone sometimes over the day.

Currently my rule fires if the heating status changes from “ok” to “error” (string item). Rule sends me a push which includes the message and displays the error (string item). The error string looks like this:

“2022-11-02T13:43:25 act:a dcd: – ccd:341 orig:8 cat:B fc:10 dlv:4”

Issue here is because it contains date and time the string is always different. The relevant info is for example is: “ccd:341”. So if error is 341 I don’t need the push. So if there would be a way to pick this part out of the string and place it in a different item / variabl I could check it with an if and only send message if it’s not “341”.

Is there any way to do this?

There are several ways to accomplish this.

If the part of the string that you want to look at is that consistently identifiable, then probably the easiest thing to do is to create an additional string item linked to the same channel as the first one. But then, you can use the regex transform (something like .*ccd:(\d*).*) on that second item so that it only contains the information you want to extract.

Alternatively, since you already have this information as part of a rule you can just modify that rule to filter out the notifications you don’t need. You didn’t say how you have created the rule, but if you’ve created it using UI rule builder then you can just add a condition to the rule prevents it from running when the item state doesn’t match your needs. If you have it in a rules file outside of the UI then it’s already some form of script and you can just add a couple lines that check the item state and only send the notification under the correct circumstances.

It might be possible to meet this use case with Open Reminder.

If not, I might be able to modify that rule template to handle it. One of the things I use this rule template for is to notify me when one of my sensor devices stops reporting. I use expire to set the Items to UNDEF if they don’t report for too long. That triggers a rule I created from the Open Door template which checks to see if the state changed to UNDEF (in your case you’d look fro changes from “ok” to “error”.

That rule calls my notification rule which has a condition that keeps track of what alerts it has sent in the past based on the Equipment that the Item that generated the alert came from. That way I’ll only get one alert per Equipment. You could instead use that to filter out and only alert on errors you care about.

One advantage of the rule template is you can get stuff like a Do Not Disturb period where it won’t alert you at all and the option to have the alert repeat as long as the Item remains in the alerting state. No coding required on your part.