Trip Logging Automations for PHEV (easily adaptable to BEV/ICE) #156
IceRoG
started this conversation in
Show and tell
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
🚗 PHEV Trip Logging with Home Assistant Automations
🤔 Why PHEV Trip Logging Is Harder Than BEV or ICE
Trip logging for Battery Electric Vehicles (BEV) or pure petrol/diesel cars is relatively straightforward:
kWh/100kmL/100kmPlug-in Hybrid Electric Vehicles (PHEV) combine both worlds — and that’s where things get complicated.
The FordPass limitation
The FordPass Home Assistant integration does not expose:
kWh), orliters)Instead, it exposes a single metric:
tripFuelEconomyThis value is already a vehicle-internal combination of:
kWh/100km)L/100km)The exact weighting is done by the car itself and is not transparent.
Why this matters
Because of this limitation:
The workaround used here
This setup reconstructs meaningful trip data by:
kWh/100kmfrom the battery energy difference over the trip distanceL/100kmfrom the tripFuelEconomy over the trip distance, adjusted using kWh contributiontripFuelEconomyonly as a reference for baseline fuel efficiencyThis makes it possible to:
1️⃣ Set up FordPass
First, make sure the FordPass integration is configured and connected to your vehicle.
All following steps rely on FordPass sensors such as:
2️⃣ Create Required Helper & Template Sensors
🔹 Trip baseline sensors
These template sensors extract attributes from FordPass entities and expose them as standalone sensors.
2️⃣b Driver Detection (Who is Driving?)
Driver detection is based on:
PersonOne
Entity:
sensor.triplog_PersonOne_connectedPersonTwo
Entity:
sensor.triplog_PersonTwo_connected2️⃣c Helpers for Trip Start
Create the following helpers:
input_number.triplog_start_batteryinput_number.triplog_start_fuelSet the maximum value of
input_number.triplog_start_fuelto a value above 100 (e.g.120), as Ford fuel percentages can exceed 100%.3️⃣ Configure CSV Logging (File Integration)
Trip data is persisted in a CSV file.
3.1 Allow file access
Add the following to
configuration.yaml:3.2 Create the file notification
/config/triplogs.csv4️⃣ Import the Automations
[VIN]with your vehicle VIN everywhere5️⃣ Set up Pyscript
Install and configure the Pyscript integration.
This is required to:
6️⃣ Create Sensors from the CSV
Use the
update_triplog_sensorsPyscript service to:Create last trip sensors per driver
Create aggregated statistics per driver
Currently, the script must be re-run after every Home Assistant restart and of course after every new data entry.
7️⃣ Visualize & Analyze
With all sensors available, you can:
✅ Result
A fully automated PHEV trip logging pipeline:
FordPass → Automations → CSV → Pyscript → Sensors → Dashboards
🔹 Automation 1: TripLog Start
This automation triggers when the vehicle’s wheel torque status changes from
OFFtoON(i.e., the car starts moving).It stores the initial state of the trip:
These values are saved into
input_numberhelpers for later comparison.🧠 Purpose
Capture a clean baseline at trip start so that consumption can be calculated reliably at trip end.
📄 YAML
🔹 Automation 2: TripLog End
This automation triggers when the wheel torque status changes from
ONtoOFF(vehicle stops).It:
pyscript📄 YAML
🔹 Part 3: Reading the CSV and Creating Trip Sensors with Pyscript
To make the trip data usable again inside Home Assistant, I use a Pyscript service that reads the CSV file and recreates entities for:
🧠 Design decisions
/config/triplogs.csvavg = Σ(consumption_per_100km × km) / Σ(km)The service can be triggered manually or automatically at the end of each trip.
📄 Pyscript Service
Beta Was this translation helpful? Give feedback.
All reactions