Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request: support for "plugins" key in config.json #287

Closed
ebaauw opened this issue May 6, 2019 · 8 comments
Closed

Feature request: support for "plugins" key in config.json #287

ebaauw opened this issue May 6, 2019 · 8 comments

Comments

@ebaauw
Copy link
Contributor

ebaauw commented May 6, 2019

Please add a button to the Plugins screen for each plugin (next to the UNINSTALL) to support for enabling/disabling the loading of installed plugins. This would manage the "plugins" key in config.json.

@palasinio
Copy link

That would be nice 👍

@CooperCGN
Copy link

CooperCGN commented May 25, 2019

This would manage the "plugins" key in config.json.

Not really to the topic, but even after extensive use of google, what is that plugin key? Can’t find any info on syntax and where it belongs.

@ebaauw
Copy link
Contributor Author

ebaauw commented May 25, 2019

It belongs at the top-level object:

{
  "bridge": {
    ...
  },
  "plugins": [
    "homebridge-config-ui-x",
    "homebridge-hue"
  ],
  "platforms": [
    {
      "platform": "config",
      ...
    },
    {
      "platform": "Hue",
      ...
    }
  ]
}

When present, it whitelists the plugins to load at the very start of homebridge (before parsing the platforms and accessories arrays). This is particularly useful when running multiple instances of homebridge on the same server, with a single install directory (typically /usr/lib/node_modules) for all plugins. You only want each instance to load "their" plugins, and ignore the plugins for the other instances.

Look at the log to understand homebridge's startup sequence:

  • Homebridge first reads config.json:
    [5/24/2019, 2:58:01 PM] Loaded config.json with 0 accessories and 2 platforms.
    
  • Then, it loads the plugins (allowing them to register themselves):
    [5/24/2019, 2:58:01 PM] ---
    [5/24/2019, 2:58:01 PM] Loaded plugin: homebridge-config-ui-x
    [5/24/2019, 2:58:01 PM] Registering platform 'homebridge-config-ui-x.config'
    [5/24/2019, 2:58:01 PM] ---
    [5/24/2019, 2:58:01 PM] Loaded plugin: homebridge-hue
    [5/24/2019, 2:58:01 PM] Registering platform 'homebridge-hue.Hue'
    
  • Then, it initialises the platform plugins mentioned in platforms (and the accessory plugins mentioned in accessories):
    [5/24/2019, 2:58:01 PM] ---
    [5/24/2019, 2:58:01 PM] Loading 2 platforms...
    [5/24/2019, 2:58:01 PM] [Config] Initializing config platform...
    [5/24/2019, 2:58:01 PM] [Hue] Initializing Hue platform...
    

Without the plugins key in config.json, homebridge loads all installed plugins, and even initialises loaded platform plugins not mentioned in platforms that use the dynamic accessory model:

[5/25/2019, 12:45:41 PM] Loaded config.json with 0 accessories and 2 platforms.
[5/25/2019, 12:45:41 PM] ---
[5/25/2019, 12:45:41 PM] Loaded plugin: homebridge-config-ui-x
[5/25/2019, 12:45:41 PM] Registering platform 'homebridge-config-ui-x.config'
[5/25/2019, 12:45:41 PM] ---
[5/25/2019, 12:45:42 PM] Loaded plugin: homebridge-hue
[5/25/2019, 12:45:42 PM] Registering platform 'homebridge-hue.Hue'
[5/25/2019, 12:45:42 PM] ---
[5/25/2019, 12:45:42 PM] Loaded plugin: homebridge-music
[5/25/2019, 12:45:42 PM] Registering platform 'homebridge-music.Music'
[5/25/2019, 12:45:42 PM] ---
[5/25/2019, 12:45:42 PM] Loaded plugin: homebridge-otgw
[5/25/2019, 12:45:42 PM] Registering platform 'homebridge-otgw.OTGW'
[5/25/2019, 12:45:42 PM] ---
[5/25/2019, 12:45:43 PM] Loaded plugin: homebridge-p1
[5/25/2019, 12:45:43 PM] Registering platform 'homebridge-p1.P1'
[5/25/2019, 12:45:43 PM] ---
[5/25/2019, 12:45:43 PM] Loaded plugin: homebridge-ws
[5/25/2019, 12:45:43 PM] Registering platform 'homebridge-ws.WS'
[5/25/2019, 12:45:43 PM] ---
[5/25/2019, 12:45:43 PM] Loaded plugin: homebridge-zp
[5/25/2019, 12:45:43 PM] Registering platform 'homebridge-zp.ZP'
[5/25/2019, 12:45:43 PM] ---
[5/25/2019, 12:45:43 PM] Loading 2 platforms...
[5/25/2019, 12:45:43 PM] [Config] Initializing config platform...
[5/25/2019, 12:45:43 PM] [Hue] Initializing Hue platform...
Load homebridge-otgw.OTGW
Load homebridge-ws.WS

@CooperCGN
Copy link

Thank you very much for that excellent explanation. I am actually running about ten homebridge instances and always thought how stupid it is that each one is loading all plugins. I had a look on the homebridge github page but couldn’t find anything about it. Going to implement this today. Thanks again.

@oznu oznu added the pinned label Jun 2, 2019
@normen
Copy link

normen commented Mar 8, 2020

+1 for this, with many instances and many different plugins it can become very tedious to find the right plugin/instance, especially when using the config-ui-x panels.

But I guess with config-x being a separate server now it would make more sense to support multiple Homebridge instances right from one config-ui-x instance..

@Salvora
Copy link

Salvora commented Sep 16, 2020

+1 for this.

@oznu
Copy link
Member

oznu commented Jan 19, 2021

The solution to this feature request will land in the next release. While not exactly what was asked for, it achieves the same goal.

It will require Homebridge 1.3.0-beta.47 or later to support the new disabledPlugins array (homebridge/homebridge#2775).

As part of these changes users will be able to toggle enable/disable a plugin, their config will be able to remain in the config.json and not stop Homebridge from loading.

image
image

@oznu oznu closed this as completed Jan 19, 2021
@ebaauw
Copy link
Contributor Author

ebaauw commented Jan 19, 2021

Thanks, @oznu.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants