From abaa57e0f1ddbbcc909fe0fd1f18188d26aad5d7 Mon Sep 17 00:00:00 2001 From: jtricerolph Date: Tue, 28 Jul 2026 22:46:49 +0000 Subject: [PATCH] Add per-app MQTT Broker (Plant) integration slug Lets plant have its own dedicated MQTT credentials instead of sharing the single central mqtt integration with utilities/hvac, so its dynsec client can be scoped to plant/# without touching other apps' access. Generalizes the test-connection dispatch to match any mqtt_* slug, not just the literal 'mqtt' one. Co-Authored-By: Claude Sonnet 5 --- src/integrations/schema.js | 5 +++++ src/routes/integrations.js | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/integrations/schema.js b/src/integrations/schema.js index f43c74a..9e0db41 100644 --- a/src/integrations/schema.js +++ b/src/integrations/schema.js @@ -52,6 +52,11 @@ export const INTEGRATIONS = { configFields: ['host', 'port'], secretFields: ['username', 'password'], }, + mqtt_plant: { + name: 'MQTT Broker (Plant)', + configFields: ['host', 'port'], + secretFields: ['username', 'password'], + }, } export const MASKED = '••••••••' diff --git a/src/routes/integrations.js b/src/routes/integrations.js index a8a2125..3ece339 100644 --- a/src/routes/integrations.js +++ b/src/routes/integrations.js @@ -141,7 +141,7 @@ export async function integrationRoutes(app) { if (res.status === 401) throw new Error('Invalid Nextcloud credentials') if (!res.ok) throw new Error(`Nextcloud returned ${res.status}`) } - else if (req.params.slug === 'mqtt') { + else if (req.params.slug === 'mqtt' || req.params.slug.startsWith('mqtt_')) { if (!creds.host || !creds.username || !creds.password) throw new Error('MQTT host, username and password are required') const mqtt = await import('mqtt') await new Promise((resolve, reject) => {