Yet another development environment setup lack of understanding

My environments are:

  • Main HA system comprising Rpi 4; Coe 2025.2.5, Supervisor 2025.03.0, Operating System: 14.2, front end: 20250221.0
  • Development system of M1 iMac with Visual Studio Code and the Platform IO IDE and ESP-IDF extensions, al the latest versions.

As I have a rather complicated device (that actually has a rather straight forward interface as far as ESPHome is concerned but the code to interface to the device is still ‘in development’) and so I want to do the ESPHome ‘external component’ development on the iMac. (Only later when it is all working do I want to copy the files to the RPi and use the component ‘for real’.)

I have opened a terminal and executed the ‘git’ and other commands as stated in 'Contributing — ESPHome" and to the line about “source venv/source/activate”.
That web page then says to use your “IDE of choice” so within the same terminal session as I used for the above commands I entere “open /Applications/Visual\ Studio\ Code.app” which brought up the Visual Studio Code IDE (I assume within the virtual environment).

This is where the documentation (in my opinion) runs out as it jumps to how to upload the completed component to github - I need the steps in between.

To get started, I have created a new folder under the ‘esphome/esphome/components’ folder and then copied in the files from the ‘switch’ component as this is (what I thought) would be a simple basis for the first part of my component (which will need a switch, and a couple of numeric values to be set and read - so my idea is to start with the switch and expand). I have changed the names etc within the files to suit my new component.
I have also created a folder under ‘esphome/tests/components’ and copied

Here I’m stuck.

  1. What commands are needed to compile the code for this component?
  2. Where are these entered (I assume the ‘terminal’ within Visual Studio Code)
    I’ve seen reference to ‘esphome compile’ but that just brings up python errors about no module named ‘esphome.config_validation’ from automation.py - as I have not written that file I assume it is part of the esphome system so why can it not be found!
    I’ve also seen reference to running 'scripts/test_build_components -e compile -c ’ followed by the new component name but that generates the same error when run from the ‘top’ level ‘esphome’ folder.

Please note that I don’t want to use github as I need to keep this all private for now and also I don’t want to set up a docker system on my iMac.

[At this stage I could start a rant about the poor quality (in my opinion) of the documentation in this area but I have seen many other posts saying the same thing but getting nowhere. I’m sure if you know the way esphome is constructed and all of the various technical details, then the documentation makes sense. However it would be REALLY useful for those of us that are starting out for a straightforward step by step document that does from an ‘empty’ system through the installation and the creation of a simple component. It also needs to describe what all of the code is that is needed in the python scripts that seem to ‘.extend’ a lot of (presumably undocumented) internals such as CONFIG_SCHEMA.
But I won’t!!!]

Thanks

Susan

I am not sure why you have set up a development environment though. You aren’t aiming yet to develop new features in esphome are you?

You probably just need Installing ESPHome Manually — ESPHome

Isn’t there an ESPHome forum for this question?

Moved

Thanks - Apologies
Susan

BTW - I tracked down the problem with the ‘esphome.config_validation’ issue - I had to completely remove all of the esphome folders and reinstall esphome - the file is now there.
No idea why is was missing before.

1 Like