Skip to content

Add trip and charging advice with briefing charts - #25

Merged
itbird merged 1 commit into
mainfrom
cursor/trip-charging-advice-1e7d
Nov 14, 2026
Merged

itbird merged 1 commit into
mainfrom
cursor/trip-charging-advice-1e7d

Conversation

@itbird

@itbird itbird commented Nov 14, 2026

Copy link
Copy Markdown
Contributor

Weekly, monthly, and yearly briefings now summarize saved use and attach a local chart. Trip and charging advice stays on this computer, and a charge session stores only the energy added during that plug-in.

Trip advice

agentdrive advice trip <km> does not wake the car and does not change a setting. It uses a non-waking battery reading when the car is already online, otherwise the last saved snapshot. Consumption is battery percent per kilometre from the car's own trips. Fewer than three usable trips is reported as too little data. A saved outside temperature can add 10 or 20 percent in cold or hot weather. The same reply suggests an everyday charge limit, usually 80 percent, and a higher limit only before a long trip. If a departure schedule is set and it is cold or hot, it suggests preconditioning and does not start it.

Trip advice from saved history on this computer. This does not change the car and does not wake it.
Battery is 55% from a non-waking reading.
Recent driving averages 0.50% of the battery per km, from 3 saved trips.
Outside temperature is -2 C (non-waking reading), so the estimate adds 20 percent for cold weather.
A trip of 120 km needs about 82% (72% to drive and 10% in reserve).
55% is not enough for this trip. It is short by about 27%.
A normal day in the saved history is about 20 km. A charge limit of 80% covers that. This does not change the charge limit.
Before this trip, about 85% would cover it. This does not change the charge limit.
A departure schedule is set and it is cold (-2 C). Preconditioning the cabin before you leave is worth doing. This is advice only. It does not start preconditioning and it does not change the departure schedule.

With only two usable trips:

Not enough saved trips to estimate consumption: 2 usable trips. At least 3 are needed. No guess was made.
Not enough saved days to learn a daily charge limit from your own driving. 80% is the usual everyday limit, and a long trip can justify a higher one. This does not change the charge limit.

Charging advice

agentdrive advice charge flags often charging to 100% and leaving it, often starting below 20%, and often charging inside a saved peak window. agentdrive tariff set off-peak 22:00-06:00 --price 0.18 and agentdrive tariff set peak 16:00-21:00 store hours in $AGENTDRIVE_HOME/tariff.yaml. Price is optional. If the in-car timetable starts outside the cheap window, the reply says so and still requires the existing confirmation before anything changes.

Often charging to 100% and leaving it: 3 of 3 saved charges ended at 99% or more and were still high hours later.
Often dropping very low before charging: 3 of 3 saved charges started at 20% or below.
Often charging in the peak window (16:00-21:00): 3 of 3 saved charges started then.
The cheap window is 22:00-06:00. Moving scheduled charging there is advice only. Any change still needs a confirmation.
The in-car timetable starts at 18:00, outside the cheap window (22:00-06:00). Moving it is a charging change and still needs a confirmation. This advice does not change the timetable.

Briefings

Week, month, and year briefings add kilometres, trips, average km/day, charges, kWh added, average per charge, the previous period, and a coverage note. History is opportunistic, not continuous. Each of those briefings writes a PNG under the car directory in AGENTDRIVE_HOME and prints Chart:. briefings/dashboard.html is one offline file with week, month, and year views. matplotlib is used when it is installed. Otherwise AgentDrive draws the PNG itself.

Summary: 32 km driven, 1 trips, 4.6 km per day. Charges: none, energy added was not available, average per charge was not available.
Compared with the previous week (2026-02-23 to 2026-03-01): 32 km versus 16 km, 1 trips versus 1, energy not recorded versus energy not recorded.
Coverage is incomplete: saved readings on 1 of 7 days. History is opportunistic, not a continuous record.
Chart: /path/in/AGENTDRIVE_HOME/briefings/weekly-2026-03-02.png
Dashboard: /path/in/AGENTDRIVE_HOME/briefings/dashboard.html

Pass --car <nickname> when several cars are saved. Advice, history, and the chart stay with that car.

Charge energy

charge_energy_added is the car's session counter, but the first reading of a new plug-in can still be the previous session, and some sessions keep climbing without returning to zero. The old code kept max(), so 70% to 72% could be stored as 54.2 kWh, and 61% to 77% as 35.8 kWh when the counter had already reached 17.1 kWh. A new session now stores only the increase after a reset, or the rise above a high opening reading when that total cannot match the battery change. A normal session that climbs from about 0 to 5.0 kWh is still 5.0 kWh. Older rows are not rewritten. Summaries count a corrected figure when the samples support one, and leave out a saved figure that cannot match the percent change.

Tests

pytest is green locally (226 tests), including too little trip data, trip sufficiency, charge-limit and tariff advice, habit flags, period comparison and coverage, the builtin PNG and offline HTML, the energy fix, and legacy rows left unchanged.

Open in Web Open in Cursor 

Learn consumption from saved trips, flag charging habits against a private home tariff, and summarize week, month, and year history with a local chart. Charge energy is the increase during a plug-in, and older rows that cannot match the battery change stay stored but drop out of totals.
@itbird
itbird merged commit b6e7da6 into main Nov 14, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant