homebridge-mqttthing icon indicating copy to clipboard operation
homebridge-mqttthing copied to clipboard

Global configuration for MQTT server/username/password? (ie. MQTT server specified for every accessory?)

Open sofakng opened this issue 4 years ago • 6 comments

Is it possible to only specify the MQTT server/username/password once?

For example, I have many accessories (zwavejs2mqtt) that I'd like to use with mqttthing but it seems redundant to specify the server/username/password repeatedly. I'm also worried that each accessory makes a separate connection to the MQTT server?

sofakng avatar Nov 03 '21 16:11 sofakng

Not currently, unfortunately. I agree: it's a pain particularly when using the configuration GUI.

Unfortunately, Homebridge accessories must either be of the 'platform' type where one configuration is used for all accessories, or as individually-configured accessories (as mqttthing is). I had hoped that it might be possible to use a 'platform' Config block for shared/default settings and then individually-configured accessories for the accessory-specific settings, but my understanding is that this isn't allowed.

Given time I'd like to move mqttthing to the former (and probably rewrite it in TypeScript), probably as an incompatible 'version 2'. Hopefully one day...

arachnetech avatar Nov 14 '21 11:11 arachnetech

What about using environment variables to allow these to be set? For example, this plugin: https://github.com/joe-ng/homebridge-dyson-link/blob/b7deeb46a6d00e60590e3e830dcd5716f206d6bd/index.js#L47-L48

Alternatively, I believe you can share configuration at the platform level — at least this CBUS plugin does this:

https://github.com/anthonywebb/homebridge-cbus

redging-very-well avatar Dec 01 '21 21:12 redging-very-well

Yes, cbus does it how I'd do it now (!) - it uses a platform-level config with an array of accessories. If I ever get time to do an MQTT-Thing 2.0 I'll go with that design, but it would be incompatible with existing configurations.

Good idea re. environment variables as an alternative. I'll have a look at that.

arachnetech avatar Dec 01 '21 21:12 arachnetech

I could raise PR for the env-var thing if you'd like?

redging-very-well avatar Dec 01 '21 21:12 redging-very-well

Thanks, go for it!

arachnetech avatar Dec 01 '21 21:12 arachnetech

https://github.com/arachnetech/homebridge-mqttthing/pull/505 Let me know if there's anything else you'd like me to do on that PR.

redging-very-well avatar Dec 01 '21 21:12 redging-very-well