diff --git a/bundles/org.openhab.binding.mail/README.md b/bundles/org.openhab.binding.mail/README.md index 06cfe9dede9..2d5e58fc69c 100644 --- a/bundles/org.openhab.binding.mail/README.md +++ b/bundles/org.openhab.binding.mail/README.md @@ -69,7 +69,10 @@ Filters use regular expressions (e.g. `.*DHL.*` as `sender` would match all From If a parameter is left empty, no filter is applied. The `transformation` is applied before setting the channel status. -Transformations can be chained by separating them with the mathematical intersection character "∩", e.g. `REGEX:.*Shipment-Status: ([a-z]+).*∩MAP:status.map` would first extract a character string with a regular expression and then apply the given MAP transformation on the result. +Transformations are defined using this syntax: `TYPE(FUNCTION)`, e.g.: `JSONPATH($.path)`. +The syntax: `TYPE:FUNCTION` is still supported, e.g.: `JSONPATH:$.path`. +Transformations can be chained in the UI by listing each transformation on a separate line, or by separating them with the mathematical intersection character "∩". +For example, `REGEX(.*Shipment-Status: ([a-z]+).*) ∩ MAP(status.map)` would first extract a character string with a regular expression and then apply the given MAP transformation on the result. Please note that the values will be discarded if one transformation fails (e.g. REGEX did not match). This means that you can also use it to filter certain emails e.g. `REGEX:(.*Sendungsbenachrichtigung.*)` would only match for mails containing the string "Sendungsbenachrichtigung" but output the whole message. diff --git a/bundles/org.openhab.binding.mail/src/main/java/org/openhab/binding/mail/internal/config/POP3IMAPContentChannelConfig.java b/bundles/org.openhab.binding.mail/src/main/java/org/openhab/binding/mail/internal/config/POP3IMAPContentChannelConfig.java index 058585e48eb..b9f6007aaf0 100644 --- a/bundles/org.openhab.binding.mail/src/main/java/org/openhab/binding/mail/internal/config/POP3IMAPContentChannelConfig.java +++ b/bundles/org.openhab.binding.mail/src/main/java/org/openhab/binding/mail/internal/config/POP3IMAPContentChannelConfig.java @@ -12,6 +12,8 @@ */ package org.openhab.binding.mail.internal.config; +import java.util.List; + import org.eclipse.jdt.annotation.NonNullByDefault; import org.eclipse.jdt.annotation.Nullable; @@ -25,7 +27,7 @@ public class POP3IMAPContentChannelConfig { public @Nullable String folder; public String subject = ""; public String sender = ""; - public @Nullable String transformation; + public @Nullable List transformation; public boolean markAsRead = false; } diff --git a/bundles/org.openhab.binding.mail/src/main/resources/OH-INF/i18n/mail.properties b/bundles/org.openhab.binding.mail/src/main/resources/OH-INF/i18n/mail.properties index 2a8b1251cf6..1fc84fc970e 100644 --- a/bundles/org.openhab.binding.mail/src/main/resources/OH-INF/i18n/mail.properties +++ b/bundles/org.openhab.binding.mail/src/main/resources/OH-INF/i18n/mail.properties @@ -37,7 +37,7 @@ channel-type.config.mail.content.sender.description = A (regular expression) fil channel-type.config.mail.content.subject.label = Subject Filter channel-type.config.mail.content.subject.description = A (regular expression) filter for the mail subject. channel-type.config.mail.content.transformation.label = Transformation -channel-type.config.mail.content.transformation.description = Transformation pattern used when processing messages. Multiple transformation can be chained using "∩". +channel-type.config.mail.content.transformation.description = Transformation pattern used when processing messages. Multiple transformations can be chained by listing each transformation on a separate line, or by concatenating them with "∩". channel-type.config.mail.mailcount.folder.label = Folder Name channel-type.config.mail.mailcount.type.label = Counter Type channel-type.config.mail.mailcount.type.option.UNREAD = Unread diff --git a/bundles/org.openhab.binding.mail/src/main/resources/OH-INF/thing/thing-types.xml b/bundles/org.openhab.binding.mail/src/main/resources/OH-INF/thing/thing-types.xml index dd68b3519af..d4b42fc652c 100644 --- a/bundles/org.openhab.binding.mail/src/main/resources/OH-INF/thing/thing-types.xml +++ b/bundles/org.openhab.binding.mail/src/main/resources/OH-INF/thing/thing-types.xml @@ -150,9 +150,11 @@ A (regular expression) filter for the mail sender address. - + - Transformation pattern used when processing messages. Multiple transformation can be chained using "∩". + Transformation pattern used when processing messages. Multiple transformations can be chained by + listing + each transformation on a separate line, or by concatenating them with "∩".