From 0551561918e62167d70f75be0eb359397bd4c4f1 Mon Sep 17 00:00:00 2001 From: kidtime-addon-publisher <4+kidtime-addon-publisher@noreply.git.nc.kreapptivo.de> Date: Sun, 8 Nov 2026 09:03:57 +0100 Subject: [PATCH] Publish add-on 0.1.1 From kidtime-server 829dc82c838abd3900dd182a1be3e55326dc7b6e --- kidtime/DOCS.md | 176 ++++++++++++++++++++++++++++++++++++++++++++ kidtime/config.yaml | 22 ++++++ 2 files changed, 198 insertions(+) create mode 100644 kidtime/DOCS.md create mode 100644 kidtime/config.yaml diff --git a/kidtime/DOCS.md b/kidtime/DOCS.md new file mode 100644 index 0000000..8e76517 --- /dev/null +++ b/kidtime/DOCS.md @@ -0,0 +1,176 @@ +# KidTime + +## What this add-on does + +KidTime is a parental control server for your home network. It stores the time +limits and usage of your children's Windows devices, tells the KidTime client on +each device when to warn, lock or log off, and serves the admin web page. The +add-on runs on the host network so the devices find it as `kidtime.local` +(mDNS) without any extra setup. The add-on takes its timezone from Home +Assistant, and the server runs as the container's main process, so a crash or a +failed port makes the add-on stop with a clear line in its log. + +## Ports + +| Port | Used for | +| ---- | ----------------------------------------------------------- | +| 8080 | Admin web page and its API (plain HTTP, "Open Web UI") | +| 8443 | Connection from the kids' devices (gRPC over TLS) | +| 8444 | Admin web page and API over HTTPS (used by the mobile app) | + +The add-on uses the host network, so these ports are open on the Home Assistant +machine itself. Do not run another KidTime server on the same network at the +same time. + +## Backups contain secrets + +Home Assistant backups of this add-on contain the TLS private key +(`certs/server.key`) and the JWT secret (`secrets/jwt.secret`), together with the +database. Anyone who holds a backup can impersonate your server to the kids' +devices and sign in as an admin session. Store backups privately and do not share +them. The add-on is stopped while a backup runs (cold backup), so the database is +copied consistently. + +## Moving your data + +You can move the Windows server's data into this add-on by copying its folders. +The same copy is also your backup and restore method. With the same certificate, +key and database, the kids' devices reconnect without being set up again. + +The certificate is the important part. Every provisioned device remembers the +server's certificate and rejects a server that shows a different one. If the +add-on's config folder is empty when it starts, it creates a brand-new server +with a new certificate, so the copy, and the hash comparison of `server.pem`, +`server.key` and `jwt.secret`, must be finished before the first start. Follow +the order below. + +**Never start the add-on to make its config folder appear.** It would start with +a new certificate on your network. Create the folder by hand instead (step 4). + +### Where the Windows data lives + +On this machine the Windows server keeps its data in `server\data` of the +KidTime project (`D:\dev\kids-time\server\data`), as set in +`server\.localtest\config.yaml`. Inside it are four folders: + +| Folder | Holds | +| ---------- | --------------------------------------------- | +| `db` | the database (`db.sqlite`) | +| `certs` | the TLS certificate and key | +| `secrets` | the JWT secret | +| `client` | the client installers used for updates | + +Ignore the loose `db.sqlite`, `db.sqlite-shm` and `db.sqlite-wal` files at the top +of `server\data`. They are leftovers the server does not use; the real database is +`db\db.sqlite`. Do not copy them. + +### Rehearse first + +Before you touch the Green, run `scripts\addon-rehearse.ps1` on the PC. It does +the same move on a throwaway copy, on an isolated network, and shows PASS or FAIL +for each check. All checks must pass. + +### Steps + +1. **Stop the Windows server cleanly** (stop the service or process, do not kill + it), so SQLite writes everything to disk. Also turn off its auto-start while + the add-on is in use: both servers claim `kidtime.local`, so they must never + run together. If you see `db.sqlite-wal` or `db.sqlite-shm` files inside `db`, + copy those too. +2. **Make an untouched safety copy.** Copy the whole `server\data` folder to a + safe place, for example `server\data-safe`. Never edit it afterwards. This is + your rollback. +3. **Install the add-on, but do not start it.** Turn auto-start and watchdog off + for now. +4. **Open the add-on's config folder** from your PC through the Samba or SSH + add-on. It is the folder ending in `_kidtime` in the `app_configs` share + (older versions: `addon_configs`). Home Assistant may only create this folder + when the add-on first starts, so it may not exist yet. Do not start the + add-on to find out. If the folder is missing, create it by hand, named + `_kidtime`. The add-on's slug is `_kidtime`, where `` is the + first 8 hex characters of the SHA-1 of the repository URL, lowercased, exactly + as you entered it in Home Assistant (this is how Supervisor derives it; the + slug is also shown in the add-on's details page or its URL, for example + `abcd1234_kidtime`). A repository added under `/addons` instead gets the slug + `local_kidtime`. That Home Assistant accepts and uses a hand-made folder is + to be confirmed on the Green (plan Task 6); this has not been verified. +5. **Copy the four folders in:** `db`, `certs`, `secrets` and `client`, so that + you end up with `db\db.sqlite`, `certs\server.pem`, `certs\server.key`, + `secrets\jwt.secret` and `client\...` directly inside the add-on's config + folder. Copy from the safety copy or from `server\data`, as long as the + Windows server stays stopped. +6. **Compare the hashes before the first start.** In PowerShell, from the + Windows source folder and then from the add-on's config folder (a network + path through Samba), run: + + ```powershell + Get-FileHash -Algorithm SHA256 certs\server.pem, certs\server.key, secrets\jwt.secret | Select-Object Hash, Path + ``` + + The three hashes must be identical in both places. If any hash differs, or + any of the three files is missing, **do not start the add-on**. Copy again + and compare again. +7. **Start the add-on for the first time** and open its log. You should see + "Certificates loaded". If you see "Certificates not found, generating new + ones", the copy went to the wrong place: stop the add-on at once and follow + "If the add-on generated a new certificate" below, because the kids' devices + would reject the new certificate. +8. Check that the admin page opens and a kid's device reconnects. +9. **Turn auto-start (and watchdog) on** for the add-on, now that the move works. + +The stored installer paths inside the database are Windows paths. The server +finds installers by file name inside the `client` folder, so this works without +changing the database. + +### If the add-on generated a new certificate + +Stop the add-on. In its config folder, delete everything inside all four folders +(`db`, `certs`, `secrets` and `client`), including any `-wal` and `-shm` files in +`db`, because the add-on has already created a new empty database. Then copy all +four folders in again from the safety copy, compare the hashes (step 6) and +start it. + +### Rolling back + +Stop the add-on and start the Windows server on its untouched safety copy (point +its configuration at it, or put it back as `server\data`). Usage recorded on the +add-on in the meantime is lost, which is acceptable for a test. + +Also turn **Start on boot** and the watchdog off for the add-on, or uninstall it +while keeping its data. Otherwise a reboot of the Green starts it again beside +the Windows server, and both claim `kidtime.local`. + +The Green's database has diverged from the Windows one by then. On any later +re-migration, replace it with the data you copy in; never reuse the Green's old +database. + +### Do not change the repository URL + +In Home Assistant, add the repository +`https://git.nc.kreapptivo.de/KidTime/home-assistant-addon`. It is +public, and so is the add-on's image +(`git.nc.kreapptivo.de/kidtime/kidtime-addon-aarch64`): neither needs a token, +an account or a registry login. + +The repository URL you entered in Home Assistant, including any `#branch`, is +the add-on's identity. Supervisor's repository id is the first 8 hex characters +of the SHA-1 of the lowercased URL as entered, and the slug is `_kidtime`. +Changing the URL, adding `#branch` or switching to the `/addons` fallback +(`local_kidtime`) gives a different add-on with an empty config folder, which +would generate a new certificate if started. So do not change the URL. + +If you must change it, treat it as a fresh install: install the new entry +without starting it, copy the four folders from the old `_kidtime` +folder, compare the hashes (step 6), start the new one, and only then remove the +old entry. + +### Uninstalling deletes the certificate + +When you uninstall the add-on, Home Assistant asks whether to delete its data. If +you let it, the certificate, key and database are gone, and a new certificate +would be generated on the next start. Every device would then reject the +server. Keep an up-to-date copy of the four folders before uninstalling. To +recover, reinstall the add-on without starting it, copy the four folders back in +from a backup (a copy of the folders or a Home Assistant backup), compare the +hashes, and then start it. Home Assistant backups contain the TLS key and JWT +secret, so store them privately. diff --git a/kidtime/config.yaml b/kidtime/config.yaml new file mode 100644 index 0000000..98d995d --- /dev/null +++ b/kidtime/config.yaml @@ -0,0 +1,22 @@ +name: KidTime +slug: kidtime +version: "0.1.1" +description: Parental control server for the local network (time limits for kids' devices). +url: https://git.nc.kreapptivo.de/KidTime/home-assistant-addon +arch: + - aarch64 +image: git.nc.kreapptivo.de/kidtime/kidtime-addon-{arch} +host_network: true +init: false +boot: auto +startup: application +# Seconds Home Assistant waits for a clean stop before killing the add-on (default 10). +timeout: 30 +backup: cold +map: + - addon_config:rw +ports: + 8080/tcp: 8080 + 8443/tcp: 8443 + 8444/tcp: 8444 +webui: "http://[HOST]:[PORT:8080]/"