[Guide]Transfer files to components folder

Spent a good few hours trying to figure out how to get access to the components folder without going through the whole USB key transfer steps documented in https://developers.home-assistant.io/docs/operating-system/debugging/#ssh-access-to-the-host

I host HASS on Proxmox and so following the whole USB loading to gain ssh wasn’t a good method for me. Instead here’s how I did it

A small disclaimer here:
Proceed only if you know exactly what you’re doing. I will not be personally responsible or provide solutions if you break anything in HA and can’t revert your changes. There IS a good reason for keeping this out of reach in GUI.

Go into the Proxmox console and type

login

docker ps -a 

Shows you all the docker containers currently running on the OS

docker exec -it homeassistant /bin/bash 

to get into the container’s environment

This is where you can find the custom_components folder that everyone has access to

The components folder is located here - /usr/src/homeassistant/homeassistant

In my case what I needed to do was clone an unreleased commit into the integration folder. I did it by uploading the file into custom_components and then moving it into the relevant integration folder.
The changed file was

__init__.py

I made a backup of the current one and copied the updated copy into the integration folder before restarting HA.

##In the integration components folder (eg. /usr/src/homeassistant/homeassistant/components/myintegration/)
mv __init__.py __init__.py.bak
cp /config/custom_components/__init__.py __init__.py
3 Likes

Why not just install the samba add-on? Or transfer using SFTP with the SSH add-on? Or get the FTP server add-on to transferring over plain old FTP?

Sounds like quite the hassle for something that can just be done dragging and dropping instead.

Because none of the addons will actually let you access the components folder. They are basically sandboxed in other containers.

This is what ssh will show you about the /usr/src folder… empty.

Well, the thing is, you shouldn’t be needing the components folder at all. Any integration can be overridden as a custom_integration.

The practice shown in this thread is complex and really not needed.

And of course, you can alternatively (and recommended) use a development environment as written/documented on our developer portal.

I totally understand, but it’s not for lack of trying. I have tried to place the integration in the custom_components folder but it wouldn’t load correctly whether it was the current branch or unreleased one.
In my case as described, it’s a small edit in init.py that fixed a big problem for me so well worth the effort. In weeks or months should a new HA release finally contain the fix, then these changes will get overwritten anyway as intended.

Thank you! Huge help.

1 Like

So what is the recommended way to override component files in components/media_source/local_source.py?

(I usually use SSH to edit line 189 in local_source.py to add , reverse=True so I can view my latest recordings first, since there are no default sorting options for local media.)

I tried using the method you seem to suggest above → I copied everything from components/media_source to /custom_components/media_source and added , “version”: “0.1” to the copied manifest.json, but even after a few restarts it doesn’t seem to want to work:

# Home Assistant Core

Setup failed for default_config: (DependencyError(...), 'Could not setup dependencies: media_source')

7:11:34 PM – (ERROR) setup.py

Unable to set up dependencies of default_config. Setup failed for dependencies: media_source

7:11:34 PM – (ERROR) setup.py

Setup failed for custom integration media_source: No setup or config entry setup function defined.

7:11:14 PM – (ERROR) setup.py

Any idea why that is or have a better suggestion about how to overwrite the settings in the components/media_source folder in a way that survives Home Assistant updates?