Documentation / LemmeSee Hub

Installing the hub

The LemmeSee Hub is a Python program with a web UI. There is no installer needed because by its very nature the LemmeSee Hub requires high levels of customization and knowledge of the files involved. This page describes what the hub needs and how to start it from its files.

Download the LemmeSee Hub from Downloads and unzip it where you want the hub to live. The zip holds one LemmeSee folder, which is the hub folder this documentation refers to.

What you need

  • A PC that stays on while you want your phone running LemmeKnow to reach the hub, running 64-bit Windows 10 or 11, or 64-bit Intel or AMD Linux. See Supported platforms.
  • Python 3.10 or later.
  • A Mosquitto MQTT broker on the same PC. The hub publishes everything through it, so the broker is required. See MQTT and Mosquitto.
  • LemmeKnow Server on the same PC. Phones get the heartbeat that turns the server's status dot green, and the config message that tells them the hub's web address, from LemmeKnow Server rather than from the hub. Running it as a hub daemon task is the preferred setup, so the hub starts, stops, and restarts it for you. See LemmeKnow Server and its HUB_URL setting.
  • The LemmeKnow app on your phone, with Premium, to connect to the hub. See Free and Premium.

Install the Python packages

The hub folder contains a requirements.txt file listing the packages it uses (FastAPI, Uvicorn, Paho MQTT, APScheduler, and others). URL watchers can also render pages that need JavaScript with a headless Chromium browser; if you plan to use that option, download the browser once after installing the packages.

Windows

Install the packages from the hub folder:

pip install -r requirements.txt

For the browser:

playwright install chromium

Linux

Recent Debian and Ubuntu releases block pip install outside a virtual environment, so give the hub its own in the hub folder. From the hub folder:

sudo apt install python3-venv
python3 -m venv .venv
.venv/bin/pip install -r requirements.txt

The hub then runs with .venv/bin/python, and so does every script and daemon it starts.

For the browser, install the libraries it needs and then the browser itself:

sudo .venv/bin/playwright install-deps chromium
.venv/bin/playwright install chromium

See Watchers.

Create config.json

The hub reads its settings from config.json in the hub folder. The download includes config.example.json, a bare template with the common settings; copy it to config.json and set db_path. That's the only setting the hub can't start without: the full path of the database file where it keeps users, tasks, webhooks, feeds, and its settings. The file is created on first start if it doesn't exist.

The smallest file that works:

{
  "mqtt":   { "broker": "localhost", "port": 1883 },
  "server": { "host": "0.0.0.0", "port": 8765 },
  "db_path": "/path/to/lemmeknow.db"
}

Point db_path at the same lemmeknow.db file LemmeKnow Server uses, so both share one server id and one set of users. Every setting is described in Configuration.

Start the hub

Start Mosquitto first; the hub needs to reach it. See MQTT and Mosquitto.

The hub reads config.json from the folder you start it in, so start it from the hub folder:

Windows

python hub.py

Linux

.venv/bin/python hub.py

If ufw is active (sudo ufw status), allow the hub's port so phones can reach it:

sudo ufw allow 8765/tcp

When it's up, it prints the addresses of its web UI:

[lemmesee] web UI
  local    http://localhost:8765
  network  http://192.168.1.10:8765

An external line also appears when the hub can work out your public address. Open the local address in a browser on the same PC to reach the web UI.

When the hub runs without a console window, such as from Task Scheduler or as a systemd service, everything it prints goes to restart.log in the logs folder inside the hub folder instead.

To stop the hub, press Ctrl+C in its console. Stopping the hub also stops every daemon it supervises.

The tray icon

Windows

While the hub runs on your desktop, a LemmeSee icon sits in the Windows system tray. Click it to open the web UI. Right-click it for Open Web UI, Show Log, which opens the folder holding restart.log, and Quit, which stops the hub.

Linux

Run as a service, the hub has no tray icon. Open the web UI in a browser, and stop the hub with sudo systemctl stop lemmesee.

Start automatically

Windows

The preferred setup on Windows is a Task Scheduler task that starts the hub with pythonw.exe when you sign in. pythonw.exe runs it without a console window, the tray icon gives you a web UI and log shortcut. Starting at sign-in rather than at boot matters: only a hub running on your desktop can show the tray icon.

You can create the task from PowerShell. Replace the paths with your Python install and the hub folder:

$a = New-ScheduledTaskAction -Execute "C:\Python310\pythonw.exe" -Argument "hub.py" -WorkingDirectory "C:\LemmeSee"
$t = New-ScheduledTaskTrigger -AtLogOn -User $env:USERNAME
$s = New-ScheduledTaskSettingsSet -ExecutionTimeLimit ([TimeSpan]::Zero) -RestartCount 60 -RestartInterval (New-TimeSpan -Minutes 1) -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries
Register-ScheduledTask -TaskName "LemmeSee Hub" -Action $a -Trigger $t -Settings $s

The working directory has to be the hub folder, because that's where the hub reads config.json. The settings take away Task Scheduler's default three-day time limit, so the hub isn't stopped after three days, and also restart it a minute after it fails. Run Start-ScheduledTask "LemmeSee Hub" to start it now, and Unregister-ScheduledTask "LemmeSee Hub" to remove it.

To set it up in Task Scheduler instead:

  • Open Task Scheduler and choose Create Task.
  • On the Triggers tab, add a trigger: At log on.
  • On the Actions tab, add an action: Start a program. Set Program to your pythonw.exe, Add any arguments to hub.py, and Start in to the hub folder.
  • On the Settings tab, turn on If the task fails, restart every 1 minute, and turn off Stop the task if it runs longer than.
  • On the Conditions tab, turn off Start the task only if the computer is on AC power.
  • Save the task.

Linux

Run the hub as a systemd service. Save this as /etc/systemd/system/lemmesee.service, with User set to the account that owns the hub folder and the paths set to where you unzipped it:

[Unit]
Description=LemmeSee Hub
After=network-online.target mosquitto.service
Wants=network-online.target

[Service]
User=you
WorkingDirectory=/home/you/LemmeSee
ExecStart=/home/you/LemmeSee/.venv/bin/python hub.py
Restart=on-failure
RestartSec=10

[Install]
WantedBy=multi-user.target

The working directory has to be the hub folder, because that's where the hub reads config.json. Then turn it on and start it:

sudo systemctl daemon-reload
sudo systemctl enable --now lemmesee

systemctl status lemmesee shows whether it's running. Its output goes to logs/restart.log in the hub folder.

Then add LemmeKnow Server as a daemon task in the hub, so the hub handles it. See Tasks and Running at startup.