Skip to content
ha-parcel-integrationsPublic

Repository files navigation

DHL Parcel Tracker

Release Downloads Marketplace License

📦 Part of ha-parcel-integrations, a family of package-tracking integrations for Home Assistant that all publish the same parcel format, statuses and events, so they plug into cross-carrier automations and the optional Parcel Aggregator. Browse the other carriers on the website.

💬 Questions or feedback? Join the discussion on the Home Assistant community.

A custom Home Assistant integration that tracks DHL Paket (Germany), DHL Parcel Polska, and — via tracking codes, no account needed — DHL Parcel's wider network and DHL Express. During setup, pick Account to log in with your own DHL Kundenkonto or Mój DHL account (parcels import automatically), Tracking codes to add tracking numbers directly (each code is routed automatically to whichever DHL backend can answer it), or API Tracking to track codes through DHL's official tracking API with a key of your own.

Account support: Germany and Poland. DHL's Polish account setup uses a nine-digit Polish mobile number and a one-time SMS code; the renewable session cookie jar is stored locally, never the SMS code or a bearer token. Country requests go through the organisation discussion. DHL's Netherlands business is a separate integration, ha-dhl-nl.

Tracking-code support: any DHL Parcel barcode (3S…, JJD…, CR…/LX…) and any DHL Express air waybill (a bare 10-digit number), worldwide, plus DHL Paket Germany parcel numbers, domestic DHL Freight Sweden shipment numbers, DHL parcel numbers that only DHL's Polish tracking (Mój DHL) knows, such as a parcel sent from Poland to another country, and parcels DHL eCommerce Iberia delivers in Spain and Portugal — no account or postcode needed. See Tracking codes below.

API Tracking support: every DHL business DHL's official Shipment Tracking – Unified API covers — DHL Paket Germany by number (no German IP or login needed), DHL eCommerce, DHL Parcel in Poland, the UK and the Netherlands, DHL Express, DHL Freight and DHL Global Forwarding — with your own key from developer.dhl.com. See API Tracking below.

Contents

Features

  • Automatic parcel import from your DHL Kundenkonto — no tracking codes to enter for your own parcels
  • dhl.track_parcel / dhl.untrack_parcel services to add or remove a tracking number from an automation — on an account, for a parcel that is not (yet) in its inbox
  • Per-parcel sensor with the canonical status (registered / in_transit / out_for_delivery / delivered / …), DHL's own status text, the expected delivery window and a tracking deep-link
  • Summary sensors: incoming parcels, next delivery, recently delivered parcels, outgoing parcels
  • Read-only Deliveries calendar with the expected delivery windows
  • Events + device triggers for no-code automations (parcel registered, status changed, delivered, delivery time changed)
  • Opt-in per-parcel status history
  • Manual refresh button and a diagnostic last-update sensor
  • Structure-preserving diagnostics export — the tool this pre-release is finished with (see Debugging)

Requirements

Account setup:

  • A DHL Kundenkonto (a free DHL account) — the same account you use on dhl.de or in the DHL Paket app — or a Mój DHL account for Poland
  • A browser to complete the one-time sign-in during setup (Germany only)
  • A German IP address for Germany. DHL's tracking endpoint only answers requests that originate from Germany — this is normally not a concern (a DHL Paket customer's own Home Assistant is already reached from Germany), but it means the integration will not work over a non-German VPN, from a non-German cloud/VPS-hosted Home Assistant, or during development/testing from outside Germany.

Tracking-code setup: nothing beyond the tracking code itself — no account, no login, no postcode.

API Tracking setup:

  • A developer profile on developer.dhl.com with an app that has the Shipment Tracking – Unified API, and that app's API key. DHL issues the key to a profile with a company name; a private profile has been refused.
  • The standard key allows 250 calls a day and one call every 5 seconds. Each tracked parcel costs one call per update, so the standard key covers about five parcels in transit at once (see API Tracking).

Installation

Marketplace (recommended)

  1. Open the Marketplace and search for DHL.
  2. Install it.
  3. Restart Home Assistant.

Or click the button below to open it directly in the Marketplace:

Open your Home Assistant instance and open a repository inside the Marketplace.

Manual

Copy custom_components/dhl into your config/custom_components/ folder and restart Home Assistant.

Configuration

Open your Home Assistant instance and start setting up a new integration.

Or set it up by hand:

  1. Go to Settings → Devices & Services → Add Integration → DHL.
  2. Choose Account, Tracking codes or API Tracking.

Account

  1. Pick a country. For Poland, enter the Mój DHL mobile number and then the single SMS code DHL sends; the integration never resends it automatically.
  2. The next form shows a sign-in link. Open it in a browser and log in with your DHL Kundenkonto.
  3. Your browser will fail to open the final dhllogin://… redirect it lands on — that is expected. This address never appears in the address bar (no desktop browser has an app registered for it); you catch it in your browser's developer tools' Network tab instead. See docs/finding-the-redirect-url.md for step-by-step instructions for Chrome, Edge, Firefox and Safari. Paste the full address into the form.
  4. Submit. Your account's parcels start appearing on the next poll.

Nothing is typed into Home Assistant itself except that pasted-back address — your DHL password never passes through this integration.

Adding a parcel that is not in your account

Your DHL account inbox only shows parcels addressed to you. To also track a parcel someone else is sending you (or one your account has not picked up yet), call the dhl.track_parcel service with its tracking number, or use a dashboard button.

Tracking codes

Choosing Tracking codes creates a single tracking hub with no parcels yet — add codes afterwards from Configure → Incoming parcels or Outgoing parcels, or with the dhl.track_parcel service. Nothing is validated against DHL at add time; a code only resolves (or doesn't) on the next poll.

API Tracking

  1. Paste your API key. It is checked with one call before the entry is created; the key is stored in Home Assistant's config-entry storage and never shown or logged.
  2. Add codes afterwards from Configure → Incoming parcels or Outgoing parcels, or with dhl.track_parcel, exactly as on a tracking hub.

Every code goes to DHL's official API — there is no routing and no fallback to the tracking hub's backends. You can add one entry per key. An entry with a key and a tracking hub side by side each keep their own parcel list.

Mind the daily quota. Calls are made one at a time, at least 5 seconds apart, and a parcel stops being fetched once it is delivered. When DHL answers that the quota is used up, the entry waits (as long as DHL asks, or longer each time it happens) and keeps showing the last known data. With the standard 250 calls a day, more than about five parcels in transit at once will use up the day. If DHL rejects the key, Home Assistant asks for a new one.

DHL's API terms apply to this setup: data from it is attributed "Delivered by Deutsche Post DHL Group" on every entity, delivered parcels disappear at the latest 30 days after delivery whatever the retention setting says, and you should only track your own parcels.

Tracking codes

Each code you add is routed automatically to the DHL backends that can answer it — you never say which. DHL's public tracking backends each see part of the network, and one parcel can cross several: a parcel sent from Germany to Spain shows only its announcement on the DHL Parcel gateway and the rest of its journey on DHL eCommerce Iberia. So a new code is looked up on every public backend at once, in parallel. Once one of them shows the parcel moving, only the backends that knew it are asked from then on. Their answers are combined: the one with the newest scan sets the status, the history holds the scans of all of them, and a field one backend lacks, such as the weight, comes from another.

Code shape Looked up on
3S…, JJD…, CR…/LX… (DHL Parcel barcodes) A keyless DHL Parcel gateway covering DHL's wider parcel network, not just Germany or the Netherlands; Mój DHL's public tracking; DHL eCommerce Iberia; DHL Paket Germany
A 10-digit DHL Express air waybill The DHL Express tracking backend; if Express does not know it, DHL Freight Sweden's public tracking (Mitt DHL) and DHL eCommerce Iberia
Any other 10-digit number (it fails the Express check digit) DHL Freight Sweden and DHL eCommerce Iberia — never the slow Express backend
Anything else, such as a 20-digit DHL Paket number (00340…) The DHL Parcel gateway, Mój DHL (codes of 11 characters or more), DHL eCommerce Iberia, DHL Freight Sweden (codes of 10 characters) and DHL Paket Germany (codes of 12 characters or more); only when none of them knows it, the DHL Express backend

If DHL Paket Germany cannot be reached, the log says so once and it is skipped until Home Assistant restarts; the other backends carry on. DHL Paket numbers can also be tracked with the API Tracking setup. A parcel DHL Paket Germany answers links to dhl.de's own tracking page.

A code that none of the backends knows yet logs one warning. A new label can take a while to appear at DHL; if the parcel stays unknown, check the code.

The DHL Express backend is intentionally slow to refresh — roughly once every 40 minutes per tracked Express code, shared across however many you track.

Options

Click Configure on the integration entry. An account hub shows one sectioned form; a tracking hub and an API Tracking entry show a menu:

Menu entry Option Default Description
Incoming parcels (tracking hub and API Tracking) Tracking codes — Add or remove the tracking codes of parcels you expect.
Outgoing parcels (tracking hub and API Tracking) Tracking codes — Add or remove the tracking codes of parcels you sent. They are counted on the outgoing sensors, not the incoming ones. Entering a code here that is filed as incoming moves it.
Settings Filter by / amount (Delivered parcels) last 7 days How long delivered parcels stay visible on the delivered sensor.
Settings Include status history (Parcel history) off Adds a history attribute per parcel with each status update.

Polling isn't one of these settings. An account hub polls on a dynamic, status-driven schedule (quiet overnight window, faster when a parcel is out for delivery); a tracking hub follows the same schedule for its DHL Parcel codes, with Express codes rationed separately as described above. An API Tracking entry follows the same schedule too, and stops polling once nothing is left in transit. See ARCHITECTURE.md for the details.

Removal

Standard HA removal applies: Settings → Devices & Services → DHL → ⋮ → Delete. Nothing is stored on DHL's side beyond the normal session your account already has.

Sensors

Entity Description
sensor.dhl_<hub>_incoming_parcels Number of active tracked parcels, full list under the parcels attribute
sensor.dhl_<hub>_parcel_<code> One per tracked parcel; state is the canonical status, attributes carry the full normalised parcel
sensor.dhl_<hub>_next_delivery Earliest expected delivery moment across all active parcels
sensor.dhl_<hub>_en_route_to_pickup_point Incoming parcels on their way to a pickup point that have not arrived yet
sensor.dhl_<hub>_awaiting_pickup Incoming parcels that are ready to collect at a pickup point
sensor.dhl_<hub>_delivered_parcels Recently delivered parcels (see the retention option)
sensor.dhl_<hub>_outgoing_parcels Number of active outgoing parcels, full list under the parcels attribute
sensor.dhl_<hub>_outgoing_delivered_parcels Recently delivered outgoing parcels (see the retention option)
calendar.dhl_<hub>_deliveries Read-only calendar of expected deliveries, no extra API calls
sensor.dhl_<hub>_last_successful_update Diagnostic: when DHL was last polled successfully

A delivered parcel moves from its per-parcel sensor to the delivered sensor automatically.

Outgoing parcels are shipments DHL reports as sent by your account rather than to it — DHL exposes this as a sendungsrichtung field (ANKOMMEND/EINGEHEND incoming, ABGEHEND outgoing) on the same account-inbox listing incoming parcels come from, no separate endpoint. Their canonical status always reports unknown: the 0-5 progress ladder below was only ever confirmed against incoming shipments, so guessing what it means for an outgoing one isn't done — the raw DHL status text is still available as raw_status.

On a tracking hub DHL's tracking data cannot tell a parcel you sent from one you receive, so you choose: a code filed under Outgoing parcels is counted on the outgoing sensors and fires the outgoing events, with its normal status.

Stops away (DHL Germany)

While a German parcel is out for delivery, DHL's live tracking can count the driver's remaining stops. The parcel sensor carries that as raw.stops_away, for example for a notification when the driver is close:

triggers:
  - trigger: template
    value_template: >-
      {{ (state_attr('sensor.dhl_<hub>_parcel_<code>', 'raw') or {}).get('stops_away') in [1, 2, 3] }}
  • DHL gives an exact number only near the end ("Nur noch 2 Zustellstopps"). Further away it says "more than 10/20/…/50"; stops_away is then that number and raw.stops_away_is_minimum is true.
  • Only when DHL unlocks live tracking. DHL's website shows it once the recipient's postal code is entered, which this integration cannot send. A parcel looked up by number, or one in your account that is addressed to someone else, stays locked, and stops_away is then null. Whether DHL unlocks it for parcels addressed to the account holder has not been seen yet; the first stop count logs a warning asking you to confirm it.
  • It is as fresh as the last poll.

Next expected update

The diagnostic Next expected update sensor estimates when the next automatic refresh is due, so a dashboard can tell current data from a stalled integration. It is unknown when polling is disabled or before the first successful poll; allow a small grace period, since the time is an estimate.

Parcel status reference

The status field is the carrier-agnostic enum shared by the whole integration family, and its exact source depends on which DHL backend produced a given parcel.

Account (Germany). DHL Germany reports a coarse 0-5 progress ladder rather than a status vocabulary, so the mapping below is what that ladder can express, plus a Packstation arrival read from the parcel's delivery details. A Filiale arrival cannot currently be told apart from an ordinary "out for delivery" (see Troubleshooting).

Status Meaning
registered Label created / picked up by DHL
in_transit In DHL's network
out_for_delivery On a delivery vehicle today
at_pickup_point Ready to collect in a Packstation, or at a Filiale or Paketshop when DHL's text says so
delivered Delivered
returning DHL reports the shipment as a return
problem Not currently distinguishable — see Troubleshooting
unknown A progress value we have not mapped yet

Tracking codes — DHL Parcel gateway. The event category behind a barcode maps as: DATA_RECEIVED → registered, UNDERWAY → in_transit, IN_DELIVERY → out_for_delivery, PROBLEM → problem, DELIVERED → delivered; a RETURNED_TO_SHIPPER event maps to returning regardless of category. at_pickup_point is not currently mapped on this backend. Anything else falls back to unknown.

Tracking codes — DHL Express. DELIVERED maps to delivered. Before delivery the status follows the newest checkpoint: Shipment is out with courier for delivery is out_for_delivery; Delivery attempt could not be completed, Delivery not accepted, Further consignee information needed and On hold awaiting for payment of shipment related fees are problem; Shipment information received is registered; Shipment Accepted, Shipment picked up, Processed at …, Arrived at DHL Sort Facility …, Arrived at DHL Delivery Facility …, Shipment has departed from a DHL facility …, Shipment is in transit to destination, Customs clearance status updated, Clearance processing complete at …, Payment is received and recorded for shipment related fees and Shipment is scheduled for delivery are in_transit. Any other checkpoint is in_transit while the estimated delivery date is still ahead, otherwise unknown. No pickup-point state has been observed on this backend yet. Checkpoint times are the local time of the DHL facility; they carry that country's time zone when it has only one, and no offset otherwise.

Tracking codes — DHL Freight Sweden. Follows Mitt DHL's own status card: a collected shipment is delivered, one waiting too long at the service point is returning, a stopped one is problem, and one ready for collection is at_pickup_point. Otherwise the newest event decides: OUT FOR DELIVERY is out_for_delivery, a drop-off at the service point or locker is at_pickup_point, a return is returning, and terminal and transport events are in_transit. A shipment without events is registered. pickup_point is the service point's name.

Tracking codes — DHL eCommerce Iberia. The newest scan decides: Out for delivery is out_for_delivery; Delivered to DHL ServicePoint is at_pickup_point; Delivered, Delivered, POD pending and Parcel picked up by recipient are delivered; Shipment being returned to sender is returning, and so is any movement after it; an absent consignee, a closed receiver, a postponed or delayed delivery, force majeure, special handling and an incident are problem; Shipment data received is registered; depot scans, drop-offs and agreed delivery dates are in_transit. A scan that is not mapped falls back to the one before it. pickup_point is the ServicePoint's name and weight is in kilograms; DHL Iberia does not always send either. Scan times are the local time in Spain or Portugal and carry no offset.

Tracking codes — DHL Paket Germany. Mapped exactly like a German account parcel (above).

Tracking codes — Mój DHL. Uses the same DHL Parcel Polska status codes as a Polish account: a delivered or collected parcel is delivered, one waiting in a locker or behind a notice is at_pickup_point, one handed to the courier is out_for_delivery, a return is returning, and delays and delivery problems are problem. This backend has no event log, so parcels found here have no history.

API Tracking. DHL's API reports a coarse status for every shipment: pre-transit → registered, transit → in_transit, delivered → delivered, failure → problem, unknown → unknown. The finer statuses (out_for_delivery, at_pickup_point, returning) are not mapped yet on this setup, because no real parcel has shown yet which DHL status text means what. Delivery times are shown exactly as DHL sends them, and weight is filled in, in kg, when DHL reports it.

The carrier's own human-readable text is always available as raw_status.

Events

The integration fires these on the event bus (also available as device triggers on the DHL device):

Event When
dhl_parcel_registered A new parcel appears in the active list
dhl_parcel_status_changed A parcel's canonical status changes (old_status / new_status in the payload), except the final hop to delivered
dhl_parcel_delivered A parcel is delivered
dhl_parcel_delivery_time_changed The expected delivery window changes
dhl_outgoing_parcel_status_changed An outgoing parcel's canonical status changes (old_status / new_status in the payload), except the final hop to delivered
dhl_outgoing_parcel_delivered An outgoing parcel is delivered

Every payload is the full normalised parcel plus the hub's device_id. Events are suppressed on the first refresh after start-up. There is no outgoing registered or delivery_time_changed event.

Services

Service Fields Description
dhl.track_parcel tracking_code, direction (optional, incoming by default), contents (optional), config_entry_id (optional) Track a parcel by its tracking number
dhl.untrack_parcel tracking_code, config_entry_id (optional) Stop tracking a manually-added parcel
dhl.update_contents tracking_code, contents (empty clears it), config_entry_id (optional) Set what is in a parcel, in your own words; goes to every entry that lists the code, or to the one named by config_entry_id; it titles the calendar event and shows on the next-delivery sensor

Both work on every kind of DHL entry. On an account, the number is tracked in addition to the account's own inbox, and direction is not used — the account knows it. On a tracking-codes or API entry, the number joins the same lists as Configure → Incoming parcels / Outgoing parcels; calling track_parcel again with the other direction moves it.

config_entry_id picks the entry. Without it, the call goes to your only DHL entry, or — with several — to your only DHL account. Any other setup needs it.

Examples

Ready-to-paste automations and dashboard snippets live in examples/, including tracking a new parcel straight from a dashboard.

Community Lovelace cards

Third-party cards that work with this integration's sensors:

Debugging

logger:
  default: warning
  logs:
    custom_components.dhl: debug

The diagnostics download is the preferred way to help. Go to Settings → Devices & Services → DHL → ⋮ → Download diagnostics. It is already redacted (names, addresses, tracking numbers, tokens) and safe to attach to a GitHub issue directly — it is the main way this pre-release gets finished, since nobody building it has a DHL parcel of their own.

Troubleshooting

  • A parcel shows unknown — DHL has not scanned it yet, or its progress value is one this integration has not mapped. Check the logs for a ready-to-paste issue link.
  • A parcel seems stuck on "out for delivery" — DHL's progress ladder has no value for "waiting at a Filiale", so that arrival is recognised from DHL's own wording ("zur Abholung bereit") and may be missed if DHL words it differently. (Packstation arrivals are recognised.) The log warns about a parcel that has been out for delivery for more than two days, which is the closest proxy there is. If this happens to you, please open an issue or attach a diagnostics export — this is the single most useful thing a tester can confirm right now.
  • Sensors go unavailable instead of dropping to zero — when DHL lists a parcel but will not hand over its details, the update is failed on purpose rather than reported as an empty account. That keeps a temporary glitch from looking like "all parcels delivered" and firing your automations. The next successful poll restores the sensors. A warning naming the number of affected parcels is written to the log.
  • Sign-in fails or the pasted link is rejected — make sure you copied the entire address after logging in, including everything after code=. Trailing characters get trimmed automatically, but a truncated copy will not.
  • Re-authentication is requested while everything looked fine — DHL sometimes hands back a refreshed session that is no longer linked to your account. It still works as a login, but your parcel list would stay empty, so the integration asks you to sign in again rather than showing nothing. Signing in restores the link.
  • Re-authentication is requested — DHL's session expired (they last about 30 minutes and are refreshed automatically in the background; this only triggers if the refresh itself is rejected). Repeat the sign-in step.
  • A tracking-code Express parcel barely updates — this is expected, not a bug; see Tracking codes for why. A DHL Parcel barcode (3S…/JJD…/CR…/LX…) updates on the normal cadence.
  • An API Tracking entry stops updating for a while — DHL has answered that the key's quota is used up. The entry keeps its last known data and tries again later; the log says so. Fewer tracked parcels in transit, or a key with a higher quota, avoids it.
  • An API Tracking entry asks for a new key — DHL rejected the stored key (it was revoked or deleted on developer.dhl.com). Paste a working one; the tracked parcels are kept.
  • A tracking code never resolves — double-check it against the shape table in Tracking codes. A code that matches none of the known DHL Parcel barcode families and isn't a 10-digit Express AWB is still tried on every backend in that table's last row. If none of them knows it, it stays unknown.

Related integrations

This integration is part of ha-parcel-integrations — a family of parcel-carrier integrations that all publish the same canonical parcel format, statuses and events.

Disclaimer

This is an independent, community-built project. It is not affiliated with, endorsed by, sponsored by, or supported by DHL, Home Assistant, or any other third party referenced in this project. Please don't contact DHL for support with this integration.

All third-party trademarks, trade names, product names, logos, and other brand assets are the property of their respective owners. References to them are solely to identify the relevant carrier or service and do not imply affiliation, sponsorship, or endorsement. Nothing in this project grants or implies any licence or right to use third-party brand assets.

This integration may rely on public, unofficial, or undocumented carrier interfaces, accessed with your own account or API key where required. These may change or be withdrawn without notice and may be subject to DHL's terms. Data is sent only to DHL's own services or those of its group; this project operates no servers of its own. You are responsible for ensuring that your use complies with applicable law and those terms. Use is at your own risk; see the licence for warranty limitations.

This integration uses the same account-inbox endpoint the DHL website uses once you are logged in. Your credentials never pass through this integration or any third party — sign-in happens directly in your own browser against DHL's own login page; only the resulting refresh token is stored in Home Assistant's own config-entry storage, the same way any other integration's credentials are.

Contributing

Pull requests and issues are welcome. Please open an issue before submitting a large change.

License

MIT

Releases

Sponsor this project

Used by

Contributors

Languages