Harnessing the power of open-source tools to monitor your vehicle’s data within your smart home ecosystem is now easier than ever. This guide will walk you through integrating OBD2 data into Home Assistant using WiCAN, an open-source Controller Area Network (CAN bus) interface, and MQTT. By leveraging Node-RED, you can create custom automations based on real-time vehicle diagnostics and performance metrics.
The following steps outline how to seamlessly connect your WiCAN device to Home Assistant, enabling you to visualize and react to your car’s data directly within your smart home dashboard.
-
Mosquitto Broker Installation: Begin by installing the Mosquitto broker add-on in your Home Assistant instance. This MQTT broker will serve as the communication backbone for transmitting data from WiCAN to Home Assistant. You can find the Mosquitto broker add-on within the Home Assistant add-on store.
-
Create a Dedicated Home Assistant User: For enhanced security, create a new, dedicated user account within Home Assistant specifically for WiCAN. These credentials will be used to configure the MQTT settings on your WiCAN device, ensuring secure data transmission.
-
Connect to WiCAN Access Point: Power up your WiCAN device and connect to its designated access point, typically named
WiCAN_xxxxxxxxxxxx
. Once connected, access the WiCAN web interface by navigating tohttp://192.168.80.1/
in your web browser. -
Configure WiCAN Mode and Wi-Fi: Within the WiCAN web interface, set the “Mode” to “Ap+Station”. Then, input your home Wi-Fi network’s SSID and password. This step allows WiCAN to connect to your local network while also providing its access point for initial configuration.
-
Enable and Configure MQTT: Enable the MQTT protocol within the WiCAN settings. Enter the Home Assistant user credentials you created in step 2. These credentials will authenticate WiCAN with your MQTT broker, allowing data to be published.
-
Install Node-RED Add-on: Install the Node-RED add-on in Home Assistant. Node-RED provides a visual flow-based programming environment that simplifies the creation of automations based on MQTT data.
-
Import Example Node-RED Flow: Download the
wican_example_flow.json
file from the WiCAN GitHub repository. Before importing, edit this file and replace thedevice_id
placeholder with your specific WiCAN device ID. -
Import Flow into Node-RED: Open the Node-RED add-on in Home Assistant and import the edited
wican_example_flow.json
file. This flow contains pre-configured nodes for subscribing to WiCAN’s MQTT topics and processing CAN bus data. -
Configure MQTT Broker in Node-RED: Double-click the “subscrition” Node within the imported flow. Configure the server settings with your MQTT broker’s IP address (typically your Home Assistant IP) and the user credentials created in step 2. Deploy the flow after configuration.
-
Define MQTT Sensors in
configuration.yaml
: To display OBD2 data as sensors in Home Assistant, you need to define them in yourconfiguration.yaml
file. Add MQTT sensor definitions, specifying thestate_topic
to match the MQTT topics published by WiCAN (e.g., “CAR1/Amb_Temp”). Adjustunit_of_measurement
andvalue_template
accordingly to parse the JSON data.
mqtt:
sensor:
- name: "Amb Temp"
state_topic: "CAR1/Amb_Temp"
unit_of_measurement: "C"
value_template: "{{ value_json.amb_temp }}"
- name: "Fuel Level"
state_topic: "CAR1/Fuel_Level"
unit_of_measurement: "%"
value_template: "{{ value_json.fuel_level }}"
-
Restart Home Assistant: Restart your Home Assistant instance to apply the changes made to the
configuration.yaml
file. -
Add Sensors to Dashboard: After restarting, navigate to your Home Assistant dashboard and add new entity cards. Your newly defined MQTT sensors, such as “Amb Temp” and “Fuel Level,” should now be available to add to your dashboard, displaying real-time OBD2 data streamed from your vehicle via the open-source WiCAN interface.