WiFi/MQTT car presence sensor for garage door automation

Thanks for sharing! My hardware came in yesterday and I had it up and running with ease, thanks to your easy to follow guide

1 Like

I’m curious about your setup.

I am running two UNIFI aps at home and I realize it takes almost 10 minutes for the mqtt state to change once I come home. I really think its the Wemo taking that long to connect to the AP once within range.

If i power cycle them when home they connect almost instantly.

@rabittn For me, giving the wemo a static ip in my dhcp server made a big difference. Now it’s a matter of seconds

Thank you, that helped tremendously.

why add and other wemos with sonar or ir to check if the car is in the garage.

Maybe FIND might work to get positioning info of the ESP8266 in your car?

I was having problems with delays , it would take up to 30 seconds for the garage door to open , once the car was started. And closing ( driving away) could take up to 3 mins.

I think it all to do with the timing to connect to the wifi and MQTT server. The Wifi router is only about 6m away from the car when it is in the garage and one single brick wall. Therefore it must be the delay in the connections etc …

So …
now Android Auto supports full Google Assistant. I have linked IFTTT to google assistant on my phone ,

So while driving in the car, towards the garage, with Android auto hooked up … i say
“ok google " " open garage”
Via IFTTT a webhook is called using the API service for MQTT exposed by HA to publish a simple Json call …
{“topic”:“devices/Garage/switch/on/set”,“payload”:“Yes”}

Garage Door opens.

Also the same for Close Garage, when i’m driving down the street away from the house

Note:
Web hook url : http://YOUR.INTERNAL.IPADRESS:8123/api/services/mqtt/publish?api_password=XX

This means i have remove the unit from the car now !!

my d1 mini has the static ip and my action is activated immediately when the d1 mini starts to blink, but it takes 4 to 10 seconds to boot and blink. Not a fixed amount of time. Is it normal? A sonoff basic boots in a fraction of time and it should be the same chip.

I honestly don’t know how fast the D1 should boot up and connect, mine typically take about 4 sec as well

ok, thanks :slight_smile: just curious to have a “benchmark” because I will be probably faster opening the gate/garage with the old fashioned remote :smile:

I just went with the mini pro and the on board antenna. It works fine as there is an AP nice and close in the garage.

I don’t have an electric door, and I don’t use the garage in any case, the idea is to get a philips hue bulb external light to come on as the car approaches. Likewise, when the car is unlocked the light will come on.

I use an automation which checks the device uptime to establish if the car is leaving or if it has arrived home.

Thanks for the write up.

1 Like

Hi. I already flash this project on a D1 mini pro 10x, change the library to 512 and see that he connect to mqtt but not create a sensor in home assistant. Anyone can give a tip?

Make sure you have home assistant discovery enabled.

Hi have enable and dont apear. Can anyone share the arduindo folder with the configs right for test …please

Hi leeb98, you can also use routines to do the same thing. That’s what I use.

I’m stuck getting this to work… I suspect the issue is somewhere in HA. More info here on what I’ve tried and figured out.

Any help greatly appreciated.

Link no longer active as deleted github comment. Problem now solved.

Did you test if work on a d1 that is not the pro?

I don’t think that’s the issue. I’m pretty sure I’ve narrowed it down to the ‘binary_sensor.carpresence’ state not being changed. If I use the MQTT topic homeassistant/binary_sensor/CarPresence/state then the garage door opens but if I use the binary_sensor.state as the trigger for the automation it doesn’t work. I have only just noticed but if I check states under the States developer tab it does get updated from OFF to ON and from ON to OFF if I power cycle the WEMOS so it is definitely my automation…

- id: '1547437025394'
  alias: Car Present Open Garage
  trigger:
  - entity_id: binary_sensor.carpresence
platform: state
to: 'on' # Not 'ON'
  condition: []
  action:
  - data:
  entity_id: cover.garage_door
service: cover.open_cover
- id: '1547437233729'
  alias: Car Not Present Garage Close
  trigger:
  - entity_id: binary_sensor.carpresence
for: 00:01:00
platform: state
to: 'off'  # Not 'OFF'
  condition: []
  action:
  - data:
  entity_id: cover.garage_door
service: cover.close_cover

EDIT: Got it to work… changed ‘ON’ to ‘on’ and ‘OFF’ to ‘off’ in automation and success! :grinning:

1 Like

So what if your car is not parked inside the garage but outside on the driveway?

  • Car is powered off, garage door is closed.
  • Car turns on, device publishes connection message to MQTT
  • Home automation platform sees that the garage door is closed and the device is connected, then sends command to open garage
  • You sit in the car, staring at the needlessly open garage door. You drive away wondering how to improve the door’s open/close logic.
  • Device eventually drives out of range, MQTT broker sends disconnection message configured as the LWT

Similarly, when arriving home, I sometimes park on the driveway, not in the garage. Naturally this system can’t predict my preference so it’ll open the garage door (needlessly).

One other thing, for safety reasons, I never ever start my car before opening the garage door. As a result, I’d either have to change this (safe) habit, in order to use this system, or just press the remote-control button (within the car) as I’ve done for many years.

Lastly, automatically closing an unattended garage door is a potential safety hazard. Some form of warning should be issued to advise anyone standing near the door.

I installed a speaker in the garage. A warning message announces the door will be closed in ten seconds. This is part of an auto-closing system that operates if I drive away and forget to close the garage door. After 5 minutes it announces the impending closure then, 10 seconds later, closes the door and then reports (via SMS) its actions. If it fails to close, it sends an SMS reporting the failure.

Each to his own, I say.

As with all automation, it should agree with your normal routines and behaviours. My wife drives the car straight into the garage and closes the door, every time. I park outside on the driveway so I won’t be using this, but for her with two young children (usually screaming!) this is perfect.

I don’t know what your garage door is like but mine is very slow and makes a fair amount of noise as it descends. If you are standing underneath the door when it starts you won’t have any trouble knowing it’s moving or getting out of its way. It’s also has no wall on one side (so more like a carport) so there is no problem with starting the engine in the garage. In any case turning the key one position turns on the power to peripherals not to the engine.

You could always use an ultrasound sensor as I’ve seen in some other projects to confirm the presence of the car in the garage like this one. This example gives more conditions that must be met in order for the door to open / close but I like the simplicity of luma’s project. The linked project also has a parking assistant to let you know when you are getting too near to the wall. This might be the next iteration for me (in a few years!). :slightly_smiling_face:

1 Like