UniFi integration: network devices, Wi-Fi and networks, as part of the dependency map

A UniFi controller (API key on Network 9+, or a read-only local login on any
version) is read every five minutes. Its switches, access points and gateways
are kept with state, IP, uptime, firmware and uplink; its networks and Wi-Fi
names beside them (passphrases are never read). Nothing is written to the
controller.

Network > Network devices lists them. Devices are a new node type in the
dependency map: uplinks become dependencies by themselves, others can be
written by hand. A device offline past a limit is an offline alert, folds what
depends on it, can be silenced with maintenance and have runbooks.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
bobbanandClaude Sonnet 5.5 committed 2026-10-20 00:35:48 +02:00
1 parent 73a06ebe63
commit 396e074108
48 files changed
+6893 -102

No files matched your search

+4 -2
View File
@@ -2,7 +2,7 @@ import { Router } from "express";
import { and, eq } from "drizzle-orm";
import { z } from "zod";
import { db } from "../db/client.js";
import { dnsProviders, integrations, maintenanceTargetTypes, runbooks, servers } from "../db/schema.js";
import { dnsProviders, integrations, maintenanceTargetTypes, networkDevices, runbooks, servers } from "../db/schema.js";
import { requireAuth, requireRole } from "../auth/middleware.js";
import { recordAudit } from "../services/audit.js";
import { describeTarget } from "../services/maintenance.js";
@@ -39,16 +39,18 @@ runbooksRouter.get("/", asyncHandler(async (req, res) => {
// What there is, everywhere, by title only — so a page can show a "runbook" button exactly where one exists, without fetching the texts.
// Notes for something that has since been removed are left out.
runbooksRouter.get("/summary", asyncHandler(async (_req, res) => {
const [rows, serverIds, integrationIds, providerIds] = await Promise.all([
const [rows, serverIds, integrationIds, providerIds, deviceIds] = await Promise.all([
db.select({ id: runbooks.id, targetType: runbooks.targetType, targetId: runbooks.targetId, category: runbooks.category, title: runbooks.title }).from(runbooks),
db.select({ id: servers.id }).from(servers),
db.select({ id: integrations.id }).from(integrations),
db.select({ id: dnsProviders.id }).from(dnsProviders),
db.select({ id: networkDevices.id }).from(networkDevices),
]);
const exists = {
server: new Set(serverIds.map((r) => r.id)),
integration: new Set(integrationIds.map((r) => r.id)),
dns_provider: new Set(providerIds.map((r) => r.id)),
device: new Set(deviceIds.map((r) => r.id)),
};
res.json({ runbooks: rows.filter((r) => exists[r.targetType].has(r.targetId)) });
}));