Skip to content

feat: carrier auto detect - #80

Closed
jmdevita wants to merge 2 commits into
mainfrom
feature/carrier-auto-detect
Closed

jmdevita wants to merge 2 commits into
mainfrom
feature/carrier-auto-detect

Conversation

@jmdevita

@jmdevita jmdevita commented Apr 4, 2026

Copy link
Copy Markdown
Owner

Summary

Adds automatic carrier detection from tracking numbers, so the courier field is now optional
when calling add_parcel or edit_parcel.

  • Uses regex patterns and checksum validation from
    jkeen/tracking_number_data (vendored JSON, no
    runtime API calls)
  • Supports 11 carriers: UPS, FedEx (7 formats), USPS (4 formats), DHL (5 formats), Amazon,
    Canada Post, DPD, OnTrac, LaserShip, Landmark, Old Dominion
  • 6 checksum algorithms: mod10, mod7, s10, luhn, sum_product, mod_37_36
  • New detect_carrier service for testing detection in HA developer tools
  • Backwards compatible — existing automations that pass courier explicitly are unaffected
  • Adds HA <2025.12 compatibility for description_placeholders

New files

  • carrier_detection.py — core detection module
  • tracking_data/*.json — 12 vendored carrier pattern files
  • tests/test_carrier_detection.py — 247 tests using jkeen's own test vectors

@jmdevita jmdevita changed the title Feature/carrier auto detect Carrier auto detect Apr 4, 2026
@jmdevita jmdevita changed the title Carrier auto detect feat: carrier auto detect Apr 4, 2026
@jmdevita

jmdevita commented Apr 4, 2026

Copy link
Copy Markdown
Owner Author

ping @PineappleEmperor if you have a moment, it may look like a massive change, but it's really just using https://github.com/jkeen/tracking_number_data as the source of truth for some auto-detection of carriers.

@PineappleEmperor PineappleEmperor left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hallo! Apologies for being AWOL! Looks good to me! We could consider releasing these as betas to make it easier to test/review? How do you want to package all of these PRs into a new version?

@jmdevita

Copy link
Copy Markdown
Owner Author

@PineappleEmperor Good idea, and I'm not sure yet.. I can figure this out this weekend unless you have any ideas!

@jmdevita

Copy link
Copy Markdown
Owner Author

@PineappleEmperor just pushed as a v1.8.0 pre-release, it absorbs a few other PRs as well. I'll test on my main HA instance but things are looking good!

@PineappleEmperor

Copy link
Copy Markdown
Collaborator

@jmdevita sorry again! I'm rammed at the minute! I've installed the beta on my main HA and have run a few tests - looks good to me!

I could see us getting requests for more automatically recognised tracking numbers, depending on how popular the feature is?

Do you want to squash and merge when you're ready to release it fully? :)

@jmdevita jmdevita mentioned this pull request Apr 21, 2026
@jmdevita jmdevita closed this in #83 Apr 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants