I used to drive an EV6, now I drive a 2024 Mach-E. Wasn’t my plan, but alas accidents happen.
With a new car comes a new Home Assistant integration, so I installed ha-fordpass, and let me tell you, WHAT an upgrade! The main benefit is that, whereas most integrations poll the upstream API periodically for updated data, and are typically rate-limited in doing so, the Ford apps use a totally different architecture with a persistent open websocket for Ford to push new datapoints down to the app the moment they arrive. The ha-fordpass integration, mimicking the app, uses the same strategy, and the benefit is that you basically get constant, instantly up to date, fine-grained telemetry from whatever car you’ve got connected. When I unplug the car, HA knows within seconds. The odometer sensor ticks up basically mile by mile, or even less.
Beyond that, ha-fordpass also has lots more interesting data available to it than the old Kia Connect integration. One of those things is “sensors.fordpass_<yourVIN>_lastenergyconsumed” or “EV Energy Consumption (last trip).” This sensor shows the consumption of the last trip in watt-hours, updated as soon as the ignition gets shut off.
I wanted to make a sensor that used this and the odometer sensor to calculate my mi/kWh efficiency for every trip. Here’s what I landed on in configuration.yaml:
template:
- trigger:
- platform: state
entity_id: sensor.fordpass_3fmtk4sx9rma24943_ignitionstatus
to: "ON"
sensor:
- name: "Mach-E Rally Trip Start Odometer"
unique_id: mach_e_rally_trip_start_odometer
unit_of_measurement: "mi"
state: >
{{ states('sensor.fordpass_3fmtk4sx9rma24943_odometer') | float(0) }}
- trigger:
- platform: state
entity_id: sensor.fordpass_3fmtk4sx9rma24943_ignitionstatus
to: "OFF"
sensor:
- name: "Mach-E Rally Last Trip Distance"
unique_id: mach_e_rally_last_trip_distance
unit_of_measurement: "mi"
state_class: measurement
state: >
{% set end_odo = states('sensor.fordpass_3fmtk4sx9rma24943_odometer') | float(none) %}
{% set start_odo = states('sensor.mach_e_rally_trip_start_odometer') | float(none) %}
{% if end_odo is not none and start_odo is not none and end_odo >= start_odo %}
{{ (end_odo - start_odo) | round(2) }}
{% else %}
{{ this.state }}
{% endif %}
- trigger:
- platform: state
entity_id:
- sensor.mach_e_rally_last_trip_distance
- sensor.fordpass_3fmtk4sx9rma24943_lastenergyconsumed
sensor:
- name: "Mach-E Rally Efficiency of Last Trip"
unique_id: ford_mach_e_rally_efficiency_of_last_trip
unit_of_measurement: "mi/kWh"
state_class: measurement
icon: mdi:lightning-bolt
state: >
{% set distance_mi = states('sensor.mach_e_rally_last_trip_distance') | float(none) %}
{% set energy_wh = states('sensor.fordpass_3fmtk4sx9rma24943_lastenergyconsumed') | float(none) %}
{% set ignition = states('sensor.fordpass_3fmtk4sx9rma24943_ignitionstatus') %}
{% if ignition == 'OFF'
and distance_mi is not none
and distance_mi > 0
and energy_wh is not none
and energy_wh > 0 %}
{{ (distance_mi / (energy_wh / 1000)) | round(2) }}
{% else %}
{{ this.state }}
{% endif %}
This gives exactly what I’m after. This morning I took a 9.94mi trip:


Energy consumed showed 2.080kWh:

Which calculates out to 4.78 mi/kWh!

Except… there’s no way that’s right. Way too efficient for this car. As a spot check, yes, the car disagrees. Even with rounding, 3.9 mi/kWh is way lower:

I had my suspicions about accuracy after a couple days of trying to get these template sensors working right, so I took screenshots of OBDII sensor readings before and after the trip.


These show 63.99-61.43=2.56kWh consumed, which calculates out to 3.88 mi/kWh – much more likely and in agreement with the car. 2.08/2.56kWh = 81.3%, which is also suspiciously close to the “driving” only portion of the consumption reported on the infotainment screen. So I think maybe this energy consumed telemetry ONLY reflects the drive train and not total consumption, which would be a real bummer. I don’t believe there’s any other sufficiently accurate way to measure or calculate energy consumed per trip, as %SOC is quite coarse and would require a constantly shifting energy-per-percent as the battery health changes.
I’m open to any other ideas but at least for now, this is where I’m at. I may just juice the stats by applying a static 80% correction factor, but that will change with the seasons and accessory usage which is most of the point of doing this. I guess the stat as-is is still useful as a measure of how efficiently you’re driving, never mind the weather.
More to come with my other automations – there are already a few!
Be First to Comment