Controlling garage door with Google Assistant

Hello

I’ve managed to setup Google Assistant so that when I speak “Turn on garage door 1” a relay on an ESP32 board will trigger and cause the door to move - up or down depending on it’s position (if the door is closed it will open and if the door is open it will close). This is the only command that Google recognizes; it doesn’t recognize “Hey Google - Turn off garage door 1”. So only the voice command of “Hey Google - Turn on garage door 1” can operate the door up or down.

I have a reed switch on the door that indicates if it’s open or closed.

What I would like to happen is for me to say “Hey Google - Open garage door 1” or “Hey Google - Closed garage door 1”. I would also like google to tell me if I can’t close garage door 1 if it is already closed (based on the reed switch).

Is this possible and how to I go about doing it?

Thanks in advance for any help that can be provided.

im not 100% sure, but i dont think a custom response from Home Assistant to the Google Assistant is curently possible.

What i know you can do:
Use the “Assist” build into Home Assistant, where you can basically customize everything Assist - custom sentences - Home Assistant (home-assistant.io)

But obviously thats not always possible, especially if you have invested into Google Homes / Nest Homes etc.
If you want to use Google Assistant the best i know is to create a Template Cover Template cover - Home Assistant (home-assistant.io). In this you can use your reed switch in the value_template so it knows if its open or closed. Then you can trigger your relay in the open_cover, close_cover and stop_cover segments.
I currently dont know if you can “open” the cover if its already open and then it would maybe close again, but if that happens, you can just put a script there like in the first example on the website that checks if the door is closed/opened or not and just does not do anything if it is already at the state where you want to go to.
What you cannot do with this is that the Google Assistant tells you, that you cant close/open the door, because it already has that state, it will just do nothing then (or whatever you specify in your custom script)

Thanks for the response. I did manage to get it to work. Here’s the code and there’s also a “powered on LED”

 `captive_portal:

# Garage Door Number 1 and 2 & Power LED GPIO
output:
  - platform: gpio
    pin: 16
    id: garage_door_1

  - platform: gpio
    pin: 17
    id: garage_door_2  

  - platform: gpio
    pin: GPIO23
    id: power_led

# Define a light component to control the power LED
light:
  - platform: binary
    name: "Power LED"
    output: power_led
    id: power_light

# Define the status LED
status_led:
  pin: GPIO22

# Define the binary sensor that indicates if a garage door is open or closed
binary_sensor:
  - platform: gpio
    filters:
      - delayed_on_off: 1s
    pin:
      number: 25
      mode: INPUT_PULLDOWN
      inverted: True
    name: "Garage Door 1 Sensor"
    id: garage_door_1_sensor
    device_class: garage_door 

  - platform: gpio
    filters:
      - delayed_on_off: 1s
    pin:
      number: 27
      mode: INPUT_PULLDOWN
      inverted: True
    name: "Garage Door 2 Sensor"
    id: garage_door_2_sensor
    device_class: garage_door 

# Define the cover that controls the garage door to open or close
cover:
  - platform: template
    name: "Garage Door 1"
    lambda: |-
      if (id(garage_door_1_sensor).state) {
        return COVER_OPEN;
      } else {
        return COVER_CLOSED;
      }
    open_action:
      - output.turn_on: garage_door_1
      - delay: 250ms
      - output.turn_off: garage_door_1
    close_action:
      - output.turn_on: garage_door_1
      - delay: 250ms
      - output.turn_off: garage_door_1
    stop_action:
      - output.turn_off: garage_door_1
    optimistic: true
    device_class: garage

  - platform: template
    name: "Garage Door 2"
    lambda: |-
      if (id(garage_door_2_sensor).state) {
        return COVER_OPEN;
      } else {
        return COVER_CLOSED;
      }
    open_action:
      - output.turn_on: garage_door_2
      - delay: 250ms
      - output.turn_off: garage_door_2
    close_action:
      - output.turn_on: garage_door_2
      - delay: 250ms
      - output.turn_off: garage_door_2
    stop_action:
      - output.turn_off: garage_door_2
    optimistic: true
    device_class: garage
reformatted text``Preformatted text`