OpenGarage - open-source Wifi garage opener

I’d think you would change the MQTT topic for the second unit, use a unique name different from that of the first unit. That, plus changing the names for the second unit in the package yaml file should do it.

The warning you’re seeing is, I think, HA telling you, “This device you’re trying to manage didn’t come from a built-in integration which would usually give each device/entity a unique ID, and allow you to manage certain aspects of it from the UI. As a result, you need to manage it in yaml instead.”

sorry guys, there are a lot of posts =) Can someone help me to set up OpenGarage in HA with video in the same section? I have done it in separate sections, but would like to see the overview, like a button, then I press it and it gives me new screen with video, open/close buttons etc (if its possible). Somethin like in the 6ths post

You need to learn a little lovelace I think. Lovelace - Home Assistant

Based on my experience I can recommend the following ESPHome config that uses the OG hardware and pin layout.

Very fast response and rock solid.

He had the code in several files. I consolidated the files into a single esphome yaml file to suit my needs.


#https://github.com/gabe565/esphome-configs/blob/c3d0aa4e88b63ea05b97cdc2309f7d69b0b36738/opengarage/packages/opengarage.yaml
substitutions:
  # For Home Assistant entity_id, hostname, etc.
  device_id: garage_door
  # Pretty name to show for entities in Home Assistant
  device_name: Garage Door

  # entity_id of the vehicle in Home Assistant
  vehicle_id: car
  # Pretty name of the vehicle in Home Assistant
  vehicle_name: Car in Garage

  # Length of time that the relay should stay active.
  # Some garage doors need the relay to stay active for longer.
  # Longer values can slow down when button presses respond.
  # For example, if you open the door, then quickly try to stop/close it,
  relay_click_time: 500ms

  # Height at which the door is considered open.
  # Should be slightly larger than the distance from the ceiling to the door.
  # Must be lower than the car threshold.
  # Entered in cm. 
  door_threshold: '72'

  # Height at which the car is considered to be home.
  # Should be slightly larger than the distance from the ceiling to the top of the car.
  # Must be higher than the door threshold.
  # Entered in cm.
  car_threshold: '175'

  # Length of time time between distance sensor updates.
  # Lower values will detect changes more quickly, but could result in increased noise.
  distance_update_interval: 500ms
  # Length of time to leave the pulse pin active
  distance_pulse_time: 20us

  # SR04 sensors can be noisy. The median is taken to prevent noisy data.
  # Higher values will slow down the distance sensor's responsiveness,
  # but will result in more consistent data.
  # See https://esphome.io/components/sensor/index.html#median
  distance_median_window_size: '31'
  # When the first value should be sent. Must be lower than the distance_median_window_size.
  distance_median_send_first_at: '5'

  # Sound the alarm on open/close
  # RTTL format references:
  #  - https://esphome.io/components/rtttl.html?highlight=rtttl#common-beeps
  #  - https://en.wikipedia.org/wiki/Ring_Tone_Transfer_Language
  open_alarm: 'false'
  open_alarm_rtttl: 'two_short:d=4,o=6,b=100:c,p,c'
  # open_alarm_rtttl: 'long:d=1,o=6,b=100:c'
  # open_alarm_rtttl: 'open_pulse:d=16,o=5,b=100:c,c6,p.,c,c6,p.,c,c6,p.'
  # open_alarm_rtttl: 'open_slide:d=128,o=5,b=100:c,d,e,g,4c6.,4p,c,d,e,g,4c6.,4p'

  close_alarm: 'false'
  close_alarm_rtttl: 'two_short:d=4,o=5,b=100:c,p,c'
  # close_alarm_rtttl: 'long:d=1,o=5,b=100:c'
  # close_alarm_rtttl: 'close_pulse:d=16,o=5,b=100:c6,c,p.,c6,c,p.,c6,c,p.'
  # close_alarm_rtttl: 'close_slide:d=128,o=5,b=100:c6,g,e,d,4c.,4p,c6,g,e,d,4c.,4p'
  
esphome:
  name: opengarage
  platform: ESP8266
  board: esp01_1m

wifi:
  ssid: 'your-ssid'
  password: 'yoursupersecretpassword'

  manual_ip:
    static_ip: x.x.x.x #device ip
    gateway: x.x.x.x #gateway ip
    subnet: 255.255.255.0
    dns1: 8.8.8.8
    dns2: 8.8.4.4

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "OpenGarage Hotspot"
    password: "yourfallbackhotspotpassword"

captive_portal:

logger:
  level: error

ota:
#  password: 

binary_sensor:
  - platform: status
    name: $device_name Status
  - platform: gpio
    pin:
      number: GPIO0
      mode: INPUT_PULLUP
    id: physical_button
    on_press:
      - switch.turn_on: relay
  - platform: status
    name: $device_name Status

  - platform: template
    name: $vehicle_name
    device_class: presence
    lambda: |-
      if ($car_threshold < id(distance).state) {
        return false;
      }
      if ($door_threshold < id(distance).state) {
        return true;
      }
      return {};
    on_state:
      - then:
          - homeassistant.service:
              service: device_tracker.see
              data:
                dev_id: $vehicle_id
                host_name: $vehicle_name
              data_template:
                location_name: '{{ location_name }}'
              variables:
                location_name: 'return x ? "home" : "not_home";'

cover:
  - platform: template
    name: $device_name
    id: garage_door_cover
    device_class: garage
    lambda: 'return id(distance).state < $door_threshold ? COVER_OPEN : COVER_CLOSED;'
    open_action:
      - if:
          condition:
            lambda: 'return id(garage_door_cover).position == COVER_CLOSED;'
          then:
            - if:
                condition:
                  lambda: 'return $open_alarm;'
                then:
                  - rtttl.play:
                      rtttl: $open_alarm_rtttl
                  - wait_until:
                      not: rtttl.is_playing
            - switch.turn_on: relay
    close_action:
      - if:
          condition:
            lambda: 'return id(garage_door_cover).position == COVER_OPEN;'
          then:
            - if:
                condition:
                  lambda: 'return $close_alarm;'
                then:
                  - rtttl.play:
                      rtttl: $close_alarm_rtttl
                  - wait_until:
                      not: rtttl.is_playing
            - switch.turn_on: relay

sensor:
  - platform: ultrasonic
    trigger_pin: GPIO12
    echo_pin: GPIO14
    name: $device_name Distance
    id: distance
    update_interval: $distance_update_interval
    unit_of_measurement: cm
    pulse_time: $distance_pulse_time
    timeout: 3m
    filters:
      # Sets the value to the max if the sensor times out
      - lambda: 'return isnan(x) ? 3 : x;'
      # Take median of the last 5 values
      - median:
          window_size: $distance_median_window_size
          send_first_at: $distance_median_send_first_at
      # Convert m to cm
      - multiply: 100
      - delta: 1
  - platform: wifi_signal
    name: $device_name RSSI
    update_interval: 5min
    filters:
      - median:
          window_size: 5

status_led:
  pin:
    number: GPIO2
    inverted: true

switch:
  - platform: gpio
    pin: GPIO15
    id: relay
    restore_mode: ALWAYS_OFF
    on_turn_on:
      # Only pulse on for $relay_click_time
      - delay: $relay_click_time
      - switch.turn_off: relay

output:
  - platform: esp8266_pwm
    pin: GPIO13
    id: buzzer_pwm

rtttl:
  output: buzzer_pwm

api:
  services:
    - service: play_rtttl
      variables:
        song_str: string
      then:
        - rtttl.play:
            rtttl: !lambda 'return song_str;'
2 Likes

EDIT - updated to quote the question directed to the immediate post before this. Not sure why clicking “reply” on that particular post didn’t link properly.

@born2fly Does configuring OG with your recommended ESPHome config help with the timeout issues I get using the latest OG official firmware and configs? e.g. here’s an example of what I regularly see in my logs and it seems like this has gotten worse since OG became a native HA integration.

Logger: homeassistant.components.opengarage
Source: helpers/update_coordinator.py:193
Integration: OpenGarage (documentation, issues)
First occurred: February 1, 2022, 23:00:14 (10 occurrences)
Last logged: 07:10:48

Timeout fetching opengarage data```

Does what help? (There are 264 previous posts in this thread, and we don’t know who you are responding to.)

I had issues with the way HA was interacting with OG, it kept freezing mine every day or two. If the polling stopped, the freezing stopped. I went to MQTT and just had the OG push their states to HA via that.

I recall there were threads using OG hardware but loads ESPHome. Would that be an option?

Probably, its just and ESP chip. Never looked into it myself as the mqtt worked fine.

It works. Whether it is an option depends on what you want to do.

I deployed mine as MQTT to begin with and have not had any issues…

Hi, I’m hoping to make one of these. I see the original plan calls for a NodeMcu V2 and others have used V3. Is it still recommended to use V2 or is the V3 a better choice now?

It has been working flawlessly for me using the ESPHOME config.

As long as the pinouts are identical it should make no difference.

1 Like

I used this diagram that was shared by another user.

1 Like

Given the changes to MQTT yaml syntax in 2022.9, I had some trouble getting the above to work initially. I did get it working, so here is my complete solution for those still wanting to setup OpenGarage via MQTT.

In my case, my MQTT username is opengarage, and the MQTT topic is is opengarage, which are configured to match in both the OpenGarage settings, as well in Home Assistant Users.

I am using the Mosquitto addon, and my ACL is set like this:
/share/mosquitto/acl.conf

acl_file /share/mosquitto/accesscontrollist

/share/mosquitto/accesscontrollist

user addons
topic readwrite #

user homeassistant
topic readwrite #

user opengarage
topic readwrite opengarage/#

configuration.yaml

homeassistant:
    packages: !include_dir_named packages

packages/package_opengarage.yaml

sensor:
  - platform: template
    sensors:
      garage_door_status:
        friendly_name: 'Garage Door Status'
        value_template: '{{states.cover.garage_door.state}}'
      garage_vehicle_state:
        friendly_name: "Vehicle State"
        value_template: >-
          {% if states.sensor.garage_door_distance.state | int == 0 %}
          Disabled
          {% elif (states.sensor.garage_door_distance.state | int > 0) and (states.sensor.garage_door_distance.state | int <= 50) %}
          Unknown (Door Open)
          {% elif (states.sensor.garage_door_distance.state | int > 50) and (states.sensor.garage_door_distance.state | int <= 150) %}
          Present
          {% else %}
          Absent
          {% endif %}

mqtt:
  sensor:
    - name: "Garage Door Distance"
      state_topic: "opengarage/OUT/JSON"
      unit_of_measurement: "cm"
      value_template: "{{ value_json.dist }}"
  cover:
    - name: "Garage Door"
      command_topic: "opengarage/IN/STATE"
      state_topic: "opengarage/OUT/STATE"
      state_open: "OPEN"
      state_closed: "CLOSED"
      payload_open: "open"
      payload_close: "close"
      device_class: "garage"



group:
  garage:
    name: Garage Door
    entities:
      - cover.garage_door
      - sensor.garage_door_status
      - sensor.garage_vehicle_state
      - sensor.garage_door_distance

Finally, I have this card on my lovelace dashboard:

type: entities
entities:
  - entity: cover.garage_door
    secondary_info: last-changed
  - entity: sensor.garage_door_status
    secondary_info: last-changed
    name: Door Status
  - entity: sensor.garage_vehicle_state
    secondary_info: last-changed
  - entity: sensor.garage_door_distance
    secondary_info: last-changed
    name: Sensor Distance
title: Garage Door MQTT
state_color: true
show_header_toggle: true
3 Likes

Quick note to say I just set this up and a couple gotchas:

  1. The relay you choose must have a high-level trigger (or set to high level if it is selectable on your relay’s board). A low-level trigger relay won’t work Not only that it won’t allow the esp32 to boot at all because the GPIO used for relay signal can’t be pulled low at boot.

  2. Many have complained of the buzzer being constantly on, and they’ve removed it. I reversed the polarity of the connection to it and that solved the problem.

I find the beeper to be a lot softer than I expected. Anyone else think the same?

I know this is a bit old, and there are a lot of comments covered in this topic / thread.

What firmware are you using?

Do you know if your files work with the opengarage firmware 1.2.0? That version has MQTT settings, but I don’t see any documentation in files under here OpenGarage-Firmware/docs/fw1.2.0 at master · OpenGarage/OpenGarage-Firmware · GitHub

I have it working without MQTT, and mainly I’m just trying to setup an alert if the door opens.

OpenGarage Firmware v1.1.2, never tried with an older firmware sorry, but here is what my MQTT settings are set to if this helps:

Does anyone have a current configuration for OpenGarage using MQTT Mosquito in Home Assistant? Everything I can find seems to be from a while ago and since then configurations have changed and I’m not sure what to correct in order to fix it.

If anyone can help setting it up step by step that would be great (already have MQTT installed and running and OpenGarage installed and running, not sure if they are communicating correctly though)