Documentation / LemmeKnow Server

Installing the server

LemmeKnow Server is a minimal Python program with no installer needed. These steps describe what the program needs to run the files.

What you need

  • A host device that stays on while you want your phone to see it, running 64-bit Windows 10 or 11, or Linux (signed-in phones need a 64-bit Intel or AMD PC). See Supported platforms.
  • Python 3.10 or later.
  • A Mosquitto MQTT broker, on the same device, or somewhere on your network. See Setting up Mosquitto.
  • The LemmeKnow app on your phone, with Premium, to connect to the server.

The files

Download LemmeKnow Server from Downloads and unzip it. The zip holds one LemmeKnow folder with these files, which stay together:

FileWhat it is
lemmeknow.pyThe server program.
config.pyYour settings: broker address, heartbeat interval, hub URL. See Configuration.
log_client.pyThe helper your scripts import to send logs and pings. See Logs.
user_manager.pyA command-line tool for optionally managing users. See Users and authentication.
autologger.py, autologger_config.py, formatsAn optional tool that sends the entries of existing log files as log lines. See Autologger.

The server keeps its data in a database file named lemmeknow.db, at the path you set as DB_PATH in config.py. With sign-in on (AUTH_ENABLED, the default) the server won't start until DB_PATH is set. That file holds the server id (a short unique code that scopes every MQTT topic) and any users you create. If you also run the LemmeSee Hub on this PC, point both at the same file, they will both use the same data as it applies to their functions.

Install the Python package

The server and the helper need one package, the Paho MQTT client.

Windows

Install it from the server's folder:

pip install -r requirements-server.txt

That's the same as pip install paho-mqtt.

Linux

Install it from your distribution. Recent Debian and Ubuntu releases block pip install outside a virtual environment, so on those use:

sudo apt install python3-paho-mqtt

Use python3 wherever these pages say python.

Install Mosquitto

If you don't already have Mosquitto installed, install it first. For the simplest setup, an open broker on your home network, give it a listener for phones and start it.

Windows

winget install EclipseFoundation.Mosquitto

Add these lines to mosquitto.conf in the Mosquitto folder (usually C:\Program Files\mosquitto), then start the service. Both need an administrator: open your editor and the command prompt with Run as administrator.

listener 1883
allow_anonymous true
net start mosquitto

Linux

sudo apt install mosquitto mosquitto-clients

The package starts Mosquitto as a service right away and at every boot. Save these lines as /etc/mosquitto/conf.d/lemmeknow.conf, then restart it:

listener 1883
allow_anonymous true
sudo systemctl restart mosquitto

To make phones sign in with an access key instead, see Setting up Mosquitto.

First run

Edit config.py so MQTT_BROKER and MQTT_PORT point at a broker listener that allows anonymous access, and set DB_PATH (or set AUTH_ENABLED = False on an open broker). Then start the program from its folder:

Windows

python lemmeknow.py

Linux

python3 lemmeknow.py

You should see a line like this assuming its a local set up with port 1883:

LemmeKnow starting  host=MYPC  broker=localhost:1883  server_id=a1b2c3d4

If successful, this will be followed by [mqtt] connected to localhost:1883 once the broker accepts the connection. If you see [mqtt] can't reach localhost:1883, retrying instead, the broker isn't running or isn't on that address and port. The server keeps retrying, so it connects as soon as the broker is up. If the LemmeSee Hub isn't running, you'll also see [auth] serving /internal/auth on 127.0.0.1:8765, which means the sign-in check is ready.

On its first connection after starting, the server sends one public log line, lemmeknow started, from the source lemmeknow. If your phone is already connected, it appears in the Monitor tab.

Only one copy of the server runs at a time. If you start it while it is already running, it prints already running and exits.