仪表盘
仪表盘可以显示 Kept 中需要你处理的事项:已逾期、到期、即将过期、已借出、不确定和库存不足,包括总数和每个空间的数量。下面的每个小组件都只调用一个接口 GET /api/v1/summary,使用一个 个人令牌(只读,勾选你想统计的空间)。Home Assistant 读取的也是这个接口。
{ "asOf": "2026-10-15T11:30:00.000Z", "totals": { "things": 61, "unplaced": 4, "overdue": 2, "due": 3, "expiring": 2, "lentOut": 2, "borrowedIn": 0, "uncertain": 2, "longUnseen": 0, "lowStock": 0 }, "locations": [ { "id": "…", "name": "Home", "kind": "home", "timeZone": "Africa/Cairo", "counts": { "things": 34, "unplaced": 1, "overdue": 2, "due": 1, "expiring": 1, "lentOut": 1, "borrowedIn": 0, "uncertain": 1, "longUnseen": 0, "lowStock": null } } ]}- 每个数量与 Kept 首页上的相同,范围是令牌能访问的空间。
- 某个空间中的
null:该功能模块在那里未开启(lentOut和borrowedIn对应借出,lowStock对应耗材)。totals只累加适用的空间,所以始终是数字。 - 不含物品名称,也不含金额。
把令牌保存在仪表盘的密钥配置中,不要放在你会分享的文件里。每个示例都使用 https://kept.example.org:换成你的 Kept 地址。
Homepage
Section titled “Homepage”一个 Custom API 小组件,写在 services.yaml 中。令牌来自环境变量 HOMEPAGE_VAR_KEPT_TOKEN(环境变量密钥)。已对照 Homepage 2.5.0 的文档检查。
- Home: - Kept: href: https://kept.example.org description: What needs you widget: type: customapi url: https://kept.example.org/api/v1/summary refreshInterval: 300000 # 5 minutes headers: Authorization: Bearer {{HOMEPAGE_VAR_KEPT_TOKEN}} mappings: - field: totals.overdue label: Overdue format: number - field: totals.due label: Due format: number - field: totals.expiring label: Expiring format: number - field: totals.lowStock label: Low stock format: number改为按空间显示,每个空间一行:
widget: type: customapi url: https://kept.example.org/api/v1/summary refreshInterval: 300000 headers: Authorization: Bearer {{HOMEPAGE_VAR_KEPT_TOKEN}} display: dynamic-list mappings: items: locations name: name label: counts.overdueGlance
Section titled “Glance”一个 custom-api 小组件,写在 glance.yml 中。${KEPT_TOKEN} 从 Glance 的环境中读取。已对照 Glance 0.8.6 的文档检查。
- type: custom-api title: Kept cache: 5m url: https://kept.example.org/api/v1/summary headers: Authorization: Bearer ${KEPT_TOKEN} Accept: application/json template: | <div class="flex justify-between text-center"> <div> <div class="color-highlight size-h3">{{ .JSON.Int "totals.overdue" }}</div> <div class="size-h6">OVERDUE</div> </div> <div> <div class="color-highlight size-h3">{{ .JSON.Int "totals.due" }}</div> <div class="size-h6">DUE</div> </div> <div> <div class="color-highlight size-h3">{{ .JSON.Int "totals.expiring" }}</div> <div class="size-h6">EXPIRING</div> </div> <div> <div class="color-highlight size-h3">{{ .JSON.Int "totals.lowStock" }}</div> <div class="size-h6">LOW STOCK</div> </div> </div> <ul class="list list-gap-10" style="margin-top: 1rem"> {{ range .JSON.Array "locations" }} <li>{{ .String "name" }}: {{ .Int "counts.overdue" }} overdue, {{ .Int "counts.due" }} due</li> {{ end }} </ul>使用自签名证书时,添加 allow-insecure: true。
Homarr
Section titled “Homarr”一个自定义小组件(Homarr 2.x)。把下面的定义保存为 kept.homarr-widget.json,然后在 Homarr 中:自定义小组件 → 导入。在 配置 API 来源 中,把建议的地址换成你的 Kept 地址,勾选确认项,并把令牌粘贴到 API 密钥或令牌 中。然后把它添加到看板:选择要添加的项目 → 自定义小组件。Homarr 从它的服务器调用 Kept,令牌不会进入浏览器。
已对照 Homarr 2.5.2 的导入 schema 检查,但尚未在它的预览中运行过:依赖它之前,请先使用 测试并预览。
networkScope: private让 Homarr 能访问你局域网中的 Kept。无论如何设置,Homarr 都会拒绝 Tailscale 的100.x地址,并且不跟随重定向:请使用 Kept 的局域网地址,即最终地址。- 自签名证书很可能会被拒绝;请使用受信任的证书,或在局域网中使用
http://。
{ "$schema": "homarr-custom-widget-v2", "name": "Kept", "description": "Overdue, due, expiring, lent out, uncertain and low stock from Kept.", "sources": { "default": { "name": "Kept", "baseUrl": "https://your-kept.example.com", "networkScope": "private", "auth": "bearer" } }, "requests": { "summary": { "path": "/api/v1/summary", "cacheSeconds": 60 } }, "options": { "showLocations": { "label": "Show each location", "control": "switch", "default": true } }, "template": "<Stack gap=\"sm\" p=\"sm\" h=\"100%\" style={{ minWidth: 0, minHeight: 0 }}>\n <Group justify=\"space-between\" wrap=\"nowrap\"><Text size=\"xs\" c=\"dimmed\" tt=\"uppercase\" fw={700}>Kept</Text><RefreshButton requestId=\"summary\" label=\"Refresh\" size=\"xs\" /></Group>\n {status.summary?.loading && <Skeleton height={120} radius=\"md\" />}\n {status.summary?.ok === false && <Alert color=\"red\" title=\"Kept unavailable\">{status.summary.error || \"Check the address and token under Configure sources.\"}</Alert>}\n {!status.summary?.loading && status.summary?.ok !== false && <ScrollArea style={{ flex: 1, minHeight: 0 }}><Stack gap=\"sm\">\n <SimpleGrid type=\"container\" cols={{ base: 2, \"300px\": 3 }} spacing=\"xs\">{[{ label: \"Overdue\", value: data.summary?.totals?.overdue }, { label: \"Due\", value: data.summary?.totals?.due }, { label: \"Expiring\", value: data.summary?.totals?.expiring }, { label: \"Lent out\", value: data.summary?.totals?.lentOut }, { label: \"Uncertain\", value: data.summary?.totals?.uncertain }, { label: \"Low stock\", value: data.summary?.totals?.lowStock }].map(item => <Paper key={item.label} withBorder radius=\"md\" p=\"sm\"><Text size=\"xs\" c=\"dimmed\">{item.label}</Text><Text fw={700} size=\"xl\">{item.value ?? \"-\"}</Text></Paper>)}</SimpleGrid>\n {options.showLocations && <Stack gap={0}>{(data.summary?.locations ?? []).map(location => <Group key={location.id} justify=\"space-between\" wrap=\"wrap\" gap=\"xs\" py=\"xs\"><Text size=\"sm\" fw={600}>{location.name}</Text><Text size=\"xs\" c=\"dimmed\">{\"Overdue \" + location.counts.overdue + \" \u00b7 Due \" + location.counts.due}</Text></Group>)}</Stack>}\n </Stack></ScrollArea>}\n</Stack>"}