OpenGarage - open-source Wifi garage opener

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

I attempted to, but upon a configuration check I received this error:

Component error: packages - Integration ‘packages’ not found.

This is what my configuration.yaml looks like:

# Configure a default setup of Home Assistant (frontend, api, etc)
default_config:

# Text to speech
tts:
  - platform: google_translate

group: !include groups.yaml
automation: !include automations.yaml
script: !include scripts.yaml
scene: !include scenes.yaml
packages: !include_dir_named packages

From there I created a folder called packages, within packages I created a file called package_opengarage.yaml, and in that I copy / pasted what you included above.

I’m also confused where in your package you’re pointing to the OpenGarage unit IP, or how you’re having the OpenGarage unit get information into MQTT. I must be missing something :-\

Ah! I probably need to fill out the MQTT section in the OpenGarage interface after I updated to Gabe’s firmware!

Yes, OpenGarage needs to be able to see and communicate with MQTT, and both sides (MQTT & OpenGarage) have to be set up to use the same topic.

You’ll also want to restart HA to take up that change to the packages folder.

So have it working to some extent; however I cannot seem to get the distance portion to show data. MQTT Explorer shows that information is being received by my MQTT server (see attached screenshot). I changed this portion:

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

so that JSON was DIST and a value of 0 at least started to appear (whereas previously it was Unknown, but that’s also clearly not correct since MQTT Explorer is able to show me that values are being discovered / recorded (around 298 - 300). Is this an aspect I need to edit / alter as well?

Screen Shot 2021-04-07 at 21.59.10

Took a tip from above and commented out the line value_template: "{{ value_json.DIST }}". Fixed everything!

Glad you got it working!

1 Like

I’ve been following everything as described here but still can’t seem to be able to get the info to show correctly.

I’m able to see under the supervisor-mosquitto-logs my instance of the OpenGarage device is connected.

Then in my config.yaml file i have this:

cover:
  - platform: mqtt
    name: "mygdo"
    state_topic: "mygdo/OUT/STATE"
    command_topic: "mygdo/IN/STATE"
    retain: false
    payload_open: "on"
    payload_close: "on"
    payload_stop: "on"
    state_open: "open"
    state_closed: "closed"
    device_class: "garage"


sensor:
  - platform: template
    sensors:
      mygdo_status:
        friendly_name: "Garage Door Status"
        value_template: '{{ states.cover.mygdo.state }}'

However, cover.mygdo and sensor.mygdo_status show as greyed-out or “unknown”.

Using MQTT Explorer this is what I see (which seems to indicate that things are configured correctly?):
mygdo

CLOSED vs Closed?

Wow that was exactly it … Wild goose chase for that …

For my edification, why does the all caps work but not the lower case? Is that a product of how the opengarage coding functions specifically?

I’m having trouble understanding how the mqtt cover device works, but the up, down, stop buttons on the cover entity are payload_open, close and stop? Is it possible to send a payload command as a tap_action?

For example, if I am displaying the status of the garage door as a glance card, is it possible to use a tap_action to send the “up” command?