HA Garage Door control by Google Assistant

Hello,

I’m trying to configure my garage doors to be controlled by google assistant. They’re generic tuya garage doors that i have configured as a switch and binary sensor and work great in HA. I can expose the switch to google assistant and everything works fine, but it shows up as a switch with no PIN. I created the following cover in configure.yaml

cover:        
  - platform: template 
    covers:
        right_garage_door:
            device_class: garage
            friendly_name: "Right Garage Cover"
            value_template: "{{ is_state('binary_sensor.garageright', 'on') }}"
            open_cover:
                service: switch.toggle
                data:
                 entity_id: switch.garageright
            close_cover:
                service: switch.toggle
                data:
                    entity_id: switch.garageright
            icon_template: >-
                {% if states('binary_sensor.garageright') == "on" %}
                    mdi:garage-open
                {% else %}
                    mdi:garage
                {% endif %}
        left_garage_door:
            device_class: garage
            friendly_name: "Left Garage Cover"
            value_template: "{{ is_state('binary_sensor.garageleft', 'on') }}"
            open_cover:
                service: switch.toggle
                data:
                 entity_id: switch.garageleft
            close_cover:
                service: switch.toggle
                data:
                    entity_id: switch.garageleft
            icon_template: >-
                {% if states('binary_sensor.garageleft') == "on" %}
                    mdi:garage-open
                {% else %}
                    mdi:garage
                {% endif %}

This covers works if i place it in a card.

Here is my google_assistant configuration.yaml section

google_assistant:
   project_id: home-6696
   service_account: !include SERVICE_ACCOUNT.json
   report_state: true
   expose_by_default: false
   secure_devices_pin: “####” #(PIN REMOVED)
   entity_config:
    cover.left_garage_door:
        name: left garage door
        expose: true
        room: garage
    cover.right_garage_door:
        name: right garage door
        expose: true
        room: garage

The garage doors show up in google home, but there’s no control over them. I’m suspicious that the ‘secure_devices_pin’ field isn’t working… doesn’t make any difference if i comment it out.

What am i doing wrong?

Alright, nothing is wrong with the code…

2 issues were stopping this from working.

  1. This only works with voice control. Which is fine, but unexpected. I was expecting there for be a button like when i had GA connected with the smart life app. My plan is to only use GA for voice control anyways.

  2. The PIN was not being recognized as a string. GA wouldn’t accept the PIN. It was in quotations and passing the config check but file editor wasn’t showing it green. I delete and just retyped “####”, file editor coded the same text green. After pushing the changes back to google assistant, the PIN worked

There is also some information floating around about need to use customize.yaml with the following fields (likely deprecated):

  • google_assistant: true
  • google_assistant_type: switch

Putting information in the customize.yaml entry works, but all the same info can be in the covers template.

Hi, I also have my HA garage door openers exposed in Google, using very similar code to you, where I have Shelly 1’s configured as covers in my configuration.

They work great in HA, where I can see the state, plus have open and close buttons.

But I’ve also noticed that there is no button control in Google, however opening, closing and asking Google if the door is open or closed works without any problems…

But, I’ve noticed a bug and I was wondering if you wouldn’t mind testing it on your system. If my garage door is closed for example, I can ask Google to close the garage door, and then it will actually open it! It’s of course not something you would do, but we found this bug once by accident, and now I’m trying to figure out if there’s a way to remove this bug.

Anyway, would you mind testing it on your system (ask Google to close the garage door, even though it’s closed, and see what happens)? Would be greatly appreciated to see if it’s just my system, or a Google Home weakness :slight_smile:

Hello all,

I had the same problem as you and could not find a solution at first.
If you read the documentation for cover templates, there is a section for conditions. You can bind the cover up, cover down feature to the condition of your sensors. So even if you make an erroneous call to Google Assistant, it will not be executed.

Here is the code that I used. Please note that I used 2 different sensors to detect the status of my garage door.

cover:
  - platform: template
    covers:
      garage_door:
        device_class: garage
        friendly_name: "Garagentor"
        value_template: >
          {% if states('binary_sensor.garagentor_auf_window') == "off" %}
            open
          {% elif states('binary_sensor.garagentor_zu_window') == "off" %}
            closed
          {% else %}
            {% if as_timestamp(states.binary_sensor.garagentor_zu_window.last_changed) > as_timestamp(states.binary_sensor.garagentor_auf_window.last_changed) %}
              opening
            {% else %}
              closing
            {% endif %}      
          {% endif %}
        open_cover:
          - condition: state
            entity_id: binary_sensor.garagentor_auf_window
            state: "on"
          - service: switch.turn_on
            target:
              entity_id: switch.garagensteuerung_switch_0
        close_cover:
          - condition: state
            entity_id: binary_sensor.garagentor_zu_window
            state: "on"
          - service: switch.turn_on
            target:
              entity_id: switch.garagensteuerung_switch_0
        stop_cover:
          service: switch.turn_on
          data:
            entity_id: switch.garagensteuerung_switch_0
        icon_template: >
          {% if states('binary_sensor.garagentor_auf_window') == "on" %}
            mdi:garage-variant
          {% elif states('binary_sensor.gargentor_zu_window') == "on" %}
            mdi:garage-open-variant
          {% else %}
            garage-alert-variant
          {% endif %}
2 Likes