Automatically open the garage door on my (car's) arrival

Here’s a solution I’ve recently built so that when I come home in my car, the garage door would automatically open.

  • Added a wifi AP near the driveway. This was originally meant to boost wifi signal for my lawn mowing robot, but helps for the auto garage opening too
  • connected an esp32 supermini (these things are very cheap, only around $2 each!) into my car’s USB port. The USB ports only power on when the car is turned on / engine running. I programmed it with esphome. Its task is very simple: on mqtt connection, send its current uptime. That’s all!
  • Added a rule in openhab to receive the mqtt uptime sent above, and open the garage door if all these conditions are true:
    • uptime > 15 minutes
    • garage door is closed
    • car esp32 Thing is online (optional) - I have payloadAvailable using mqtt LWT on all my mqtt Things.
    • the garage door state lastStateChange was older than 5 minutes ago (prevent rapid closing / opening) - this means if someone at home recently opened the door then closed it, it won’t open for me. I’m not sure if this is a good idea - subject to further tweaking. Maybe I could reduce this to 30 seconds or less.

So now as soon as I pull into my driveway, the garage door opens up automatically.

It means if I happened to park in the driveway, turning the car on wouldn’t open the garage door - the esp32 would connect to mqtt and sends a low uptime (less than 15 minutes). I would need to start the car somewhere 15 minutes away for this scheme to work.

I could further add some encrypted handshake in the mqtt messaging but I feel that it’s unnecessary.


The implementation is very easy that you would probably do this using your own way, but here’s mine:

esp32 esphome config:

substitutions:
  device_name: car
  friendly_name: "Car Garage Opener"

esp32:
  board: esp32-c3-devkitm-1
  framework:
    type: esp-idf

packages:
  # contains common basic esphome setup, wifi ssid, mqtt connection details, etc.
  common: !include common/common.yaml

wifi:
  # don't keep rebooting, that'd slow down the reconnection. Just keep retrying
  reboot_timeout: 0s
  power_save_mode: none
  on_disconnect:
    then:
      - light.turn_off: statusled

  on_connect:
    then:
      - light.turn_on: statusled

mqtt:
  on_connect:
    then:
      - delay: 1s # this may not be necessary
      - mqtt.publish:
          topic: ${device_name}/THIS_TOPIC_WILL_TRIGGER_YOUR_RULE
          payload: !lambda 'return to_string(static_cast<int>(id(uptime_sensor).state));'

light:
  - platform: status_led
    name: Status LED
    id: statusled
    pin:
      number: GPIO8
      inverted: true

sensor:
  - platform: uptime
    name: Uptime
    id: uptime_sensor

The openhab rule (jruby)

rule "Car offline" do
  changed "mqtt:topic:car", to: :offline
  run do |event|
    Car_Wifi_Connected.update nil
  end
end

rule "Car arrived" do
  changed Car_Wifi_Connected, to: (15.minutes.to_i..)
  only_if { Car_Wifi_Connected.thing.online? }
  only_if { Garage_Door.closed? }
  only_if { Garage_Door.last_state_change.nil? || Garage_Door.last_state_change < 5.minutes.ago }
  run do |event|
    logger.info "Car arrived, online for #{event.state} seconds"
    Garage_Door_Press.on # or however you would open your garage door
    Voice.say "Car arrived, opening the garage door automatically" if Alarm_Armed.off?
  end
end
7 Likes

I like this fancy automation, but option for manual button on esp can be considered,in case it fudges.

I have similar idea for light on driveway tha it would turn on only when someone is at the door or car pulls in.

That can be easily added. For me, it’s a lot easier to reach for my actual garage remote control than finding the esp32 which I keep inside the centre console, and currently it’s just a bare esp32 supermini pcb. I haven’t made a case for it yet.

For me this is currently done using ipcamera → Frigate → Detect car → turn on external lights and alert us inside the house that a car (any car) just pulled into the driveway

Previously I was also toying with using ipcam LPR to detect my car and open the garage door but it wasn’t very reliable, plus it can easily be spoofed.

I found a very nice case for the esp32 supermini:

https://makerworld.com/en/models/1072508-esp32-c3-supermini-snap-fit-case-5-options

Amazing, i played a bit with frigate a year ago, sounds promising that you have it functioning.

Do you have any recomendation for configuring frigate for this detection, i do use mqtt so that part is easy then

It’s very easy that I don’t even know what to say about it.

The Frigate configuration is something like:

objects:
  track:
    - person
    - car

You can tweak it further, like minimum size to be considered - this depends on your camera distance, resolution etc. You can tweak it in frigate’s GUI I think. Define detection area (e.g. only detect the car if it’s close to your house, and ignore them if they’re in the main road), etc.

Frigate would then send an mqtt message on the topic frigate/<camera or zone id>/car with the number of cars it detected in that zone.

I have considered that some time ago. Maybe could be better to put some “BT tag” on the car, or the keys or using phone BT, and put the Esp32 near de door so the Esp32 detect that BT item aproaching and open it.

But, I think that it could be counterproductive, because it can open the door in a undesirable moment (dogs, persons, cars…), and also you have to detect that you are or not actually inside (arriving, leaving, etc…).

I prefer controlling “manually” the open, but, it is easy with Alexa, my actually car has builtin Alexa, and also my Smartwatch, so it is very easy to give voice command to Alexa to open the door. I prefer that that open automatically.

Ruben

I am a bit paranoid and do not give garage control to alexa / google assistant. I know we can add a pin to it but then it becomes cumbersome.

You could combine the two and only let Alexa open the door when the car is in range and running.

This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.