Ability to run more than one instance of an integration

Based on my previous post Multiple coordinators for ZHA integration , it seems that there’s a legitimate use for having multiple instances of z-wave, zha and maybe other integrations where it’s not possible to have a single IoT network. For stuff like esphome it makes sense to have a single instance, since devices don’t rely on a centralized coordinator, rather HA itself, but for other cases this can be limiting.

What’s the technical reason for not allowing multiple instances of an integration? What do I have to keep in mind when cloning an integration using custom_components, and can this be used to have more than two instances of said integration?

1 Like

You can currently have multiple Z-wave-JS integrations, there are multiple examples on the forum representing this and how to do it. The challenge is that only one Z-Wave-JS-UI Addon is supported natively, but you can install it on docker or other install methods outside of Home Assistant supervised.

I imagine ZHA will be the same, and I’ve seen a post in the ZHA section that they are working on allowing that implementation to run externally Zigpy developer(s) begun work on external and stand-alone implementations of ZHA - Configuration / Zigbee - Home Assistant Community (home-assistant.io)

Outside of those technologies, many integrations support multiple instances where that makes logical sense. For example, I have multiple Rokus and multiple Roku integrations.

A similar thing happens with zigbee2mqtt, see the post I linked in the original post for more info

Thanks for sharing that, I’ll keep an eye on it. Regardless of what progress is made with this, without knowing the answers to the questions I posted, at first glance it seems like an overcomplicated workaround if we’re just looking to have many instances of an integration.

Well, let’s take a stab at your questions.

We’ve established there is no technical reason that prevents multiple copies of an integration. My further estimation is that it is dependent on the integration architecture and author as to if multiple integrations are supported.

This is out of my league, but my assumption is that an experienced python programmer could likely work through this process. You’d have an advantage if you have previously created or modified an integration as I imagine there are specific architecture details that are common.

Keep in mind that some limitations you are referring to aren’t with integrations but with Addons. I don’t believe Home Assistant OS supports multiple copies of the same Addon. That said, Addons are just a convenience for new or unexperienced users. The need for multiple Addons or IOT networks aren’t really something new or unexperienced users encounter. Advanced users can likely work out how to run multiple instances. For example, I’m confident I can add a second Z-wave controller and its associated software should I feel the need to do so. Same for Zigbee, you can run ZHA and Zigbee2MQTT at the same time for 2 ZigBee controllers. I’m pretty sure you can also run more than 1 instance of Zigbee2MQTT at the same time using different base topics. As I pointed out, the issues/complications aren’t necessarily with the integration, it’s with the additional “plumbing” required to get the correct data to the integration.

The term overcomplicated is subjective, depending on the person reviewing the implementation steps. Could it be easier? Certainly. But for free open-source software I don’t begrudge the volunteers that write the code to not make this a priority.

There’s been a bit of effort recently to document cookbook community guides, perhaps someone will tackle this subject as they implement their own multiple network solution.

That has always been a gripe of mine. I could see in a large home or if you have separate living quarters, like a pool house or guest house, where having the ability to have a second or third (or more) Z-Wave and/or Zigbee network would be extremely beneficial. Having this could really take HA up to the next level for luxury homes.

My point being that this is possible today. It may not be point and click but is quite feasible and multiple users are running multiple Z-wave/Zigbee networks.

1 Like

I’ve found that this pattern repeats with many things in HA and ESPHome, where doing something simple is easy, but as soon as you want to use something in a not exactly as intended way then usability (more likely hackability) falls very sharply.

1 Like

My understanding is that the ZHA integration essentially manages the network via the serial port provided by the controller, so my reasoning is that there should be no relevant technical reason for this to be locked down to a single controller. The integration does not depend on any add-on or service that would need to be replicated.

I have quite a bit of experience in Python but I’ve never programmed any integrations, so I might try to make a duplicate integration if there’s no other way around it. I want to avoid this as much as possible since it could cause issues with integration updates.

That’s my understanding as well. If you’re looking for alternate suggestions I would install Zigbee2MQTT and just use it as the second controller management software. On the positive side, it will give you an alternative management platform to contrast with ZHA. I’ve heard it has more capabilities, but I use ZHA as well. On the negative side, it’s a new UI with a new learning curve, and requires a MQTT server that you may not currently have in place. Just a thought.

1 Like

Suggest start new thread in the feature request forum or ask that moderator rename this topic to ”Ability to run more than one instance of the ZHA integration” and move this to the feature request forum → Feature Requests - Home Assistant Community

Anyway, I do not think that there is any technical reasons why it would not be possible to allow users to run multiple instances of the ZHA integration, but each needs to have its own dedicated Zigbee Coordinator to control a seperate Zigbee network.

At least I believe that the reason why you can currently only have one instance of the ZHA integration is a choice made by the ZHA integration developers.

FYI, as a workaround is already possible to manually copy the whole zha component inside the Home Assistent core and run it under a different name, but the problem then for users to keep a such an inoffcial copy(ies) updated with latest version.

Note that as you do not use the same Zigbee channel for more than one Zigbee network / Zigbee Coordinator they should not signifigantly interfere with each other. If there was an official way to run multiple instances then they could make sure that does not happen.

2 Likes

It not being updated is the reason why I haven’t gotten around to doing that yet.

Anyways, I’m grateful for all the comments I got regarding my ZigBee situation. However I’d still like to know the reasoning for locking down integrations to one instance, instead of just discouraging or warning the user, not just for the ZigBee one, but for other integrations where this would be a legitimate use case.

So, is it possible to run 2 instances of the same integration ?

It depends on the integration author. If it was designed and coded to support multiple instances, then yes. If not, then no. Not something the user has control over.