Initial Home Assistant add-on skeleton for Clawdbot (Papur)
This commit is contained in:
@@ -0,0 +1,37 @@
|
|||||||
|
# Papur (Clawdbot) Home Assistant Add-on (Draft)
|
||||||
|
|
||||||
|
This is a starter Home Assistant add-on wrapper to run **Clawdbot** as a Supervisor-managed container on **HAOS**.
|
||||||
|
|
||||||
|
## What this gives you
|
||||||
|
- Always-on Clawdbot instance on your HAOS host
|
||||||
|
- Separate bot identity (you will provide a new Telegram bot token)
|
||||||
|
- Persistent storage in `/data` inside the add-on (maps to HAOS add-on data folder)
|
||||||
|
|
||||||
|
## Notes / constraints
|
||||||
|
- This is a **headless** deployment; browser automation via Chrome-extension relay won’t be available.
|
||||||
|
- You can still do LAN automation (MikroTik/HA API, cron reminders, etc.).
|
||||||
|
|
||||||
|
## Install overview (high level)
|
||||||
|
1. Put this repo on GitHub (or local git).
|
||||||
|
2. In Home Assistant: **Settings → Add-ons → Add-on Store → ⋮ → Repositories**
|
||||||
|
3. Add the repo URL.
|
||||||
|
4. Install the add-on and configure the options.
|
||||||
|
|
||||||
|
## Configuration
|
||||||
|
You’ll set options in the add-on UI (Telegram token + optional HA token + MikroTik connection hints). See `papur-addon/config.yaml` schema.
|
||||||
|
|
||||||
|
### MikroTik key
|
||||||
|
For MikroTik access, put the private key file inside the add-on data folder:
|
||||||
|
- host path (HAOS): `/addon_configs/<addon_slug>/keys/mikrotik_papur_nopw`
|
||||||
|
- in-container path: `/data/keys/mikrotik_papur_nopw`
|
||||||
|
|
||||||
|
(Exact host path may vary; easiest is using File editor / Samba share to place the key under the add-on’s data directory.)
|
||||||
|
|
||||||
|
## Logs
|
||||||
|
View logs in the add-on UI.
|
||||||
|
|
||||||
|
## Next steps
|
||||||
|
If you want, I can tailor:
|
||||||
|
- default config for Telegram routing
|
||||||
|
- persistent memory paths
|
||||||
|
- optional Home Assistant token mounting (for HA integration skill)
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
*.log
|
||||||
|
*.sqlite
|
||||||
|
/data/
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
ARG BUILD_FROM=ghcr.io/hassio-addons/base:14.0.2
|
||||||
|
FROM ${BUILD_FROM}
|
||||||
|
|
||||||
|
# Base image is Alpine. Install node + git so we can install clawdbot.
|
||||||
|
RUN apk add --no-cache \
|
||||||
|
nodejs \
|
||||||
|
npm \
|
||||||
|
git \
|
||||||
|
bash \
|
||||||
|
openssh-client \
|
||||||
|
ca-certificates \
|
||||||
|
tzdata \
|
||||||
|
jq
|
||||||
|
|
||||||
|
# Install clawdbot globally
|
||||||
|
RUN npm config set fund false && npm config set audit false \
|
||||||
|
&& npm install -g clawdbot
|
||||||
|
|
||||||
|
COPY run.sh /run.sh
|
||||||
|
RUN chmod +x /run.sh
|
||||||
|
|
||||||
|
CMD [ "/run.sh" ]
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
build_from:
|
||||||
|
amd64: ghcr.io/hassio-addons/base:14.0.2
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
name: Papur (Clawdbot)
|
||||||
|
version: "0.1.0"
|
||||||
|
slug: papur_clawdbot
|
||||||
|
description: Run Clawdbot (Papur) as a Home Assistant add-on.
|
||||||
|
url: https://github.com/YOURNAME/ha-addon-papur
|
||||||
|
arch:
|
||||||
|
- amd64
|
||||||
|
startup: services
|
||||||
|
boot: auto
|
||||||
|
init: false
|
||||||
|
hassio_api: false
|
||||||
|
homeassistant_api: false
|
||||||
|
host_network: true
|
||||||
|
map:
|
||||||
|
- addon_config:rw
|
||||||
|
options:
|
||||||
|
telegram_bot_token: ""
|
||||||
|
timezone: "Europe/Sofia"
|
||||||
|
homeassistant_token: ""
|
||||||
|
mikrotik_host: "192.168.88.1"
|
||||||
|
mikrotik_ssh_user: "papur"
|
||||||
|
mikrotik_ssh_key_path: "/data/keys/mikrotik_papur_nopw"
|
||||||
|
schema:
|
||||||
|
telegram_bot_token: str
|
||||||
|
timezone: str
|
||||||
|
homeassistant_token: str?
|
||||||
|
mikrotik_host: str
|
||||||
|
mikrotik_ssh_user: str
|
||||||
|
mikrotik_ssh_key_path: str
|
||||||
@@ -0,0 +1,71 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
# Home Assistant add-on options are usually rendered to /data/options.json
|
||||||
|
OPTIONS_FILE="/data/options.json"
|
||||||
|
|
||||||
|
if [ ! -f "$OPTIONS_FILE" ]; then
|
||||||
|
echo "Missing $OPTIONS_FILE (add-on options)."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
BOT_TOKEN=$(jq -r '.telegram_bot_token // empty' "$OPTIONS_FILE")
|
||||||
|
TZNAME=$(jq -r '.timezone // "Europe/Sofia"' "$OPTIONS_FILE")
|
||||||
|
HA_TOKEN=$(jq -r '.homeassistant_token // empty' "$OPTIONS_FILE")
|
||||||
|
MT_HOST=$(jq -r '.mikrotik_host // "192.168.88.1"' "$OPTIONS_FILE")
|
||||||
|
MT_USER=$(jq -r '.mikrotik_ssh_user // "papur"' "$OPTIONS_FILE")
|
||||||
|
MT_KEY=$(jq -r '.mikrotik_ssh_key_path // "/data/keys/mikrotik_papur_nopw"' "$OPTIONS_FILE")
|
||||||
|
|
||||||
|
if [ -z "$BOT_TOKEN" ]; then
|
||||||
|
echo "You must set telegram_bot_token in the add-on configuration."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
export TZ="$TZNAME"
|
||||||
|
# Reduce risk of secrets ending up in logs
|
||||||
|
set +x
|
||||||
|
|
||||||
|
# Persist everything under /data
|
||||||
|
export HOME=/data
|
||||||
|
mkdir -p /data/.clawdbot /data/clawd /data/keys /data/secrets
|
||||||
|
|
||||||
|
# Store HA token (optional) in a local file for later use by the HA skill/tooling.
|
||||||
|
if [ -n "$HA_TOKEN" ]; then
|
||||||
|
umask 077
|
||||||
|
printf '%s' "$HA_TOKEN" > /data/secrets/homeassistant.token
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Write Clawdbot gateway config (JSON5) into the expected location.
|
||||||
|
# Use pairing for DMs by default; no hardcoded chat allowlist needed.
|
||||||
|
cat > /data/.clawdbot/clawdbot.json <<EOF
|
||||||
|
{
|
||||||
|
gateway: { mode: "local" },
|
||||||
|
agents: {
|
||||||
|
defaults: {
|
||||||
|
workspace: "/data/clawd"
|
||||||
|
},
|
||||||
|
list: [
|
||||||
|
{ id: "main" }
|
||||||
|
]
|
||||||
|
},
|
||||||
|
channels: {
|
||||||
|
telegram: {
|
||||||
|
enabled: true,
|
||||||
|
botToken: "${BOT_TOKEN}",
|
||||||
|
dmPolicy: "pairing"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
EOF
|
||||||
|
|
||||||
|
# Convenience info for later (MikroTik access path & HA token file)
|
||||||
|
cat > /data/CONNECTION_NOTES.txt <<EOF
|
||||||
|
Home Assistant token (if set): /data/secrets/homeassistant.token
|
||||||
|
MikroTik SSH:
|
||||||
|
host=${MT_HOST}
|
||||||
|
user=${MT_USER}
|
||||||
|
key=${MT_KEY}
|
||||||
|
EOF
|
||||||
|
|
||||||
|
echo "Starting Clawdbot Gateway..."
|
||||||
|
exec clawdbot gateway run
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
name: Papur Add-ons
|
||||||
|
url: https://github.com/YOURNAME/ha-addon-papur
|
||||||
|
maintainer: Vanyo <you@example.com>
|
||||||
Reference in New Issue
Block a user