How to modify core integration for testing

I’m trying to troubleshoot core integration. In this case LCN.

I’m able to use it’s dependencies locally:

I’d like to try out my changes directly in HA.

And here’s the problem. I’ve got no idea how I can override python dependencies which I assume are installed together with integration in HAOS.

I’ve tried making custom_components directory with no luck… HA says it’s custom integration however, official python module remains in use.

module.py is the one I want to use modified

You will find this very challenging in HAOS.

Whilst you can amend the code as you have and that will work, you will get a dependancy conflict on the pypck library if you try and change its version.

You can hack this by setting up shell access to your HA instance and change the manifest file of the core lcn component and its entry in requirements_all.txt

Much better to create yourself a dev environment and do it this way, especially if you plan to issue a PR for your changes.

1 Like

Hey, thank you very much! I was able to edit python modul on the file system and within container.

Somehow, I was struggling with generating proper keys using putty so I used ssh-keygen in my linux machine.

What worked for me with a component with a single library it has a dependency on:

  • Overriding with a custom_component as described here - e.g. custom_components/snoo
  • Copying in the modified library (e.g. python_snoo) as a subfolder - e.g. custom_components/snoo/python_snoo
  • Removing the dependency from manifest.json, as well as adding a version (I used 99.0)
  • Editing all Python files in the custom_components/snoo folder to change the imports from the library name to use the subfolder in the same directory
    • e.g. change from python_snoo.baby import Baby to from .python_snoo.baby import Baby - notice the new . at the beginning. I used global find/replace with the VS Code addon to do this.
    • In my case, some directory structure modification within the library was required to get it working - moving all the files to the root directory of the library specifically (vs a src subfolder).
    • There were some other changes I had to make where the library was referencing itself by name vs a relative path

Definitely annoying, but let me test/use my changes in HAOS before they were merged!