Welcome to the HA forums. Impressive first post.
In future could you please post your config properly - see point 11 in this post How to help us help you - or How to ask a good question
esphome has a cover component https://esphome.io/#cover-components - I would look at the Cover Core and Template Cover pages.
There is also a template cover home assistant component. It really depends whether you want the implementation on the esp or in HA. https://www.home-assistant.io/components/cover.template/