Documentation / LemmeKnow

Filter expressions

A filter decides which incoming messages a rule matches. It looks at the content of what arrived: its text, source, level, link, and so on. A rule with no filter matches everything from its app and channel.

Filters are about content. To pause or fire rules based on the phone's state (time, Wi-Fi, battery), use conditions instead.

Building a filter

The filter builder in the rule editor is a tree of groups and filters.

  • Each group is either All (every item in it must match) or Any (at least one must match). Tap the toggle at the top of a group to switch.
  • The add row at the bottom of each group has a button for each available field, a Group button to nest another group, and, for some rules, level buttons.
  • Groups can nest as deep as you need, and every group has a TRUE/FALSE switch. FALSE reverses the whole group.
  • Drag the handle to reorder filters and groups within their group.

Each filter row reads as a sentence: the field, a comparison, and a value, for example Message contains disk full. Tap any part of the row to open the filter editor, which has a Comparison dropdown and a Value. To change a filter's field, delete it with ✕ and add a different one.

Copy and Paste below the tree copy a whole filter between rules of the same kind (Alert and Nudge rules share one clipboard, Notify and Silence rules another).

Comparisons

All comparisons ignore upper and lower case.

ComparisonMatches when
contains / does not containThe field includes the value anywhere
equals / does not equalThe field is exactly the value
starts with / does not start withThe field begins with the value
exists / does not existThe named field is present on the item (Field filters only; no value needed)
is / is notThe ping is the one picked from the list (Ping filters only)

Fields

FieldContains
MessageThe main text. For a notification from another app, its title and text together. For a feed item, its title and content.
HeaderThe title: a notification's title or a feed item's title. For server messages this is the message text which is the same as the Message field.
DetailThe body: a notification's expanded text, or a feed item's content. Empty for server messages.
SourceThe source label of a server message or feed item
LinkA feed item's link, followed by any other links in its content, separated by spaces
FieldNamed values some feeds attach to items (see below)
PingThe code of a ping from a server or feed (see below)
Nudged byThe name of the Notify rule that sent a self-nudge
RequestMatches only requests from a server asking for your approval

Level isn't a field you type. Instead, the level buttons (Debug, Info, Important, Warning, Error) add a filter for that level, with a TRUE/FALSE switch.

Which fields each rule gets

RuleFields
Notify or SilenceMessage, Header, Detail, Source, Field, Link, plus level buttons
Alert with no channel, or for another appMessage, Header, Detail, Source, Field, Link
Alert for a LemmeKnow channelPing, Message, Header, Detail, Source, Field, Link
NudgePing, Source, Message
Self-Nudge mode (Alert or Nudge)Nudged by, Message, Header, Detail, Source, Field, Link, plus level buttons

Request is added for LemmeKnow rules (other than Nudge) scoped to Any Server or to a specific server. Approvals are covered in Approvals.

If you change a rule's channel or mode so that some of its filters don't apply, saving asks you to remove them: Remove fields not valid for this rule type.

The Field filter

Some feeds, such as feeds from a LemmeSee hub, attach named values to each item, like status or size. A Field filter has a Name as well as a value:

  • equals with Name status and Value ok matches an item whose status value is ok.
  • exists with Name status matches any item that has a status value at all.
  • contains and starts with compare against the item's named values written as name:value.

Pings

Servers and feeds can send pings, short coded events that Nudge and Alert rules respond to. A server's own pings need labels from a LemmeSee hub: LemmeKnow acts only on codes the hub has labelled. When you add a Ping filter on a rule scoped to a server, the value becomes a list of that server's pings by name, such as [disk-high], and the comparison is is or is not. If the hub later changes its labels and a saved ping doesn't match any of them, the rule shows a warning. See Pings for sending pings and ping_messages for the hub's labels.

LemmeKnow also sends built-in pings of its own. Their codes are zero or negative, and every such code is reserved for them: the app ignores a server's pings with a code of zero or less.

CodeNameSent when
0Server onlineA server comes back after being offline
-1Server offlineA server stops sending heartbeats
-2Server offline (sustained)A server stays offline for the minutes set in its settings
-3Server degraded (sustained)A server stays in a warning state for the minutes set in its settings
-4State entered alarmOne of the hub's states goes into alarm
-5Action requestedA hub sends a request for your approval
-6Feed optionsA feed item arrives with buttons you can press

For rules scoped to a feed, the list offers Action requested and Feed options.

Tokens in filter values

A filter value, and a Field filter's name, can include tokens such as {{item.source}} or {{now.weekday}}. They're filled in each time a message is checked, before comparing. Secrets can't be used in filters.

Script mode

Notify rules with Premium can use Script mode instead of the builder: a JavaScript snippet that sets result to true when the rule should match. See Rule modes in Notification rules.