diff --git a/README.md b/README.md index 64daccc..5444c8c 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,8 @@ --- ## MeatPi [Discord server](https://discord.com/invite/2hpHVDmyfw) ## Please update to the [latest firmware version](https://github.com/meatpiHQ/wican-fw/releases/) +--- +# [Official Docs](https://meatpihq.github.io/wican-fw/) ## Order on [**Mouser**](https://www.mouser.com/c/?m=MeatPi) or [**Crowd Supply!**](https://www.crowdsupply.com/meatpi-electronics) @@ -65,8 +67,6 @@ - [OBDII PID Request Over MQTT](#5-obdii-pid-request-over-mqtt) - [Request Battery SoC MQTT Example](#6-request-battery-soc-mqtt-example) - [CAN to JSON interpreter - Filtring](#7-can-to-json-interpreter---filtring) -- [Home Assistant](#home-assistant) - - [Firmware Update](#firmware-update) - [OTA](#1-ota) - [USB Flash](#2-usb-flash) @@ -443,102 +443,6 @@ Custom ID|355| 170| 170| 170| 170|_5_| _34_| 170| 170 The PID in the configuration should be set to -1. The values to extract are from Byte 4 and Byte 5. The formula used here is (5 + 34)/2, so the expression to set is (B4 + B5)/2. -# Home Assistant - -WiCAN seamlessly integrates with Home Assistant via the MQTT protocol, automatically retrieving vehicle data and publishing it. Sensors are created in Home Assistant without any manual intervention, making setup effortless. - -**Note:** The [WiCAN PRO](https://www.crowdsupply.com/meatpi-electronics/wican-pro) model supports more car models. - -image - -### Getting Started Guide - -1. **Install the Home Assistant [Mosquitto broker add-on](https://github.com/home-assistant/addons/blob/master/mosquitto/DOCS.md).** - -2. **Create a new Home Assistant user account for WiCAN.** - The credentials for this account will be used to configure the MQTT settings in WiCAN. - -3. **Connect to the WiCAN access point** (WiCAN_xxxxxxxxxxxx). - Open a web browser and navigate to [http://192.168.80.1/](http://192.168.80.1/). - -4. **Set the "Mode" to AP+Station.** - -5. **Enter your home WiFi network SSID and password.** - -6. **Set the Protocol** to Autopid - -7. **Enable [MQTT](#mqtt)** and enter the Home Assistant credentials created in step 2. - -8. **Go to the "Automate" tab and enable "Vehicle Specific".** - -9. **Select your vehicle model from the dropdown list.** - If the list is empty, download the latest [vehicle profiles file](https://github.com/meatpiHQ/wican-fw/blob/main/vehicle_profiles.json) and upload it using the "Choose File" button. - -10. **If your vehicle isn't supported,** open an issue on GitHub, and I’ll assist you in creating a new vehicle profile if possible. - -11. **Enable "Home Assistant Discovery".** - This will automatically create sensors in Home Assistant. - -12. **Fill in the "Destination Topic" and "Cycle Time".** - - **Destination Topic:** The MQTT topic where WiCAN will publish the vehicle data. - - **Cycle Time:** Defines how frequently WiCAN will pull and publish the vehicle parameters to Home Assistant. - -13. **Press the "Store" button and reboot the device** for the changes to take effect. - ---- - -### ---Deprecated method--- -### 1. EV Battery Examples [Wiki Page](https://github.com/meatpiHQ/wican-fw/wiki/EV-Battery-SoC-in-Home-Assistant-%E2%80%90-Example) -In this example, we will learn how to set up Home Assistant to request the battery State of Charge (SoC) without using Node-RED. This example has been tested on an ORA Funky Cat vehicle and can also serve as a reference for requesting other Parameter IDs (PIDs) in addition to SoC. EV Battery Examples [Wiki Page](https://github.com/meatpiHQ/wican-fw/wiki/EV-Battery-SoC-in-Home-Assistant-%E2%80%90-Example) - -### 2. Node-RED Example - -WiCAN is able to send CAN bus messages to Home Assistant using MQTT protocol. I found that using Node-RED is the simplest way to create automation based on the CAN messages received. This short video highlights some of the steps https://youtu.be/oR5HQIUPR9I - -1. Install Home Assistant [Mosquitto broker add-on](https://github.com/home-assistant/addons/blob/master/mosquitto/DOCS.md) -2. Create Home Assistant new user account for WiCAN. These user credentials will be used to set up the MQTT setting for WiCAN. -3. Connect to WiCAN access point WiCAN_xxxxxxxxxxxx then, using a web browser, go to http://192.168.80.1/ -4. Set the "Mode" to Ap+Station -5. Fill in your Home WiFi network SSID and Password. -6. Enable [MQTT](#mqtt) and fill in the Home Assistant credentials created in step 2 -7. Install Home Assistant [Node-RED Add-on](https://github.com/hassio-addons/addon-node-red) -8. Download [wican_example_flow.json](https://github.com/meatpiHQ/wican-fw/blob/main/ha/wican_example_flow.json) and replace **device_id** with your WiCAN ID. -9. Open Node-RED Add-on and import the edited "wican_example_flow.json" -10. Double click on the subsction Node and edit the server fill in MQTT broker IP address and credentials created in step 2 -11. Click deploy. -12. To create a new MQTT sensor, you’ll need to edit the configuration.yaml file by adding the following lines: - -``` -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 }}" -``` -11. Restart Home assistant -12. After restart go to dashboard and Add new Card entity. - -## Workflow summery - -In this example we've got one Node subscribed to topic ``` wican/device_id/status ```, when WiCAN connects to the local network it will publish ``` {"status": "online"} ```. Once the Node function ``` Send Get Amb Temp req ``` receives online status it will send a OBD2 request to get the ambient temperature. The OBD2 request message looks like this: - -``` { "bus": "0", "type": "tx", "frame": [{ "id": 2015, "dlc": 8, "rtr": false, "extd": false, "data": [2, 1, 70, 170, 170, 170, 170, 170] }] } ``` - -Frame ID : 2015 or 0x7DF -PID: 70 or 0x46 - -Here is a good [reference](https://www.csselectronics.com/pages/obd2-pid-table-on-board-diagnostics-j1979) on how to construct a PID request. Note select DEC from drop down list. - -We have another Node subscribed to topic ``` wican/device_id/can/rx ```, once the car ECU responds to the request the function ``` Parse Amb Temp RSP ``` will parse the message and publish a message to topic ``` CAR1/Amb_Temp ```. Notice that when you edited ``` configuration.yaml ``` file create an MQTT Entity that subscribes to ``` CAR1/Amb_Temp ``` and expects a message ``` { value_json.amb_temp } ``` with unit_of_measurement C. - -![image](https://user-images.githubusercontent.com/94690098/204269457-32f6e6b5-c9be-44d0-b41c-36fa61b82258.png) - - # Firmware Update ## 1. OTA: diff --git a/docs/content/0.index.md b/docs/content/0.index.md index 1c30548..959699a 100644 --- a/docs/content/0.index.md +++ b/docs/content/0.index.md @@ -5,4 +5,6 @@ navigation: false Welcome to the WiCan docs. -Use the menu to find various pages. Also checkout out the [contributing](/contributing) page on how to add and update these docs +Use the menu to find various pages. Also checkout out the [contributing](/contributing) page on how to add and update these docs. + +These docs are very new, and defiantly still a work in progress. Feel free to help out and migrate helpful content from the main README.md, and various issues/discussions all in here to get them in in a central place diff --git a/ha-battery-alert.md b/ha-battery-alert.md deleted file mode 100644 index 537ac7c..0000000 --- a/ha-battery-alert.md +++ /dev/null @@ -1,34 +0,0 @@ -# Setup battery alerts in Home Assistant - -![image](https://user-images.githubusercontent.com/94690098/192513730-79944a6d-73d0-4bd3-934e-1b2432c083f0.png) - - -In this update I’d like to talk about battery alerts and how to set it up. Battery alerts are particularly useful if you own multiple cars that you don't often use. All cars have "parasitic current draw" between 50mA to 85mA which eventually empties the battery if the car is not turned on, some cars can last about 30 days or 4 weeks before it needs to be jump started. WiCAN can help you keep an eye on the battery voltage as the battery discharges and send you an alert when the preset value is reached. In this tutorial you’ll create a simple Mqtt sensor and automation in Home Assistant, so when low battery is detected a text to speech notification will be sent to Google Home speaker. - -Battery alerts are easy to set up, assuming you have a wifi connection where you park your car and you have a home assistant running on your network. Here’s how to set it up: - -1- Install Home Assistant [Mosquitto broker add-on](https://github.com/home-assistant/addons/blob/master/mosquitto/DOCS.md) - -2- Create Home Assistant new user account for WiCAN. These user credentials will be used to set up the mqtt setting for WiCAN. - -3- Connect to WiCAN access point WiCAN_xxxxxxxxxxxx, then using a web browser, go to http://192.168.80.1/ - -4- Enable Sleep mode and Battery Alert. - -5- Fill in the Battery Alert configuration. In the Alert URL fill in your Home Assistant ip address and the Mqtt User/password created in step 2. - -![image](https://user-images.githubusercontent.com/94690098/192513194-0decddc1-0be3-4231-bece-814d26671766.png) - -6- To create a new MQTT sensor, you need to edit “configuration.yaml” file and add the following lines to the file: -mqtt: - sensor: - - name: "Car Battery" - state_topic: "CAR1/voltage" - unit_of_measurement: "V" - value_template: "{{ value_json.battery_voltage }}" - -7- Restart Home Assistant, then edit your dashboard to add a new card with “Car Battery” entity. - -8- Finally create a new automation by setting the MQTT topic, entity name and battery voltage value. - -![image](https://user-images.githubusercontent.com/94690098/192513519-9f531503-b93f-4712-b57d-7f8dd06ba4dc.png) diff --git a/ha/wican_example_flow.json b/ha/wican_example_flow.json deleted file mode 100644 index 9e18ed3..0000000 --- a/ha/wican_example_flow.json +++ /dev/null @@ -1 +0,0 @@ -[{"id":"c11843ebf9246b34","type":"tab","label":"Flow 1","disabled":false,"info":"","env":[]},{"id":"d897d06ca9cc0590","type":"mqtt in","z":"c11843ebf9246b34","name":"","topic":"wican/device_id/can/rx","qos":"0","datatype":"auto-detect","broker":"a3221ddd636fd541","nl":false,"rap":true,"rh":0,"inputs":0,"x":530,"y":800,"wires":[["b5c51ef05fb34a12","8cf0115436d3fef6"]]},{"id":"f174886b9f84065e","type":"mqtt in","z":"c11843ebf9246b34","name":"","topic":"wican/device_id/status","qos":"0","datatype":"auto-detect","broker":"a3221ddd636fd541","nl":false,"rap":true,"rh":0,"inputs":0,"x":530,"y":600,"wires":[["2f2215a9609be7a3"]]},{"id":"d6ae5410d4d73060","type":"mqtt out","z":"c11843ebf9246b34","name":"Publish to WiCAN","topic":"wican/device_id/can/tx","qos":"0","retain":"","respTopic":"","contentType":"","userProps":"","correl":"","expiry":"","broker":"a3221ddd636fd541","x":1350,"y":600,"wires":[]},{"id":"53398018d8604c78","type":"function","z":"c11843ebf9246b34","name":"Send Get fuel req","func":"\n\nmsg.payload = { \"bus\": \"0\", \"type\": \"tx\", \"frame\": [{ \"id\": 2016, \"dlc\": 8, \"rtr\": false, \"extd\": false, \"data\": [2, 1, 47, 170, 170, 170, 170, 170] }] };\nreturn msg;\n\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1030,"y":720,"wires":[["d6ae5410d4d73060"]]},{"id":"b5c51ef05fb34a12","type":"function","z":"c11843ebf9246b34","name":"Parse Fuel RSP","func":"\nvar obj = Object(); \n\nfor(let i = 0; i < msg.payload.frame.length; i++){\n //check frame id\n if (msg.payload.frame[0].id == 2024 && msg.payload.frame[0].data[2] == 47){\n obj.fuel_level = msg.payload.frame[0].data[3] * (1 / 2.55);\n obj.fuel_level = Math.round(obj.fuel_level * 100) / 100;\n msg.payload = obj;\n return msg;\n }\n}\n\n\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":780,"y":800,"wires":[["b98b59c966f60b79"]]},{"id":"b98b59c966f60b79","type":"mqtt out","z":"c11843ebf9246b34","name":"Publish fuel level to HA","topic":"CAR1/Fuel_Level","qos":"0","retain":"","respTopic":"","contentType":"","userProps":"","correl":"","expiry":"","broker":"a3221ddd636fd541","x":1370,"y":800,"wires":[]},{"id":"2f2215a9609be7a3","type":"function","z":"c11843ebf9246b34","name":"0100","func":"\nif(msg.payload.status == \"online\"){\n msg.payload = { \"bus\": \"0\", \"type\": \"tx\", \"frame\": [{ \"id\": 2016, \"dlc\": 8, \"rtr\": false, \"extd\": false, \"data\": [2, 1, 0, 170, 170, 170, 170, 170] }] };\n return msg;\n}\n\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":750,"y":600,"wires":[["d6ae5410d4d73060"]]},{"id":"8cf0115436d3fef6","type":"function","z":"c11843ebf9246b34","name":"check Init Resp","func":"\nvar obj = Object(); \nfor (let i = 0; i < msg.payload.frame.length; i++) {\n if (msg.payload.frame[0].id == 2024 && msg.payload.frame[0].data[1] == 65 && msg.payload.frame[0].data[2] == 0){\n\n return msg;\n }\n}\n\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":780,"y":720,"wires":[["53398018d8604c78"]]},{"id":"2b0fdfd345c70c85","type":"mqtt in","z":"c11843ebf9246b34","name":"","topic":"wican/device_id/can/rx","qos":"0","datatype":"auto-detect","broker":"a3221ddd636fd541","nl":false,"rap":true,"rh":0,"inputs":0,"x":530,"y":420,"wires":[["06f2129337df3f53"]]},{"id":"439b4ba43bc22264","type":"debug","z":"c11843ebf9246b34","name":"debug 3","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":1080,"y":320,"wires":[]},{"id":"8d062f82d786743c","type":"mqtt in","z":"c11843ebf9246b34","name":"","topic":"wican/device_id/status","qos":"0","datatype":"auto-detect","broker":"a3221ddd636fd541","nl":false,"rap":true,"rh":0,"inputs":0,"x":530,"y":220,"wires":[["314db33b5f26f14e"]]},{"id":"b9eab1ae011789af","type":"mqtt out","z":"c11843ebf9246b34","name":"Publish Get Temp req to WiCAN","topic":"wican/device_id/can/tx","qos":"0","retain":"","respTopic":"","contentType":"","userProps":"","correl":"","expiry":"","broker":"a3221ddd636fd541","x":1150,"y":220,"wires":[]},{"id":"314db33b5f26f14e","type":"function","z":"c11843ebf9246b34","name":"Send Get Amb Temp req","func":"\n\nmsg.payload = { \"bus\": \"0\", \"type\": \"tx\", \"frame\": [{ \"id\": 2015, \"dlc\": 8, \"rtr\": false, \"extd\": false, \"data\": [2, 1, 70, 170, 170, 170, 170, 170] }] };\nreturn msg;\n\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":850,"y":220,"wires":[["b9eab1ae011789af","439b4ba43bc22264"]]},{"id":"06f2129337df3f53","type":"function","z":"c11843ebf9246b34","name":"Parse Amb Temp RSP","func":"var obj = Object();\n\nfor (let i = 0; i < msg.payload.frame.length; i++) {\n //check frame id\n if (msg.payload.frame[0].id == 2024 && msg.payload.frame[0].data[2] == 70) {\n obj.amb_temp = msg.payload.frame[0].data[3] - 40;\n msg.payload = obj;\n return msg;\n }\n}\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":840,"y":420,"wires":[["5959e252f55b00bd","439b4ba43bc22264"]]},{"id":"5959e252f55b00bd","type":"mqtt out","z":"c11843ebf9246b34","name":"Publish Amb Temp to HA","topic":"CAR1/Amb_Temp","qos":"0","retain":"","respTopic":"","contentType":"","userProps":"","correl":"","expiry":"","broker":"a3221ddd636fd541","x":1130,"y":420,"wires":[]},{"id":"a3221ddd636fd541","type":"mqtt-broker","name":"local","broker":"192.168.31.2","port":"1883","clientid":"","autoConnect":true,"usetls":false,"protocolVersion":"4","keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","birthMsg":{},"closeTopic":"","closeQos":"0","closePayload":"","closeMsg":{},"willTopic":"","willQos":"0","willPayload":"","willMsg":{},"userProps":"","sessionExpiry":""}]