New to ESPhome: need help to get started with DIY project

Hello,

I’m using HomeAssistant for several years and I also created a bunch of IoT devices with raspberry Pi and Arduino. I want to give the ESPhome integration a try and need some help on how to get started.

Description of the project:

I’m building a roman shades controller. The curtain will be opend with a tubular motor with mechanical stops. The motor can turn up and down and will stop at a predefined point. Power to the motor does not need to be interupted when the curtain is opened or closed. To control the motor I’m using 2 relays:

  • first relay will turn on/off power to the motor. (to stop the motor during opening or closing)
  • second relay will decide the direction of the motor (up or down)

This will be controlled with a Wemos D1 mini with relay1 on PIN D3 and relay2 on PIN D2.

The curtain will be controlled with 2 push buttons hooked up to another ESPhome device (input controller) 1 button for UP and the other for DOWN. I should also be able to control the curtain from HomeAssistant as well. The input controller is simple and I already got it working controlling lights in home assistant.

When the up button is pushed the curtain needs to turn on relay1 and put relay2 in the off (up) position.
If the up button is pushed again when in the open state the curtain needs to stop by disabling relay1. If the curtain is already fully opened this will not have any result but during the opening it will stop the curtain at the current position.
Same goes for the down button. when pushed the curtain needs to turn on relay1 and put relay2 in the on (down) position. If the down button is pushed again when in the closed state the curtain needs to stop by disabling relay1. If the curtain is already fully closed this will not have any result but during the closing it will stop the curtain at the current position.

How should I configure this in ESPhome? what kind of components do I need to configure?

Can somebody help me to get started?

Thank you.

Have a look at endstop cover or feedback cover, that might suit

This seems like it could be done with a bunch of if-then statements. Have you taken a look here: Automations and Templates — ESPHome

All the best for your project!

Do you want to integrate this in the esphome of the motor esp. Or would you run it in automation’s in HA.
To me that seems the most convenient version for then you only need to make two Automation’s one for the up button and its action and one for the down button, here you can use the stop at the top and bottom as condition to switch motor direction? I wonder if it is needed to throw in a boolean helper to tell motor is running, doubt that. But then the automation should not be that difficult, I guess.

1 Like

Take a look at the logic in the “one touch button” for this project. The project in general should be useful.

I adapted it for another project and it works well.

Single button logic is roughly: If closed then open, if open then close, if moving then stop, if mid then opposite of last movement. You can adapt for yours.

I think some of the config may have changed over ESPHome versions. I can share mine if you need.

You can also look at the ln298n (or mini version) for motor control (maybe for next project). They can simplify motor forward/reverse and even speed.
https://www.google.com/search?q=ln298n&sxsrf=ALiCzsbxlLdNfzeHNYb9XONUrd6S1oNFzQ%3A1667335880541&ei=yIZhY_3MIIuX4-EP14m9gA8&oq=ln298n&gs_lp=EhNtb2JpbGUtZ3dzLXdpei1zZXJwuAED-AEBMgQQIxgnMgQQIxgnMgQQIxgnMgcQABiABBgKMgcQABiABBgKMgcQABiABBgKMgcQABiABBgKMgcQABiABBgKwgIKEAAYRxjWBBiwA8ICBhAAGBYYHsICBRAAGJECkAYISPIYUNkLWNMTcAF4AMgBAJABAJgBuwGgAZ0JqgEDMC434gMEIEEYAIgGAQ&sclient=mobile-gws-wiz-serp