Racks, notes and to-do, OS support, suggested dependencies, Nginx Proxy Manager and Home Assistant

- Racks page and a network diagram (UniFi tree with servers, printable)
- Notes on servers and devices; To do list shown in Coming up and My work
- Agents report the operating system (Linux 7, Windows 6); end-of-life badge and alert
- Suggested dependencies from where a service is reached
- Nginx Proxy Manager integration: proxy hosts page, certificate and host alerts, suggested checks
- Home Assistant integration: watch chosen entities, history chart, limit and unavailable alerts
- TimeChart gets a "value" scale that fits negatives; docs updated

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
bobbanandClaude Sonnet 5.5 committed 2026-10-20 21:47:56 +02:00
1 parent 68b41b5586
commit 18ceed62e8
77 files changed
+20432 -35

No files matched your search

+96
View File
@@ -471,6 +471,12 @@ export const servers = sqliteTable("servers", {
// not in this list, and not noted on the Ports page, is a "new port" (services/newPorts.ts). Null until the first report that carries ports.
portBaseline: text("port_baseline"),
// What the machine runs, as its agent says (agent 7 and later): the distribution's id ("ubuntu", "debian", "proxmox-ve", "windows"), its pretty name and its release
// (for Windows, the build number). What services/osLifecycle.ts works out when its support ends from.
osId: text("os_id"),
osName: text("os_name"),
osVersion: text("os_version"),
// What the machine is, as its firmware says (agents report it): maker, model and serial number. Used to fill in the inventory.
hwManufacturer: text("hw_manufacturer"),
hwModel: text("hw_model"),
@@ -536,6 +542,8 @@ export const integrationTypes = [
"pbs",
"osticket",
"unifi",
"npm",
"homeassistant",
] as const;
export type IntegrationType = (typeof integrationTypes)[number];
@@ -1088,6 +1096,94 @@ export const metricsTokens = sqliteTable("metrics_tokens", {
lastUsedAt: text("last_used_at"), // ISO
});
// ─── Home Assistant: the few things somebody chose to watch ─────────────────
// An entity (a sensor, a binary sensor, a battery, a UPS) that somebody chose to watch on a Home Assistant integration, and the limits that make it an alert.
export const haWatched = sqliteTable(
"ha_watched",
{
id: integer("id").primaryKey({ autoIncrement: true }),
integrationId: integer("integration_id")
.notNull()
.references(() => integrations.id, { onDelete: "cascade" }),
entityId: text("entity_id").notNull(), // "sensor.ups_battery"
name: text("name"), // what to call it here; the entity's own friendly name when null
above: real("above"), // an alert when a numeric value is above this
below: real("below"), // …or below this
createdAt: text("created_at").notNull(),
},
(t) => [uniqueIndex("ha_watched_unique").on(t.integrationId, t.entityId)],
);
// What the last read said about each watched entity. `unavailableSince` is when it was first seen "unavailable" or "unknown", kept until it is not.
export const haEntities = sqliteTable(
"ha_entities",
{
integrationId: integer("integration_id")
.notNull()
.references(() => integrations.id, { onDelete: "cascade" }),
entityId: text("entity_id").notNull(),
friendlyName: text("friendly_name"),
state: text("state").notNull(),
value: real("value"), // the state as a number, when it is one
unit: text("unit"),
deviceClass: text("device_class"),
lastChanged: text("last_changed"),
unavailableSince: text("unavailable_since"),
updatedAt: text("updated_at").notNull(),
},
(t) => [primaryKey({ columns: [t.integrationId, t.entityId] })],
);
// A numeric value of a watched entity at a moment, for the chart: one every few minutes, kept 35 days.
export const haReadings = sqliteTable(
"ha_readings",
{
id: integer("id").primaryKey({ autoIncrement: true }),
integrationId: integer("integration_id")
.notNull()
.references(() => integrations.id, { onDelete: "cascade" }),
entityId: text("entity_id").notNull(),
at: text("at").notNull(), // ISO
value: real("value").notNull(),
},
(t) => [index("ha_readings_lookup_idx").on(t.integrationId, t.entityId, t.at)],
);
// ─── Notes and the to-do list ───────────────────────────────────────────────
// Free-form notes about a server or a network device — what is it, where does it sit, what did I do to it last time — one text per thing, drawn with the same small
// formatting as a runbook. Polymorphic like runbooks and maintenance windows, so no foreign key: the note of something removed is simply not shown.
export const notes = sqliteTable(
"notes",
{
id: integer("id").primaryKey({ autoIncrement: true }),
targetType: text("target_type").$type<"server" | "device">().notNull(),
targetId: integer("target_id").notNull(),
body: text("body").notNull(),
updatedBy: text("updated_by"),
updatedAt: text("updated_at").notNull(), // ISO
},
(t) => [uniqueIndex("notes_target_idx").on(t.targetType, t.targetId)],
);
// Things to do: the small jobs of a homelab ("replace the UPS battery", "move the NAS to the new switch"), with a day they are due and optionally a person and
// a thing they are about. Open ones with a due day are in Coming up; the ones handed to someone are in My work.
export const todos = sqliteTable("todos", {
id: integer("id").primaryKey({ autoIncrement: true }),
title: text("title").notNull(),
detail: text("detail"),
dueDate: text("due_date"), // YYYY-MM-DD
assigneeUserId: integer("assignee_user_id").references(() => users.id, { onDelete: "set null" }),
assigneeName: text("assignee_name"), // as it was when handed over, so it still reads if the person is removed
targetType: text("target_type").$type<"server" | "device">(),
targetId: integer("target_id"),
createdBy: text("created_by"),
createdAt: text("created_at").notNull(), // ISO
doneAt: text("done_at"), // ISO; null while open
doneBy: text("done_by"),
});
// ─── Personal API tokens: read-only access to /api/v1 for scripts and Home Assistant ─────
// One person's own: made by them, shown to them once, and gone when they are. Only a hash of the secret is kept. A token only ever reads (the API has no other verbs),