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:
parent
0bdfe67bf5
commit
abaa57e0f1
2 changed files with 6 additions and 1 deletions
|
|
@ -52,6 +52,11 @@ export const INTEGRATIONS = {
|
||||||
configFields: ['host', 'port'],
|
configFields: ['host', 'port'],
|
||||||
secretFields: ['username', 'password'],
|
secretFields: ['username', 'password'],
|
||||||
},
|
},
|
||||||
|
mqtt_plant: {
|
||||||
|
name: 'MQTT Broker (Plant)',
|
||||||
|
configFields: ['host', 'port'],
|
||||||
|
secretFields: ['username', 'password'],
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
export const MASKED = '••••••••'
|
export const MASKED = '••••••••'
|
||||||
|
|
|
||||||
|
|
@ -141,7 +141,7 @@ export async function integrationRoutes(app) {
|
||||||
if (res.status === 401) throw new Error('Invalid Nextcloud credentials')
|
if (res.status === 401) throw new Error('Invalid Nextcloud credentials')
|
||||||
if (!res.ok) throw new Error(`Nextcloud returned ${res.status}`)
|
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')
|
if (!creds.host || !creds.username || !creds.password) throw new Error('MQTT host, username and password are required')
|
||||||
const mqtt = await import('mqtt')
|
const mqtt = await import('mqtt')
|
||||||
await new Promise((resolve, reject) => {
|
await new Promise((resolve, reject) => {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue