Maybe you want to learn the basics first then?
Here are some links you might wanna read to get an idea how the system ticks you try to work with:
- Getting Started with ESPHome and Home Assistant — ESPHome
- Frequently Asked Questions — ESPHome
- Configuration Types — ESPHome
- ESP8266 Platform — ESPHome
- ESPHome Core Configuration — ESPHome
And then (if you still have questions) you might want to try to ask a good question and using code tags like described here: How to help us help you - or How to ask a good question