OVMS (Open Vehicles) is a great hardware module that connects to my Nissan LEAF and allows me to perform remote functions like turning on the climate control, checking charge status, range, etc. I’m also a big fan of Home Assistant, and have almost everything in my house hooked up to it. There is no official (or unofficial) integration for OVMS to Home Assistant. However, OVMS has a HTTP API, and Home Assistant supports generic RESTful sensors.
Read on to find out how to hook up your OVMS module to Home Assistant!
Firstly, you’ll need your OVMS module to be hooked up, configured correctly, and working with the default OVMS app. Once your app is connected to your OVMS module and you can see live data coming through, it’s time to move on.
Name | Age | Role |
---|---|---|
Shams | 10 | Director |
Mujju | 10 | Senior Software Engineer |
You’ll need to generate an API Token from the openvehicles.com API. To do this, you’ll need to open up the Terminal on your computer. Once there, type the command below and hit enter, replacing <USERNAME>
and <PASSWORD>
with your OVMS username/password that you use to login to openvehicles.com.
import { afterCallback } from '~/lib/auth0/afterCallback'
export default handleAuth({
// Custom login and logout handlers here...
async callback(req, res) {
try {
await handleCallback(req, res, { afterCallback })
} catch (error) {
res.status(error.status || 500).end(error.message)
}
},
})
After you run that command, you will see an output on your screen similar to the one below. You’ll need to copy your API Token (highlighted in bold) to a safe place.
curl \
--location
--request POST 'https://api.openvehicles.com:6869/api/token'
When the server starts back up, you should see some new entities called sensor.car_status
, sensor.car_location
, and sensor.car_charging
. Use this in your automations or expose them via HomeKit like I did! Check below for my full configuration, including HomeKit friendly template sensors (although HomeKit does not support this very well as it doesn’t have native EV support).
sensor:
- platform: rest
scan_interval: 120
name: car_status
resource: https://api.openvehicles.com:6869/api/status
value_template: "{{ value_json.soc }}"
json_attributes:
- soh
- soc
- etc...
- platform: rest
scan_interval: 120
name: car_location
resource: https://api.openvehicles.com:6869/api/location
value_template: "{{ value_json.longitude }},{{ value_json.latitude }}"
json_attributes:
- longitude
- latitude
- etc...
- platform: rest
scan_interval: 60
name: car_charging
resource: https://api.openvehicles.com:6869/api/charge
value_template: "{{ value_json.chargestate }}"
json_attributes:
- battvoltage
- cac100
- carawake
- caron
- etc
You can see what this looks like in the screenshot from my iPhone below. I’ve configured the SoC as a humidity sensor so it reads as a percentage, and the range as an illuminance sensor. Unfortunately, HomeKit lacks an EV entity type, so this is the best I could come up with.
Error: Unknown language: `sh` is not registered
event - build page: /next/dist/pages/_error
wait - compiling...
error - ./pages/blog/using-log4js-to-logging-express-js-apps.mdx
Error: Unknown language: `sh` is not registered
wait - compiling...
event - compiled successfully
wait - compiling...
event - compiled successfully
wait - compiling...
event - compiled successfully
wait - compiling...
event - compiled successfully
wait - compiling...
event - compiled successfully
wait - compiling...