Please consider bringing back custom components

I understand the reasons why custom component support was removed, as outlined here.

But I feel that these reasons are mostly targeted towards “proper” components that are meant to be distributed to other users, and in those case, yes, external components are much better.

However.

These reasons are meaningless for people that have existing projects using custom components. They, like me, found or wrote some code somewhere in the past that works, and has been working for a long time. And now they can’t compile their projects anymore.

If you didn’t write it yourself, the original writer of the code may have long since moved on, and given that this wasn’t really a proper component in the first place, probably just shared code that worked for them, in the hope that it would work for others. They probably never intended this to be a proper component.

The users of the code can follow instructions very well, and got it working, but that’s about it. They aren’t programmers. They can’t be expected to rewrite the custom component to an external one. I’ve seen many posts popping up the last couple of days from people asking why their project, with custom components, doesn’t compile anymore, and how to fix it.

And I guess that’s the main issue here: there isn’t a trivial fix. We can’t tell people to “just move that C++ code to a separate file”, and it’ll work, because it won’t.

Side note: I’ve recently implemented my first external component, and even though I’m a seasoned software developer, it was difficult. With the removal of custom components the documentation for external components has somewhat improved, but not nearly enough to make it a reasonably easy process (I still don’t understand half of what the Python part of my component does, I just lifted code from existing components and it seemed to work :man_shrugging:t3:).

It feels like there’s a mismatch between the purpose of external components on one side, and custom components on the other, that perhaps hasn’t been given enough thought.

External components are meant to be shared with other users and could even end up as part of ESPHome itself. They are “proper” components, and therefore, they have strict rules on implementation, validation, etc.

Custom components are quick-and-dirty: they lack the safeguards that external components provide, but they often get the job done much quicker, don’t require as much programming/development skills, and are often a good solution for personal projects. They get shared with other users, but usually with a “this may not work for you as well as it does for me” guarantee. But they do work, are they are being used.

Removing support for custom components has left a void in the “getting things done quickly” category, and has also left a lot of users with projects that now cannot be compiled anymore, and that a lot of them cannot fix.

EDIT: I took the custom component code from ESPHome 2024.10.0 and created an external component for it (yes, I can see the irony here :wink:). It might be enough to enable custom components in 2025.2.0 again (I tried against the one project that I have that requires custom component support, and it compiles). See here: GitHub - robertklep/esphome-custom-component: Brings back support for custom ESPHome components

21 Likes

Agree.
You should be able to keep loading your old custom components.

2 Likes

Spot on! Many devices I cannot compile anymore. And devs tell me “use an archived esphome”.

Goal-Target-Missed…

But the user (me) is left with issues.

1 Like

If you don’t need any of the features of the newer builds on those devices you can install the Legacy ESPHome addon from HACS and continue as you were.

Sure but why should that be needed.
The fix didn’t fix anything it just broke something.

1 Like

@Hellis81 @sender see the first post, it may provide an easy solution.

2 Likes

In a similar position to OP but I am a very occasional programmer, and have just created two external components. One of my components was fairly simple as I modified an existing one but the other meant combining bits from various sources and randomly changing things until it worked. I’m OK moving to external components but the documentation isn’t sufficient in my opinion, I realise how difficult writing documentation is but unfortunately I don’t have the knowledge to contribute.

I will share my components when complete but again the validation is too strict for me to consider merging into ESPhome, however I do understand the reasons for.

2 Likes

I’m thinking that this is probably the best way to go, because I doubt the ESPHome developers will revert this change.

1 Like

It works well!!!

2 Likes

You are a lifesaver. I have a mission critical Home Assistant integration of a custom component that parses serial data and was tearing my hair out trying to port it to an external component. Not a straightforward task at all. No one else would have any need for the custom component so I really do not care about it being sharable.

2 Likes

Thank you Robert :blush: !
It did the trick for my dirty dirty custom code !
Greets, Tom

1 Like

I dont think its gonna happen folks… Same thing that happened to custom components happened to me when i was a kid. My dad and custom components must shop at the same grocery store because they both go get a gallon of milk and never come back… So weird.

Thanks. Works well. Disappointing this was removed.

Kinda ironic this change undermines ESPHome progress to make IoT available to the masses.

Are you sure about?

The intention is to force custom components to external components which have a higher bar. This higher bar is specifically to make them easier to use for the masses. This has the effect of making it harder to create components for others to use.

The reality is likely somewhat different. The documentation for creating external components is very dense and limited and doesn’t help much if you don’t already know what to do, i.e., there are many gaps in the required knowledge that are not covered by any documentation I could find.

Since this is open source, you now have a solution, because someone took the time to fix something that bothered them and shared that with everyone.

I’m sure the intention was well meaning but the end result, is it creates an unnecessary barrier for many enthusiasts.

IMO there is a disconnect from the reality that this feature is frequently used by hobbyists for niche cases, where effort to build a proper component isn’t justified. The better option would have been just the flag there is no support for this feature, rather than block.

It may seem a trivial matter for a competent developer, but the appeal of ESP Home to the average hobbyist is how easy it is to create your own bespoke solutions and this change makes that unnecessarily harder.

1 Like

I agree with you as did @robertklep but he did more, he actually fixed it so you can still use custom components, which I thought was really creative. He has also been helping people use his external component to get the removed functionality back. So, you really should thank him for doing that.

I also agree that building an External Component is too hard. That is an area to focus on, because I do believe it would be better if the people creating custom components created external components, but I also understand why many might not want to. So perhaps getting people interested in making it easier to understand what one needs to understand to create a good external component would be worthwhile. I don’t believe this is an easy task and will take someone who does not understand learning a whole lot through some unknown process or someone who does know remembering what it was like when they did not know and how to explain things in a way that will make sense to others. That is rarely easy.

Hi @robertklep
Your solution worked with a “custom component” I found somewhere over the net, and it was working seamlessly for my purposes…
I’ll try to move it to an external component, but at least now I have a backup plan.

Thanks

1 Like

This is just a thankyou for the fix @robertklep
I was hours into a forced update of an old device that has been solid for at least 2 years without sucess until I found your solution.
Cheers

2 Likes

I also just want to say thanks for the fix @robertklep
It saved me a TON of time trying to figure out how to deal with this!

1 Like

Another person chiming in to say this is ridiculous, AND that @robertklep fixed it for me.

Thanks man!

1 Like