question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Multiple config.json entries for same platform plugin

See original GitHub issue

Is homebridge supposed to support multiple entries in config.json for the same platform plugin?

When using static accessories, homebridge seems to support specifying the same platform plugin multiple times in config.json. The platform constructor is invoked multiple times, with a different value for config corresponding to each config.json entry. This works brilliantly for homebridge-hue, to specify different settings for different Hue bridges in different config.json entries.

I’m (finally 😉 refactoring homebridge-hue to use dynamic accessories instead and I’m running into an issue. The platform constructor is invoked multiple times, just as for static accessories, but only the last (most recently created) platform instance receives the accessoryRestored event. Also, there’s no reference to the instance (or config.json entry) that orginally created the accessory. Consequently, the earlier (original) platform instance doesn’t know the accessory has been restored, tries to create it, and obviously receives an error Cannot add a bridged Accessory with the same UUID as another bridged Accessory. I catch the error, so homebridge and homebridge-hue continue to work, but the last (most recently created) platform instance doesn’t know the earlier (original) config.json settings that should still apply to the restored accessory.

Did any of you run into this issue for other plugins? How did you address it?
I suppose I could try and work around this issue by linking the accessories to the platform class rather than to the platform instance. And by somehow using the accessory context to keep track of which instance (or config.json entry) originally created the accessory. However, this seems overly complicated and error prone.
Alternatively, I could just issue an error message and exit homebridge when the platform is specified more than once in config.json. However this seems like a check homebridge should be doing.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
ebaauwcommented, Mar 19, 2019

You don’t. Either change the plugin, so a single instance can support both modes simultaneously, or run two separate homebridge instances.

0reactions
nicodujcommented, Mar 19, 2019

Thank you, will combine I think !

Sent with GitHawk

Read more comments on GitHub >

github_iconTop Results From Across the Web

config file with 2 or more plugins · Issue #475 - GitHub
I'm trying to write my config.json file for use with the legacy plugins plugin and the Sonos plugin. More specifically I'm using Smartthings ......
Read more >
Configuration in ASP.NET Core - Microsoft Learn
Settings files, such as appsettings.json; Environment variables; Azure Key Vault; Azure App Configuration; Command-line arguments; Custom ...
Read more >
User and Workspace Settings - Visual Studio Code
VS Code provides several different scopes for settings. ... the UI that lets you review and modify setting values that are stored in...
Read more >
New! 10x more awesome ways to write JSON configuration ...
In most of the configurations, I've experienced there are sections/values which are used multiple times in the same or multiple JSON configuration files....
Read more >
c# - Automatically set appsettings.json for dev and release ...
Update for .NET Core 3.0+. You can use CreateDefaultBuilder which will automatically build and pass a configuration object to your startup ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found