Documentation / LemmeKnow Server

Configuration

LemmeKnow Server reads its settings from config.py, a small Python file kept in the same folder as lemmeknow.py. Each setting is a plain Python assignment. Restart the server after you change it.

To keep config.py in a different folder, set the LEMMEKNOW_CONFIG_DIR environment variable to that folder. A config.py next to lemmeknow.py still takes priority. The helper and user_manager.py look for it the same way.

Server settings

SettingDefaultMeaning
MQTT_BROKER"localhost"Address of the Mosquitto broker. Use "localhost" when the broker is on the same PC, or its address on your network, such as "192.168.1.10".
MQTT_PORT1883Broker port the server connects to.
MQTT_KEEPALIVE60Seconds between MQTT keepalive checks on the server's connection.
HEARTBEAT_INTERVAL300Seconds between heartbeats. The app uses this to decide when the PC counts as offline.
HUB_URL""Full URL of a LemmeSee Hub, such as "https://hub.example.com". When set, the server sends it to the app, which fills in the server's Hub URL for you. The app takes only an https:// address, because your access key is sent to it. This is how phones learn the hub's web address, so set it on the hub's PC; leave it empty if you don't use the hub.
AUTH_ENABLEDTrueWhether the server runs its sign-in check for phones. Set it to False on an open broker, where nothing uses the check. See Users and authentication.
DB_PATH""Full path of the server's database file. Required while AUTH_ENABLED is on: the server won't start with it empty. With sign-in off, empty means lemmeknow.db in the same folder as lemmeknow.py. If you also run the LemmeSee Hub, point both at the same file.

Every setting is optional. A setting you leave out takes the default shown.

A minimal file looks like this:

MQTT_BROKER        = "localhost"
MQTT_PORT          = 1883
MQTT_KEEPALIVE     = 60
HUB_URL            = ""
HEARTBEAT_INTERVAL = 300

The server connects to the broker without a username or password, so point it at a listener that allows anonymous access. See Setting up Mosquitto.

Heartbeat interval and the phone

The app marks the PC offline when no heartbeat arrives within the server's Heartbeat Timeout. A server you add without a Heartbeat Timeout gets one set automatically from the first config message: twice HEARTBEAT_INTERVAL. With the default of 300 seconds, the phone marks the PC offline after about 10 minutes without a heartbeat.

If you lower HEARTBEAT_INTERVAL to notice outages sooner, the phone keeps the timeout it already saved, so update Heartbeat Timeout in the server editor too. It must be greater than the interval.

Settings the helper reads

log_client.py reads MQTT_BROKER, MQTT_PORT, and DB_PATH from the same config.py when it can find it, so scripts in the server's folder publish to the same broker and find the same server id. If it can't import config.py, it uses a built-in placeholder address, and you set the broker in your script instead:

import log_client
log_client.MQTT_BROKER = "192.168.1.10"
log_client.MQTT_PORT = 1883

Set these before the first log call. See Logs.

Other settings in the file

Your config.py may contain settings that LemmeKnow Server itself doesn't read, for example ones used by other scripts that share the file. They're harmless. The server reads only the settings in the table above.