fix: disambiguate route AM and PM suffixes and prevent partial word matches #10

Merged
jrittenh merged 2 commits from fix/route-am-pm-resolution into main 2026-10-29 07:50:03 -04:00
Owner

Summary of Changes

  • Word Boundary Matching for Suffixes: Switched route AM/PM regex evaluation to word boundaries (\b(am|morning|pickup)\b and \b(pm|afternoon|dropoff)\b) in get_time_suffix and entity name generation. Prevents route names containing substrings like 'am' (e.g. Campus, Program, Oakham, Graham, Durham, William, STEAM) from falsely matching as AM routes when they are actually PM routes.
  • Relative Route Schedule Disambiguation: Enhanced get_run_display_name to accept all_runs for a student. When a student has multiple runs, the run schedules are compared so the earlier planned run is designated as AM and the later run as PM, preventing accidental duplicate PM or AM labels.
  • Entity ID Migration Safety: Updated _async_migrate_entity_ids to pass runs to get_run_display_name and safely handle existing entity ID swaps or temporary transitions.
  • Version Bump: Bumped manifest version to 0.2.4.
  • Unit Tests: Added test coverage verifying that route names with embedded 'am' words resolve to _pm suffixes, relative run schedule comparison, and migration safety.
### Summary of Changes - **Word Boundary Matching for Suffixes**: Switched route AM/PM regex evaluation to word boundaries (`\b(am|morning|pickup)\b` and `\b(pm|afternoon|dropoff)\b`) in `get_time_suffix` and entity name generation. Prevents route names containing substrings like 'am' (e.g. `Campus`, `Program`, `Oakham`, `Graham`, `Durham`, `William`, `STEAM`) from falsely matching as AM routes when they are actually PM routes. - **Relative Route Schedule Disambiguation**: Enhanced `get_run_display_name` to accept `all_runs` for a student. When a student has multiple runs, the run schedules are compared so the earlier planned run is designated as AM and the later run as PM, preventing accidental duplicate PM or AM labels. - **Entity ID Migration Safety**: Updated `_async_migrate_entity_ids` to pass `runs` to `get_run_display_name` and safely handle existing entity ID swaps or temporary transitions. - **Version Bump**: Bumped manifest version to `0.2.4`. - **Unit Tests**: Added test coverage verifying that route names with embedded 'am' words resolve to `_pm` suffixes, relative run schedule comparison, and migration safety.
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
jrittenh/ha-myride!10
No description provided.