Repository navigation
Edit a bus profile: rename, move the stop, change the schedule (v0.5.2) - #3
Conversation
….5.2) Configure -> "Edit a bus profile" changes the name, bus, stop (map pick with radius, or the bus's current position), expected arrival and grace, watch window, days and offline alert. The profile id stays the same, so checkpoints, recorded trips, entity IDs and scripts using profile: <id> keep working. Add and Edit share one form. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b81da9784b
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| fields = self._profile_fields(user_input, loc) | ||
| fields["stop"] = {**(current.get("stop") or {}), **fields["stop"]} | ||
| profiles[pid] = {**current, **fields} | ||
| return self._save(profiles) |
There was a problem hiding this comment.
Reset live trip state when changing the bus or stop
If today's tracker has already marked the bus as arrived, changing its vehicle or moving its stop saves the new configuration but retains the old arrival state. The options update reloads the entry, and BusMonitorCoordinator.async_load() restores that snapshot by the unchanged profile ID without checking the vehicle or stop. Consequently, TripTracker.wants_position() remains false and update() suppresses further arrival/checkpoint alerts for the rest of the day, even though the newly selected bus has not reached the newly configured stop. Invalidate the affected live trip state on these changes while retaining completed trip history and preserving state for rename-only edits.
Useful? React with 👍 / 👎.
What
Adds Configure → Edit a bus profile. You pick a profile, and a form opens filled in with its current settings:
The profile id stays the same, so the following keep working:
profile: <id>, like the "Where is the bus" script.Add and Edit now share one form (
_profile_schema) and one builder (_profile_fields), so they can't drift apart. Edit merges onto the stored profile, so it keeps checkpoints and any other stored keys.Why
Before this, a profile couldn't be changed after it was created. Renaming a route or moving the stop meant deleting the profile, which also lost its checkpoints and trip history, and changed its id.
Reviewer notes
name_exists.Tests
ruff,pytest(100 tests) and hassfest (run locally in Docker) all pass. New tests:🤖 Generated with Claude Code