Editing Component Files in Hassio

Had this yesterday with a function that was broken in the latest update and the great man himself, @balloob, pointed me in the right direction.

Copy the file you want to edit into the custom_components folder but make sure you recreate the folder path inside that folder, for example, I needed to edit harmony.py which is here…

/usr/lib/python3.6/site-packages/homeassistant/components/remote/harmony.py

…so I added /config/custom_components/remote/harmony.py

If you get errors about not finding other files in your new folder just copy them into it too. You can get the files from the homeassistant github, I couldn’t see how to download them so just copied the code and pasted into a new file, saving with the relevant name.

10 Likes

I’m trying to fix the foscam issue since 51.2 is not out yet for hassio.
I use the ssh addon but cannot find the folder: /usr/lib/python3.6/site-packages/homeassistant/components
Am I looking in the wrong location?

This is a good simple tip that should be part of hass.io docs.
There are a lot of people who have customisation in their hass solution who are disappointed that hass.io is not flexible enough for them.

This is a nice solution as it decouples customisation from the core hass image, so allows you to see exactly what has been changed.

2 Likes

@redwings15 :
SSH on port 22222 instead of 22 and you’ll be logged in the “container manager”.
Then you can do ‘#docker ps’ to list the containers.
If you want to log in into a container => example : ‘#docker exec -t -i homeassistant /bin/bash’
To get info about a container : ‘#docker inspect homeassistant’

If you change something inside a container, it will be lost after restart that’s why you have to use a shared folder with the “base image” which is persistent.

3 Likes

As you say, it’s not a good practice to make edits in the docker image.
Better to get used to using custom_components folder.

Thanks! Where do I put this custom_components folder? Since I’m using Hassio I have access to 4 folders… addons, backup, config, and share, but I don’t see a custom components folder and don’t know where to put it either.

It goes in the config dir:

config/custom_components

1 Like

Perfect thanks!

https://home-assistant.io/developers/component_loading/

1 Like

Hi

Im completely new to HA (Hass) but not to home automation:slight_smile:

Maybe this is a easy one but how do you find and copy the harmony.py (In this case) file over to custom_components if we dont have access to the components folder in Hass?

Or Is this not possible on hass.io

https://github.com/home-assistant/home-assistant/blob/master/homeassistant/components/remote/harmony.py

Hi there, I have a similar problem under Hassio, which this post has helped with. In my case I fixed a couple of issues with the “russound_rnet.py” component, under media_player. I can see that HASS is now using the patched code under “config/custom_components/media_player”. the file “russound_rnet.py” has a REQUIREMENTS = [‘russound==0.1.7’], which is a file called “russound.py”, normally under “.homeassistant\deps\Python36\site-packages\russound”, that I have not been able to locate in Hassio. Can you guys help me, by telling me where this Requirement file should go in Hassio?

Thanks in advance.

I’m trying to do the same with https://github.com/easink/hass.aioheos.media_player but I don’t seem to get the requirements fixed either… Normally with python, dependencies can just be put in the same folder and they will be recognized when importing, but this doesn’t seem to work.

@Bobby_Nobble would this work for the zwcfg_xxx.xml file? Im trying to edit it for the Central scene fixes but it keeps over writing it because i cant get HA to stop correctly.

Sorry, don’t know about that one. Do a backup and then give it a go, nothing to lose of you’re prepared for the worst :+1:

@bobby_nobble thanks for the reply. I figured out what I needed to edit the xml file. just needed to update the SSH add-on. All is good now.

1 Like

I was able to override an included file by doing the following. In my case I needed to override some code in the /usr/lib/python3.6/site-packages/pysma/__init__.py file which is used in the sma sensor. To do this I copied those files into the custom_components directory like so

/config/custom_components/sensor/sma.py
and
/config/custom_components/pysma/__init__.py

And then in the sma.py file I found where pysma was imported and changed the code from

import pysma
to
import custom_components.pysma as pysma

After I did this everything started working.

1 Like

Connection refused on port 22222

Have tried to follow https://home-assistant.io/developers/hassio/debugging/ but no luck so far

Thx all, this worked like a charm!

SInce Version 107.x the source files in the docker container are located at /usr/src/homeassistant

1 Like