GarHAge - a Home-Automation-friendly ESP8266-based MQTT Garage Door Controller

I’ve written an MQTT garage door controller that integrates pretty seamlessly with Home Assistant, and can control two garage door openers using one ESP8266.

It’s called GarHAge, and you can read more about it (including full build and configuration instructions) here: https://github.com/marthoc/GarHAge.

The latest release is v1.2.0, which you can download from the GitHub releases page here: https://github.com/marthoc/GarHAge/releases.

I’d appreciate any feedback and bug reports!

12 Likes

Nice! I don’t actually have a motor for my garage door yet, it’s an up and over. What types of motor should I look for? Thanks

GarHAge should work with most if not all openers - all it needs is for a opener to be able to operate via the connection of two terminals on the opener, which the pushbutton for the door mounted in the garage will also connect to.

1 Like

This is great, will be using this one a few doors, i am using this code without the relay.

I had been doing this with a PI running another instance of HA for quite a while, and had planned on switching it out for a ESP8266. Your code pushed me over the edge :slight_smile: One thing I’d like to poke at in your instructions…

GarHAge will only work with relay modules that are active-high (meaning that the relay is triggered by a HIGH output from a GPIO pin). Note that many modules available on Amazon, eBay, or AliExpress are active-low, which is not supported by GarHAge.

I have a couple Sainsmart relays boards from amazon that I was using with the PI. of course, when I set everything up as soon as I plugged the NodeMCU in, the garage door triggered. I went into the code you provided and just changed the setup() method to write LOW to the open/close pins. My question - was this a limitation that you had just written in, or is this actually something I should not be doing? I’m a programmer with some electronics knowledge, but just enough to be dangerous :slight_smile:

I think I have two problems with active-low relays.

The first is that the way the Sainsmart relay boards are designed, your GPIO pin actually ends up sinking 5v when the relay is triggered into a pin designed only for 3.3v, if you use the basic wiring method and don’t use a protection circuit. This may be only momentary voltage, but could in theory damage the board.

Second, I also couldn’t be sure what would happen when the board lost power and rebooted - would the outputs be low for a split second after powerup, until the setup() function ran, thus triggering your door to open? An active-high relay board gets around this by only triggering the relay when receiving a high output, so even if the esp8266 is floating in a not-high state after startup, your doors aren’t going to be triggered to open.

Thanks for using and thanks for the comment. I don’t think I’m going to support the active-low relays since I want the project to be easy to set up and not have to incorporate more circuitry, and because I feel with the active-high board I can more reliably predict what the code is going to do on startup.

Just wanted to announce that I’ve released GarHAge v1.1.0 - its available at the GitHub releases page: https://github.com/marthoc/GarHAge/releases.

Added several automation examples to the README.md, including iOS actionable notifications.

1 Like

Just want to point out that if you are going to use the code with an active-low relay, you’ll need to change both the setup() and toggleRelay() functions.

In setup, change:

  pinMode(door1_openPin, OUTPUT);
  digitalWrite(door1_openPin, LOW);

  pinMode(door1_closePin, OUTPUT);
  digitalWrite(door1_closePin, LOW);
  
  pinMode(door1_statusPin, INPUT_PULLUP);
  door1_lastStatusValue = digitalRead(door1_statusPin);

  if (door2_enabled) {
    pinMode(door2_openPin, OUTPUT);
    digitalWrite(door2_openPin, LOW);

    pinMode(door2_closePin, OUTPUT);
    digitalWrite(door2_closePin, LOW);

    pinMode(door2_statusPin, INPUT_PULLUP);
    door2_lastStatusValue = digitalRead(door2_statusPin);
  }

To:

  pinMode(door1_openPin, OUTPUT);
  digitalWrite(door1_openPin, HIGH);

  pinMode(door1_closePin, OUTPUT);
  digitalWrite(door1_closePin, HIGH);
  
  pinMode(door1_statusPin, INPUT_PULLUP);
  door1_lastStatusValue = digitalRead(door1_statusPin);

  if (door2_enabled) {
    pinMode(door2_openPin, OUTPUT);
    digitalWrite(door2_openPin, HIGH);

    pinMode(door2_closePin, OUTPUT);
    digitalWrite(door2_closePin, HIGH);

    pinMode(door2_statusPin, INPUT_PULLUP);
    door2_lastStatusValue = digitalRead(door2_statusPin);
  } 

And change toggleRelay() from:

void toggleRelay(int pin) {
  digitalWrite(pin, LOW);
  delay(relayActiveTime);
  digitalWrite(pin, HIGH);
}

To:

void toggleRelay(int pin) {
  digitalWrite(pin, LOW);
  delay(relayActiveTime);
  digitalWrite(pin, HIGH);
}

I think that should do it, but I haven’t really thought through the implications. Do let me know how it works, I may decide to implement this after all with a simple schematic if people want to do active-low. I know the Sainsmarts are popular.

Thanks! I did actually get both functions changed, just missed that in my post to you :slight_smile: I’ve had no ill-affect using the active-low settings, even when power is disconnected/reconnected. I’ll keep you informed.

After @mconway’s results, I’ve just released v1.2.0 to add support for active-low relay modules. I would appreciate any feedback or bug reports on the feature if you are using one of these modules, since I do not have an active-low module to test myself.

Grab the latest release at: https://github.com/marthoc/GarHAge/releases.

1 Like

@marthocoo Thanks! I haven’t downloaded the latest release yet, but just an update - I haven’t had any issues that I can tell with the voltage. The only issue I have run into was the MQTT service on my pi died, and I had pulled the garage door controller apart thinking it was that, then hooked ip p wrong when I put it back together :slight_smile: Either way, just tested it again 2 mins ago, and still running strong.

I’m going to be printing an enclosure for it soon, and once I get a little time I may play with a slightly different wiring diagram for circuit protection. Stay tuned!

thanks, will give this a go, already tried open garage, but your build also looks interesting. Will let you know once my magnetic switches arrive from CN.

Just as a quick FYI. I put this whole project together with the great information from your GH page in 30 minutes! It works flawlessly, and really appreciate how detailed everything was! So easy to implement and integrate with HASS.

Thanks so much!

Nice project!

Has anyone suceeded in changing the icons from the generic cover to a garage door?

17 PM

There is a mdi icon for garage that is much clearer than the generic cover 26 PM

but I can’t seem to get Hassio to take the customization.

Thanks!

This should be part of GarHAge’s documentation. I just realized it’s not. In customize: (under homeassistant: at the top of configuration.yaml) add an entry for your garage door, and add device_class: garage to it, like so:

homeassistant:
  ...
  [misc Home Assistant options]
  ...
  customize:
    cover.garage_door:
      device_class: garage

Doing this will get you a dynamic garage icon that shows open when open and closed when closed! Try it and let me know if it works.

1 Like

No luck:

  customize:  
    cover.garage_door_prius:
      device_class: garage
    cover.garage_door_audi:
      device_class: garage

still gets me

15 PM

You have to 1) reload your core config or restart home assistant and 2) change the state of the device once in order for customizations to take effect. Try that and let me know!

I have restarted HA a number of times, without any success. actuating door didn’t flip it either.

Just out of interest if you visit HASS with a different interface (ie if you are using the app use a browser) does it still show the generic cover icon? Maybe a caching issue is all I’m thinking? I double checked my own config and it looks exactly as yours and I have the garage icons.

It’s really stubborn! I’ve tried 3 different browsers (4 if you count iOS), and flushed cache as well. I’ve not had a problem changing the icon’s with other platforms.