commit bc0b442b6551a05f8fbae6db064d0143d659d174 Author: TheLast Date: Tue Jan 27 11:59:06 2026 +0200 Initial Home Assistant add-on skeleton for Clawdbot (Papur) diff --git a/README.md b/README.md new file mode 100644 index 0000000..33611ed --- /dev/null +++ b/README.md @@ -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//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) diff --git a/papur-addon/.gitignore b/papur-addon/.gitignore new file mode 100644 index 0000000..9fae749 --- /dev/null +++ b/papur-addon/.gitignore @@ -0,0 +1,3 @@ +*.log +*.sqlite +/data/ diff --git a/papur-addon/Dockerfile b/papur-addon/Dockerfile new file mode 100644 index 0000000..7595efe --- /dev/null +++ b/papur-addon/Dockerfile @@ -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" ] diff --git a/papur-addon/build.yaml b/papur-addon/build.yaml new file mode 100644 index 0000000..d6c749a --- /dev/null +++ b/papur-addon/build.yaml @@ -0,0 +1,2 @@ +build_from: + amd64: ghcr.io/hassio-addons/base:14.0.2 diff --git a/papur-addon/config.yaml b/papur-addon/config.yaml new file mode 100644 index 0000000..3e684b8 --- /dev/null +++ b/papur-addon/config.yaml @@ -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 diff --git a/papur-addon/run.sh b/papur-addon/run.sh new file mode 100644 index 0000000..f0124b0 --- /dev/null +++ b/papur-addon/run.sh @@ -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 < /data/CONNECTION_NOTES.txt <