OpenGarage - open-source Wifi garage opener

Has anybody tried using more than one HC-SR04 sensor to keep track of multiple cars?

1 Like

I ordered the passive buzzer, but mine is still running at all times. This is the one I purchased: https://www.amazon.com/gp/product/B0777P6FN5. It looks exactly like the one Dave said he is using that works. Is there something I’m missing?

Anyone using this in Homekit? I’m running into a problem of false notifications.

In the Home app, if I press the garage door button to open the door, the button status quickly changes to “opening” and then almost immediately reverts back to “closed” status which triggers a notification on my phone “Garage door was closed” even though it’s still in the process of opening the door. After about 12 seconds once the garage door is finished opening, I receive another notification saying “Garage door was opened”. The opposite happens whenever I close the door. However, in HA the states are reported perfectly.

Just trying to make the wife happy with my new gadget but she’s not loving it.

To add, my current setup is connecting OpenGarage to HA using the native platform and example config, then pushing this out to HomeKit for use on the Home App with iPhone and CarPlay.

I was able to solve my issues by using MQTT instead of the built-in component. If anyone is interested in going this route here’s the code I used to get it working:

Add to your configuration.yaml

cover:
     - platform: mqtt
       name: "Garage Door"
       command_topic: "youropengaragedevicename/IN/STATE"
       state_topic: "youropengaragedevicename/OUT/STATE"
       state_open: "OPEN"
       state_closed: "CLOSED"
       payload_open: "open"
       payload_close: "close"
       device_class: "garage"

sensor:
  - platform: template
    sensors:
      garage_door_status:
        friendly_name: 'Garage Door Status'
        value_template: '{{states.cover.garage_door.state}}'

Add to groups.yaml

  garage:
    name: Garage
    entities:
     - cover.garage_door
     - sensor.garage_door_status
3 Likes

Hi,

Are you able to open/close the garage using this? when i press open/close nothing happens with the garage. I see the values publishing in mqtt topics. Doesnt it need the devicekey to open/close the garage door?

./Sooraj

For even more fun here is another MQTT (yay for no polling!) example with a vehicle state entity and distance entity. This requires a version of the firmware that reports the distance to the /OUT/DIST MQTT topic.

  • 80 is my door threshold
  • 150 is my vehicle threshold
  • a compatible firmware can be found here (thanks @gabe565)
  - 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.opengarage_distance.state | int == 0 %}
          Disabled
          {% elif (states.sensor.opengarage_distance.state | int > 0) and (states.sensor.opengarage_distance.state | int <= 80) %}
          Unknown (Door Open)
          {% elif (states.sensor.opengarage_distance.state | int > 80) and (states.sensor.opengarage_distance.state | int <= 150) %}
          Present
          {% else %} 
          Absent
          {% endif %}

  - platform: mqtt
    name: "OpenGarage Distance"
    state_topic: "OpenGarage/OUT/DIST"
    unit_of_measurement: "cm"
     
      
cover:
     - platform: mqtt
       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"

Then groups.yaml can have this or whatever:

  garage:
    name: Garage Door
    entities:
     - cover.garage_door
     - sensor.garage_door_status
     - sensor.garage_vehicle_state
     - sensor.opengarage_distance
1 Like

Yes, the OpenGarage always requires a key to actuate its relay.

Apologies for the stupid question, but do I need to bespoke the code at all? I saved the file into HA following the instructions and rebooted HA but I still have the issue than the “Opening” state remains in HA despite the door being “Opened” or “Closed” within the Opengarage local network interface. Only a reboot of HA solved it this morning.

The opengarage code in home assistant has been rewritten since @swbradshaw’s post.

Thank you, I hadn’t appreciated that (clearly!). So I can remove the file by the sounds of it. I’ve had greater reliability today as a result of increasing the the door threshold distance - I think the ultrasonic sensor is rather inaccurate in this weather and allowing for a significant margin of error seems, at least today, to have resolved my issue.

I think they can be temp dependent, but I am not sure what weather you have. Beautiful summer day here :slight_smile:

One other thing to check is the usb charger you are using to supply power. I had issues with mine varying by about a 1m over subsequent reads, which would cause the car in garage reading to go in and out constantly.

My 1A usb charger was not providing stable/clean/sufficient power to the unit and it was causing the problem. Replacing it with a 2A charger (despite their webpage saying 1A is fine), it fixed it straight away.

Thank-you for sharing - got this working tonight. Great to migrate to MQTT.

is moving to MQTT better for the hardware (ie. loss polling) ? If so, I would like to try to get this working.

If it works for you then there’s probably no difference, but connecting HA to mine would cause the unit to intermittently freeze up and need to be reboot. If it wasn’t polling it worked fine, and moving to MQTT fixed it for me.

it doesn’t care over mqtt.

I’m back again and, fresh from some basic knowledge of mqtt (for an alarm keypad and a Aqara button), I thought I’d make the move to mqtt for my opengarage unit earlier today. I used the code above but my Vehicle State entity was always shown as “Unavailable”. However, after some digging I found someone recently solved the problem for another user and so I’m posting it here for anyone else who struggles:

Essentially a value template line was added:

  - platform: mqtt
    state_topic: GarageDoor/OUT
    value_template: "{{ value_json.DIST }}"
    unit_of_measurement: "cm"
    name: "GarageDoor Distance"

EDIT: Well that was strange - a reboot and I lost the vehicle distance reading. It took commenting out the json value line to bring it back. Thoroughly confused!

Just trying out @gabe565’s 1.1.2 OpenGarage firmware (thanks Gabe!)

For my implementation, I used the advice from @addie above, but created a package to keep everything pertaining to OpenGarage in a single file.

I also made use of the additional data being sent in the JSON MQTT payload on the OpenGarage/OUT/JSON message being sent by this new firmware to get the distance value.

For those not using this firmware yet, this new message contains content like:

{"dist":161,"door":0,"vehicle":1,"rcnt":98}

I added a packages folder to my file system, and in my configuration.yaml, did this:

homeassistant:
  packages: !include_dir_named packages

Then, in my packages folder, I created the file package_opengarage.yaml containing the following:

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.opengarage_distance.state | int == 0 %}
          Disabled
          {% elif (states.sensor.opengarage_distance.state | int > 0) and (states.sensor.opengarage_distance.state | int <= 55) %}
          Unknown (Door Open)
          {% elif (states.sensor.opengarage_distance.state | int > 55) and (states.sensor.opengarage_distance.state | int <= 170) %}
          Present
          {% else %}
          Absent
          {% endif %}

  - platform: mqtt
    name: "OpenGarage Distance"
    state_topic: "OpenGarage/OUT/JSON"
    unit_of_measurement: "cm"
    value_template: "{{ value_json.dist }}"

cover:
  - platform: mqtt
    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.opengarage_distance

I suspect I could have used more of the JSON payload to simplify the Vehicle State, but when things started working, I stopped working!

Would you be able to provide more insight on how you implement this into Home Assistant? I have Home Assistant up and running, and I have my OpenGarage up and running, but I cannot seem to make a card with any OpenGarage information.

Is your OpenGarage talking to your Home Assistant over MQTT?

I used MQTT Explorer (on Windows) to subscribe to the MQTT topic “OpenGarage/#” and see what messages were flowing. It’s a great tool for purpose. I suppose you can also use the MQTT tooling in Home Assistant to subscribe to a topic, and perhaps that’s a better tool to make sure that HA is getting those messages (and vice-versa).

If you are using the package file I shared above, you should be able to add an Entities card to a lovelace dashboard with something like this inside:

type: entities
entities:
  - entity: sensor.garage_door_status
  - entity: sensor.garage_vehicle_state
  - entity: sensor.opengarage_distance
  - entity: cover.garage_door
title: Garage Door MQTT
state_color: true