Hey everyone!
I’d like to share my project to setup a fully automated garage door opening and closing system with no voice commands, no remotes/fobs and no buttons to press whether they are through proprietary app, HA app, car interface or otherwise. I envisioned the system as
- When leaving home in your car, just start the car and the garage door should open.
- As you drive off, the garage door should close up behind you.
- When you arrive back home, and drive up to your garage door, it should automatically open.
- Once you have parked and switched the car off, it should automatically close.
Interested? Please keep reading! This is a quick guide for those who are familiar with Home Assistant. For the more complete version, check out my full post on my blog.
Prerequisites
Before you start you will need to have set up a few things:
-
Your garage must be in range of WiFi.
-
You’ll need a Home Assistant compatible smart garage controller that works with your garage door opener. In my case that was a Refoss Smart Garage Door Opener for my Chamberlain Liftmaster Garage Door Motor. Any controller will do as long as it can control the garage door and detect its open/closed state.
-
Lastly, you’ll need the WiCAN device made by MeatPi Electronics. WiCAN is an OBD-II WiFi and Bluetooth–enabled ESP32 adapter. It connects via the OBD-II port (compatible with virtually any car after 1996). Check the details about this device and others in their repo: GitHub - meatpiHQ/wican-fw. This device is very cool and can expose all sorts of cool information about your car to Home Assistant, both via just scraping the web page or via MQTT.
In this guide, we will use its ability to report your car’s battery voltage. Why voltage? Because in most standard ICE cars, when the engine is on, so is the alternator
that is charging your battery usually at around 13.5V-14.2V but when the car is off, the battery is usually hovering between 12V to 12.8V and we can use that to tell Home Assistant whether your car’s engine is on and running and when its off.
WiCAN Setup
Step 1:
Find your car’s OBD-II port and plug in the WiCAN device. Once plugged in, it should automatically be in Access Point (AP) mode with an SSID like WiCAN_xxxxxxxxxxxx and a default password like @meatpi#.
Step 2:
Connect to the AP and go to IP Address 192.168.80.1 in your browser. If needed, refer to the official guide.
On the Settings tab under AP Config, switch the mode from AP to AP+Station. Enter your WiFi settings under the Station Config section and save changes to let the device reset, and connect to your WiFi network.
Step 3:
Now that the WiCAN device is connected to your network, set a static IP for it on your router. We will need this later on in the guide.
Home Assistant Setup
Step 1:
Add the device to Home Assistant via the Ping (ICMP) Integration. The steps are Integrations > Add Integration > Ping (ICMP). Enter the static IP of the WiCAN device,
press submit and once the device is showing on the integration page, go to configuration. Set the Consider Home Interval to 1 (so Home Assistant marks the device as not home one second after disconnection).
Step 2:
Next, lets configure a REST sensor so we can poll the WiCAN device for current battery voltage. Add the following to your configuration.yaml and replace the values in square brackets .
sensor:
- platform: rest
resource: http://[WiCAN-Static-IP]/check_status
verify_ssl: false
timeout: 3
scan_interval: 1
name: [Sensor Name]
unique_id: [Unique Sensor ID]
value_template: >
{{ value_json.batt_voltage | regex_replace(find='[^\d.]', replace='') | float }}
state_class: measurement
device_class: voltage
unit_of_measurement: "V"
Step 3: Garage Door Open Automation
We now have all we need to create the Garage Door Opening Automation. Home Assistant polls the car battery voltage every second. If the voltage is above a set threshold
(say 13V) for a certain duration (say 3 seconds), and the door is currently closed, it will open the garage door. I also recommend setting the automation to single mode and adding a delay so the automation does not erratically trigger once it has already done so. It should end up looking something like the following:
Trigger: Numeric State of [Sensor Name] above 13 for 3 seconds
Condition: Garage Door is Currently Closed
Action 1: Open Garage Door
Action 2: Delay
Step 4: Setup for Garage Door Close
An important challenge we need to resolve before we can make our closing automations is to ensure that we can use the garage door like normal.
If we directly triggered the closing of the garage door when the car voltage is below out threshold
level, then any time you open the door to take the trash out, or the WiCAN experiences a temporary disconnection, the door will unexpectedly close on you. We only want the automation to trigger when the car was recently running.
Home Assistant’s history_stats platform allows us to do exactly this. Add the following into your configuration.yaml
under sensors
:
- platform: history_stats
name: "Count of Voltage Above 13"
entity_id: [Historical Unique Sensor ID]
state:
- "13.1"
- "13.2"
- "13.3"
- "13.4"
- "13.5"
- "13.6"
- "13.7"
- "13.8"
- "13.9"
- "14.0"
- "14.1"
- "14.2"
- "14.3"
type: count
start: "{{ now() - timedelta(minutes=1) }}"
end: "{{ now() }}"
If the count of this sensor is above 0, it means the car has been on at some point within the last 1 minute.
Step 5: Garage Door Close On Leaving Home
Next, we can create the automation to close the garage door as you leave your house and the WiCAN device connected to your device leaves your local network. Once again, ensure the automation runs in single mode and add a delay.The automation should look something like this:
Trigger: WiCAN device disconnects
Condition: Garage Door is Currently Open & [Historical Unique Sensor ID] value > 0
Action 1: Close Garage Door
Action 2: Delay
Step 6: Garage Door Close After Arriving Home
The last automation left to create is the one that will close the garage door once you have arrived, the garage door has opened, you have parked your car in the garage
and have now shut it off. This automation will also run in single mode and will have a delay to make sure we can only trigger it once in a set duration. The automation
should look like:
Trigger: Numeric State of [Sensor Name] below 13 for 3 seconds
Condition: Garage Door is Currently Open & [Historical Unique Sensor ID] value > 0
Action 1: Close Garage Door
Action 2: Delay
And that should be it! Go ahead and give it a try and see how well this works for you! For a detailed discussion about testing considerations and the parameters I have used in this guide, be sure to check out my full post on my blog.