I want to try some minor tweaks to an add-on directly in my HA environment. I’ve installed Portainer and in the app directory of its container I can see the python files of the add-on. If I edit a file (for testing my approach I’ve simply edited a write to the log which should show up but doesn’t) in the app directory and then restart the add-on, my edit is lost and the original file is returned. Clearly, restarting an add-on copies the source files from somewhere. Try as I might, I can’t find this original source. Can somebody point me in the right direction (ideally the appropriate documentation too)?
Ultimately, I might want to either fork the add-on or suggest to the original writer some updates.
The best way to do this, I find, is to create a copy of the integration and place its files/folders in a folder in the custom_components directory. Then add a version-line to the manifest.json file and you should be good to go.
You can do all this from within HA itself via the Visual Studio Code addon. Adding the directories, files and make the changes to the code.
Sorry, I did not read properly
Yes, for an addon it’s best to fork to your own github repo, make the changes and load it from that repo too. I’ve done this in the past too.
When the changes work, you can create a pull-request for them from your own repo. There will be a button for that shown when you have made the changes, all automatic.
I have read this but confess to still being lost. I suspect there’s a gap in my understanding of how the whole docker environment works. The local run option, which would seem to be what would be best for me, is confusing to say the least (and I’m not IT illiterate, quite the opposite).
If you can steer me in the right direction I’d really appreciate it. If there are any tutorials, videos etc out there that would be perfect. I don’t want to waste anyone’s time.
To start with, I simply want to make some small tweaks to an existing add-on. I’ll be doing this in my production environment (I know this is bad practice but I really am talking about tweaks and I’m confident as I can be nothing will break, plus I don’t have another option at the moment). I want to edit the code of the add-on, restart it, see what happens, make another edit, repeat ad nauseam. I can’t find where the local “master” source for the add-on is (I can’t believe an add-on is dependent on github for a restart, HA must be resistent to network failures if it restarts, I presume that when an add-on restarts, a master of it is copied to the docker container where it runs).
If I can work this out I’ll happily document how I did it to help others in the future.
Any add-on is an executable but restricted with exact port numbers to communicate with outside world. When you containerized the executable, you are sealing the content but can allow some folders to be mounted externally, so you can go with external volume path but i would say, let’s go easy.
Setup the executable somewhere else, run it there without docker or add-on and test your changes. When you are done, you can update the main add-on with your changes.