A Go Telegram bot that provides Telegram-based access to a Yale Doorman L3 smart lock connected via Bluetooth to a Home Assistant VM. The bot talks to HA exclusively over MQTT and never holds HA credentials.
Before running the bot, the following must be set up in HA:
- Mosquitto add-on running with a
portsariMQTT user. yalexs_bleintegration paired with the lock.mqtt_statestreamconfigured inconfiguration.yaml.- A command-bridge automation subscribing to
portsari/cmd/lock.
Build the binary:
go build -o portsari ./cmd/portsariCopy deploy/config.yaml.example to /etc/portsari/config.yaml and fill in
your MQTT credentials and Telegram bot token. Set
access.bootstrap_admin_telegram_id to your own Telegram user ID for the
first run — this creates the first admin account on /start. After the first
admin exists, remove or set this field to 0.
telegram:
token: "123456:ABC-DEF1234ghIkl-zyx57W2v1u123ew11"
access:
bootstrap_admin_telegram_id: 123456789 # your Telegram IDRun directly:
./portsari --config /etc/portsari/config.yamlThe deploy/ directory contains a systemd unit and install script:
sudo bash deploy/deploy.shThis builds the binary, installs it to /usr/local/bin/portsari, installs the
systemd unit, and starts the service. The bot runs as the portsari user.
The systemd unit expects the config at /etc/portsari/config.yaml.
See deploy/config.yaml.example for a complete file. Required fields:
| Section | Key | Description |
|---|---|---|
mqtt |
broker |
MQTT broker address (host:port) |
mqtt |
username |
MQTT username |
mqtt |
password |
MQTT password |
telegram |
token |
Bot token from @BotFather |
database |
path |
Path to SQLite database file |
access |
bootstrap_admin_telegram_id |
Your Telegram ID (numeric) for first admin creation on first /start. Remove or set to 0 after the first admin account is created. |
- Regular users get a persistent keyboard with a single "Unlock" button.
Tapping it or sending
/unlockunlocks the door (subject to tier and rate limits). - Admins get the Unlock button plus an "Admin" button that opens an inline menu with: Status, Users (paged list with role/tier/remove actions), Invite (preset codes + revoke), Full log, and Broadcast.
- All slash commands have inline-keyboard equivalents and vice versa.
Admin commands (fallback surface):
| Command | Action |
|---|---|
/lock |
Lock the door |
/unlock |
Unlock the door |
/status |
Lock state, battery, last event |
/users |
List users with role/tier/status |
/invite <role> <tier> [duration] |
Create an invite code |
/revoke <code> |
Revoke an unused invite |
/setrole <id> <role> |
Change a user's role |
/settier <id> <tier> |
Change a user's tier |
/remove <id> |
Deactivate a user |
/log [n] |
Show last n access log entries |
/broadcast <msg> |
Message all active users |
Regular users do not see status, log, or management commands.
Telegram Users ←→ Go Bot ←→ Mosquitto (HA VM) ←→ Yale L3 (BLE)
The bot subscribes to HA state via mqtt_statestream and publishes lock
commands to a bot-owned MQTT topic. A single HA automation bridges command
topics to lock.lock / lock.unlock service calls.
The bot watches lock state and sensor topics and sends alerts for: unlocked, locked, jammed, battery low/critical, lock offline, and back online. Alerts are routed to all users or admins depending on severity.
MIT