Documentation / LemmeKnow Server

Pings

A ping is a short signal identified by a code, such as 200 or backup-done. Unlike a log, a ping isn't stored in the Monitor tab. It's meant to trigger something on your phone: a nudge or an alert built on that code.

Pings need labels from a hub

The app only acts on a ping whose code has a label that describes what the code means, such as 200 = "Build finished". Labels are a LemmeSee Hub feature: you define them in the hub's ping_messages setting, and each phone receives the labels its user may see when it connects to the hub.

LemmeKnow Server doesn't define labels. If your phone is connected only to LemmeKnow Server, it ignores every ping. To get notified from a script without the hub, send a log at warning, important, or error and build a rule on it.

Codes that read as a whole number of zero or less, such as 0 or -3, are reserved for the app's own events, such as a server going offline. The app ignores them when they arrive from a server. See Filter expressions for the built-in pings.

Sending a ping

import log_client

log_client.SOURCE = "build"
log_client.ping("200", "Build 1432 finished", public=True)
ArgumentDefaultMeaning
code(required)The ping code, as text. It must match a label defined on the hub.
message""Optional text sent along with the ping.
sourcelog_client.SOURCESource name sent with the ping.
publicFalseTrue sends to the public channel, False to the private one. See Public and private channels.
user_topic_idNoneHub only. Sends the ping to one user only, and overrides public. See Messages for one user.

The Logger class has a matching method, log.ping(code, message="", public=True). Note its different default: public.

Like log calls, ping() waits up to 5 seconds for the broker to confirm, and prints [log_client] ping publish failed: ... instead of raising an error if it can't.

Sending without the helper

Publish a JSON message, not retained, to one of:

lemmeknow/<server_id>/ping/public/<code>
lemmeknow/<server_id>/ping/private/<code>
lemmeknow/<server_id>/ping/<topic_id>

The last form, for one user, needs the hub.

FieldMeaning
codeThe ping code. Required.
sourceSource name.
msgOptional message text.
tsTime in milliseconds (Unix epoch).
mosquitto_pub -h 192.168.1.10 -p 1883 -q 1 \
  -t 'lemmeknow/a1b2c3d4/ping/public/200' \
  -m '{"code":"200","source":"build","msg":"Build 1432 finished","ts":1761200000000}'

In the topic, the code has /, +, # and whitespace stripped out, so keep codes to plain letters, digits and dashes. The app reads the code from the code field of the message.

The app also treats a log line whose level is ping:<code> (for example ping:200) as a ping with that code.