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:
1 parent
73a06ebe63
commit
396e074108
48 files changed
+6893
-102
No files matched your search
@@ -72,6 +72,22 @@ export const INTEGRATION_FIELDS: Partial<Record<IntegrationType, IntegrationFiel
|
||||
{ key: "tokenSecret", label: "API token secret", secret: true, type: "password" },
|
||||
{ key: "insecure", label: "Allow self-signed certificate", secret: false, type: "checkbox" },
|
||||
],
|
||||
unifi: [
|
||||
{ key: "url", label: "UniFi controller URL", secret: false, placeholder: "https://unifi.example.lan (or https://host:8443 for a self-hosted controller)" },
|
||||
{
|
||||
key: "apiKey",
|
||||
label: "API key (Network 9 or later)",
|
||||
secret: true,
|
||||
optional: true,
|
||||
type: "password",
|
||||
placeholder: "made under Settings → Control Plane → Integrations; leave blank to log in instead",
|
||||
},
|
||||
{ key: "username", label: "Username (instead of an API key)", secret: false, optional: true, placeholder: "a local, read-only account — not a Ubiquiti cloud account" },
|
||||
{ key: "password", label: "Password (instead of an API key)", secret: true, optional: true, type: "password" },
|
||||
{ key: "site", label: "Only this site (optional)", secret: false, optional: true, placeholder: "the site's name as shown in UniFi; blank reads every site" },
|
||||
{ key: "selfHosted", label: "A self-hosted Network application, not a UniFi OS console (UDM, Cloud Gateway, Cloud Key)", secret: false, type: "checkbox" },
|
||||
{ key: "insecure", label: "Allow self-signed certificate", secret: false, type: "checkbox" },
|
||||
],
|
||||
osticket: [
|
||||
{ key: "host", label: "Database host", secret: false, placeholder: "osticket-db.example.lan" },
|
||||
{ key: "port", label: "Database port", secret: false, optional: true, placeholder: "3306" },
|
||||
@@ -137,8 +153,14 @@ export function validateIntegrationConfig(
|
||||
merged: Record<string, string | boolean | undefined>,
|
||||
): string[] {
|
||||
const fields = INTEGRATION_FIELDS[type] ?? [];
|
||||
return fields
|
||||
const missing = fields
|
||||
.filter((f) => f.type !== "checkbox" && !f.optional)
|
||||
.filter((f) => merged[f.key] === undefined || merged[f.key] === "")
|
||||
.map((f) => f.key);
|
||||
// UniFi takes an API key, or a username with its password: one way in is required, which no single field says.
|
||||
if (type === "unifi") {
|
||||
const has = (k: string) => typeof merged[k] === "string" && (merged[k] as string).trim() !== "";
|
||||
if (!has("apiKey") && !(has("username") && has("password"))) missing.push(has("username") ? "password" : "apiKey");
|
||||
}
|
||||
return missing;
|
||||
}
|
||||
Reference in new issue
Block a user