This project utilizes a WeMos D1 mini Pro, u.FL to SMA antenna whip, and an external antenna in a 3D-printed enclosure to indicate presense when powered on and attached to MQTT.
The included Arduino code is setup to work with Home Assistant MQTT Discovery to automatically create a binary_sensor
device which will indicate the connection status of the device. The device should be powered from your car's ignition so it's only on when the car is running. When the device powers on, it will attempt to connect to the defined MQTT broker, publishes a discovery message, and configures a Last Will and Testament. When the device is powered off (or you drive out of WiFi range), the Last Will and Testament is sent by your broker to update subscribed automation system(s).
The included Home Assistant blueprint automation example utilizes this information to open or close a connected garage door. Just copy the file url into the blueprint import menu and create an automation using the blueprint!
The first order of business will be to setup the Arduino IDE to flash the provided Arduino sketch to the ESP8266. Download the IDE for your platform and follow these instructions to add support for the ESP8266 platform.
Next you will need to add the PubSubClient library for MQTT. Follow this guide for the general process and add the 'PubSubClient' from the Library Manager.
At the top of the Arduino sketch are several fields you must modify to fit your environment (WiFi details, MQTT broker IP, node name, etc). Once those fields have been set you can upload to your microcontroller and monitor sensor status in Home Assistant.
WARNING:
If you will be deploying more than one of these devices you must change the node names to be unique. Failure to do so will result in a cascading series of MQTT connections/disconnections as your devices compete for access to your broker.
In order to utilize an external antenna on the WeMos D1 Mini Pro, you will need to move a 0 ohm 0603 SMT resistor. See this blog post along with an accompanying video on how to make that happen. A hot-air station will make this easier, but I was able to do this with a normal pencil iron.
If you are more familiar to Tasmota flashing and usage rather than Arduino Programming and building, this is another variant that you could use. It will replace the Arduino Programming section above, but follows the guidelines of just about everything else. The blueprint that is attached to this project named MQTT_Tasmota_CarPresence.yaml can be used as an alternate along with flashing the Di-Mini with Tasmota to accomplish the same thing as the original.
This Tasmota Variant is set-up to work with Home Assistant Tasmota Integration to automatically create a switch
which will indicate the connection status of the Car Presence Device. It should show up as a switch with a name that matches the FriendlyName set-up in the Tasmota Web Console.
generic(18)
.Backlog SO19 0; SO56 1; SO63 1; SO65 1; WifiConfig 5
MQTT_Tasmota_CarPresence.yaml
similar to the instructions for the other blueprint above.This project is powered by coffee. I might get a little weird about it at times, but it's not much of a stretch to suggest that coffee both powers and consumes a fair portion of my mental energy. Hook me up if you think HASP is cool. Thanks!