Skip to content

DrCoolzic/ESPHomeCompDev

Repository files navigation

ESPHome custom component design tutorial

The main purpose of ESPHome is to enable users with no particular computer skills to automatically create the software for an electronic device. To do this, the user describes his device's configuration in a YAML file. ESPHome then uses a library of components which it assembles according to the user's needs, automatically generating the firmware required for the module to function correctly. The user must then assemble the various components on an electronic board and connect it to a computer to load and execute the code generated by ESPHome.

On the other hand a developer will create new components to enrich the ESPHome library. This task is much more complex, as it involves describing the component's behavior using the C++ and Python languages. A good knowledge of C++ and the basics of Python are required to complete this task.

Having been faced with the need to create a component that didn't exist in the ESPHome library, I wondered about the steps and tools required to complete this task. Although there are many tutorials on creating devices in ESPHome, very few deal with creating new components. I therefore proceeded by trial and error to finally establish an environment and a process to follow. This experience has given me some valuable knowledge, which I'd now like to share. It's worth noting that there are certainly other (potentially better) methods for accomplishing this task.

This series of tutorials attempts to answer some of the questions that arise when designing a component and integrating it (or not) into the ESPHome library.


Each section is accompanied by an English (and French) document describing the section in detail. It also contains the different source code used.


Jean Louis-Guerin alias DrCoolZic on most forums :)