#3828·homebridge

Reload individual plugins instead of rebooting the entire Homebridge

Author: justjam2013Created Jul 16, 2025Updated Aug 29, 2025
Labelsenhancementvision

Current Situation

When a plugin is updated or the configuration is changed, the entire Homebridge is restarted to reload the plugin. During the time that Homebridge is down, all of the devices bridged by Homebridge are unavailable, not just the ones supported by the modified plugin. This means that any automation involving any HB device will fail.

Proposed Change

Dynamically reload a single plugin without requiring a complete restart of Homebridge to minimize Homebridge unavailability.

Additional Context

Node.js: refreshing a module using require.cache

https://github.com/homebridge/homebridge/blob/be3852ee20be8b39a192b6c73e06fb2e53e8894b/src/plugin.ts#L228

const mainPath = path.join(this.pluginPath, this.main);
...
const pluginModules = this.isESM ? await _importDynamic(pathToFileURL(mainPath).href) : require(mainPath);

So mainPath would need to be saved:

const mainPath; ... this.mainPath = path.join(this.pluginPath, this.main);

As pluginModules is loaded on demand, it looks like something like this could be done:

public async reload(): Promise<void> {
  delete require.cache[require.resolve(this.mainPath)];
  this.load();
}

This would delete this plugin from the cache and then the call to load() would load the plugin back into the cache

The Homebridge API would then need to be updated, so that HB UI could request a plugin be reloaded after it is updated or its configuration is changed.