Use esp32 as garage door opener

Hello, first post on this forum so I don’t quite know the ins and outs here yet.
I was thinking almost the same as this video:

I want to be able to connect my dumb garage port to my home assistant rpi installation. from the youtube video I got a parts list but I got kind of confused as to why he chose what he chose.
In his video he uses 2 magnetic contact sensors, one of them is normally closed and the other is normally open, is there a reason he bought 2 different types instead of just 2 pcs of the same?

I want to replicate what he did but using this parts list:
relay
2 sensors
esp32 type c

this does not account for cables or usb power.

But would this parts list be able to work together and could I use the same-ish code as the youtuber? config for ESP

My guess is probably just so that the state of the fully open and fully closed sensors is natively as you would expect at the hardware level for the use case.

Or maybe it’s that if a device spends most of its time in one position (garage door is closed) then it is better practice to have both the sensors in an open position for this state. I think…

I’m not certain but I don’t think it really matters. You can just invert them as required at the software level.

So I reckon getting whatever is fine.

Okay thanks, I’ll buy 2 open then. We’ll see how it goes.

They used 2 different ones because you need them to essentially be opposite for the cover logic to work properly. Its hard to explain and honestly i dont fully understand the reasons but, I banged my head for days trying to get my door to keep the open,opening,closed,closing states to stay in sync and thats how you have to do it. you can either buy 2 different ones or you will need to invert one of your binary sensors.

The code from that project is kind of weird IMO. He made a crude attempt at doing the door logic and Esphome has really good options for different covers that are far better than that and you don’t need to manually program the logic like that anymore, it’s done for you in the Feedback Cover — ESPHome
READ THE DOCUMENTATION!
The worst thing you can do is just copy/paste code you find on the internet and cross your fingers, hoping that it will work. Make an investment in yourself and try to understand it and learn it. It’s not that hard.
You can use my door config as a reference but, try to make your own.

cover:
  - platform: feedback
    name: "Overhead"
    id: overhead_2
    has_built_in_endstop: true
    max_duration: 17s
    open_action:
      - switch.toggle: cover_switch
      - text_sensor.template.publish:
         id: template_text
         state: "Opening"      
    open_duration: 16s
    open_endstop: top_reed_switch
    
    # open_sensor: open_movement_binary_sensor

    close_action:
      - switch.toggle: cover_switch
      - text_sensor.template.publish:
          id: template_text
          state: "Closing"
    close_duration: 16s
    close_endstop: bot_reed_switch
    
    # close_sensor: close_movement_binary_sensor

    stop_action:
      - switch.turn_off: cover_switch
      - text_sensor.template.publish:
         id: template_text
         state: "Stopped/Idle"         


button:
  - platform: restart
    name: "Barn Sensors Restart"
  - platform: safe_mode
    name: "Barn Sensors (Safe Mode)"  

binary_sensor:
  - platform: gpio
    pin: 
      number: D1 
      mode: INPUT_PULLUP
      inverted: true
    id: top_reed_switch
    name: "top reed"       
    on_state:
      if:
        condition:
           binary_sensor.is_on: top_reed_switch
        then:
          - text_sensor.template.publish:
              id: template_text
              state: "Open" 
       

   
  - platform: gpio
    pin: 
      number: D5
      mode: INPUT_PULLUP
     
    id: bot_reed_switch
    name: "Bottom Reed"   
    on_state:
      if:
        condition:
           binary_sensor.is_on: bot_reed_switch
        then:
          - text_sensor.template.publish:
              id: template_text
              state: "Closed"
text_sensor:
  - platform: template
    name: "Overhead Text"
    id: template_text      
1 Like

Tysm! Yeah I should learn yaml, that would make it way easier for me to understand. I’ll try your code when i recieve the items.

Is there any way to do this with one reed switch only. I can do it with Tasmota, but I cannot figure out how to do it with ESPHome.

what cant you figure out? You can do it with 1 reed but, I wouln’t. It’s going to be harder to keep track of the door states and therefore less reliable. Do you reside in the Sahara desert or somewhere that doesn’t have online shopping? If not, you can order reed switches for very little money…10$

Seriously? What’s the point of doing the project if you’re only going to do it half-way?

The other and arguably best option would be to just buy a Shelly2.5 relay. This will work as the relay to trigger the door, it also has 2 DC current monitoring inputs and through current it knows exactly when the door starts/stops, if it’s open/closed and the exact % it’s open.

The problem with the old esp8266 w/relay and 2 reed switches is it doesn’t know when someone pushes the button/s on the wall, it doesn’t know when a car RF remote is used to trigger the door and it doesn’t know if something triggers the laser obstacle sensor which causes the door to stop then open.

https://www.shelly.com/en/products/shop/shelly-2-5-ce-ul-1

Thank you for your reply. I don’t live in the Sahara Desert, and I can easily buy another reed switch. Currently, I am using an ESP32 device running Tasmota with one reed switch, and it is functioning perfectly. However, I am curious to know why ESPHome is unable to perform the same function with just one reed switch.

It can, its just that second reed switch helps keep the correct open’opening’closed,closing states. With only one reed switch, it “assumes” the door position and if its wrong hitting the top or bottom reed will correct the states. Having only one reed, the true door state wont ever update unless it hits your single reed switch.

I would seriously suggest the Shelly2.5 though. That thing will track the door 100% while even with 2 reeds the door state can get out of whack.