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 <noreply@anthropic.com>
This commit is contained in:
jtricerolph 2026-07-28 22:46:49 +00:00
parent 0bdfe67bf5
commit abaa57e0f1
2 changed files with 6 additions and 1 deletions

View file

@ -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 = '••••••••'

View file

@ -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) => {