jaroschek / home-assistant-myuplink

Custom Home Assistant integration for devices and sensors in myUplink account.
39 stars 8 forks source link

Core Integration with same Domain "myuplink" #61

Open jaroschek opened 5 months ago

jaroschek commented 5 months ago

I don't know, if this is an issue or will be an issue in the future. But I just noticed, that in the core repository of Home Assistant a new integration was added to integration the myUplink API:

https://github.com/home-assistant/core/pull/86522/files

I have no idea, how to handle this. Everybody is free to write code as he linkes. But I for myself would prefer to continue using my own implementation, even if this new integration in the core repository exists.

Does anybody know, if there will be problems caused by the identical DOMAIN?

Will my custom integration have any future, or will it get somehow "banned" because it uses the same DOMAIN as the new core integration?

7RST1 commented 5 months ago

I'd guess this would propose a problem, yes. I think there are internal databases in hass where all the data for different integrations are stored using it's DOMAIN as a key, where they'd end up conflicting.

There also seems there are no official methods to change the domain name.

This domain has to be unique and cannot be changed

https://developers.home-assistant.io/docs/creating_integration_manifest/#domain

Looks like by the time the "official" myuplink integration goes out of dev into beta, this one should have changed its domain name to something a bit different, implying all historical data tied to the old myuplink domain would be lost.

Maybe, maybe, they'd never conflict if you never set up the official integration, but it's hard to say without understanding the internal operations of the domain system.

It's annoying, cause this one looks to be more feature packed than the official one. I'd even call this one the OG since it used the domain name first.. But I guess there is little to do about it.

elden1337 commented 5 months ago

It should only be an issue if one were to run both integrations in their instance as far as I know. The config-keys are local. However, it would be a good practice to start thinking of a way to alter it here since I also don't see that the now becoming official integration will do that. Not sure how hacs-jobs would handle this conflict either, possibly there will be checks that may flag this integration once the other one is in prod.

elden1337 commented 5 months ago

on top of mind if I were you I would just announce a breaking change and deploy a version with another domain name as soon as possible. People would have to re-install to not break it (uninstall, then install new). If noone else has any other better idea ofc.

jaroschek commented 5 months ago

Thanks for your feedback.

I found something interesting: https://developers.home-assistant.io/docs/creating_integration_file_structure/#where-home-assistant-looks-for-integrations

You can override a built-in integration by having an integration with the same domain in your <config directory>/custom_components folder.

So I would guess, my integration can stay in that domain.

And one can only get access to the (younger) core integration, when this custom integration is removed or not installed at all. Or on the other hand: If one has installed only the core integration and it does not meet the expectations, one can install this custom integration through HASC to use it instead.

elden1337 commented 5 months ago

hmm, unsure if that would cut it to be honest (but i have never gone down this path either). In the core.config_entries file where the data is stored, it is all one big dictionary regardless of it being custom or internal:

{
  "version": 1,
  "minor_version": 1,
  "key": "core.config_entries",
  "data": {
    "entries": [
      {
        "entry_id": "blablabla",
        "version": 1,
        "minor_version": 1,
        "domain": "met",
       ...
      },
      {
        "entry_id": "blablabla",
        "version": 1,
        "minor_version": 1,
        "domain": "myuplink",
       ...
      }
   ]
 } 
}

My guess is that if I had your integration running, and then installed the other one it would overwrite the entry with the data from that one, rendering your integration unavailable.

elden1337 commented 5 months ago

But somehow this has to be resolved. The "official" one does not seem to have any writeability at all as far as i could tell which make this one far more usable for my case and many other cases.

elden1337 commented 5 months ago

Yeah feeling quite confident the only non-haxxy way would be to do breaking change and enforce uninstall/reinstall. The haxxy ways I'm thinking of could mess up things for users.

jaroschek commented 5 months ago

My guess is that if I had your integration running, and then installed the other one it would overwrite the entry with the data from that one, rendering your integration unavailable.

I'm currently testing this with the latest dev of Home Assistant Core. And as far as I can tell, there can be just one myuplink integration. If the core integration and the custom integration share the same domain, you can not use both integrations at the same time.

As long as a custom integration with the same domain is installed, this will win and get's used. The core integration is ignored, because the custom integration overrides the domain. One can only use the core integration, if the custom integration with the same domain is not installed or is completely removed.

I agree, that this could cause issues for users who would like to try both in parallel for comparison.

But on the other hand this seems to be a very handy way to publish a different implementation of the same domain.

elden1337 commented 5 months ago

Alright. Your decision how to proceed of course. I just hope that Hacs wont block this once the official is launched in production.