You've always been able to create custom components for Home Assistant by creating a custom_components folder inside your HA directory but did you know you can use this method to override default components that HA ships with? Using this method allows you to add, revert, or change any component to do whatever you need.

Why would I want to override components?

There are actually a lot of really good reasons to override a default component. Here are a couple reasons that I see it could be really useful:

Manually fix HA component that broke from an update

Home Assistant is really good but it definitely isn't perfect and sometimes things break when updates get pushed out. Here is an example of someone that had their bulbs break after a HA update. By overriding the default component we can actually download the component files before the breaking change and use them to fix our issue.

If you need help getting old versions of component files click here to jump to that section. This is only really helpful if you know what version it broke in.

Adding new features or making changes to a component

Maybe you feel like a component would be really awesome if it had feature X. This method is perfect for downloading an existing component to make changes to do just that. This also makes it extremely easy to make changes and contribute them back up into the HA ecosystem.

Overriding the components

So now that we covered all of that lets actually override the default component:

  • Create a directory inside your Home Assistant folder called custom_components if it doesn't already exist.
  • Navigate to this link and find the folder name for your component and click it.
  • Create the component folder inside custom_components using the name of the component directory you just clicked on in GitHub.
  • Download all of the component files from GitHub and place them inside the newly created component folder.

Note: You must download all of the component files into the new override directory otherwise the override will not work. Even if you are only modifying one file from the component you still need to copy all of the files to the new component folder.

And now you can go ahead and modify the files to do whatever you want (add features, revert changes, etc). Make sure to restart Home Assistant after every change. I also recommend setting the component you are modifying into debug mode to make it easier to detect problems. Here is an example of how to do this inside the configuration.yaml file (if the component is flux_led):

logger:
  default: info
  logs:
    homeassistant.components.flux_led: debug
Enable debugging for a single component (in this case flux_led)

Getting component files for specific version

If you want to revert to a previous component version you can actually get the files from GitHub pretty easily.

  • head over to this link and select the component folder that matches which component you want to override.
  • Press the button in the top left of the page that says Branch: dev
  • Click the tab that says Tags
  • Click the version you want the component files for
Example of getting HA files for specific tag

Download the raw verison of all of the component files in this folder and use these in your custom component folder (steps on how to do this described above). You will now be using an older version of a component.

Check your file permissions

If the override isn't working the most likely cause is file permissions. If you are on Linux I recommend doing an ls -all from within the Home Assistant folder to see what permissions, owner, and group Home Assistant files are using. I would then check the permissions on the files you created in custom_components to make sure they match (I would also check the custom_components folder itself).

Every time I have seen this issue so far it has been caused by file permissions. It's an easy fix.

Need help or want to leave feedback?

I'm always available to help out if anyone needs it. Just leave a comment below and I will do my best to help you out. I also love hearing from my readers so if you have any feedback or just want to say thanks please feel free to leave that as well. :)