DHL Packstation Rest Sensor für Home Assistant

Lass dir die Auslastung oder Verfügbarkeit deiner Packstation in Home Assistant anzeigen.
Dank der zugänglichen DHL API ist es kein Problem die Daten innerhalb in Home Assistant zu verarbeiten.
Die Daten werden per Restful Sensoren abgeholt, pro Tag wird ein Sensor angelegt.

Ihr benötigt lediglich einen Account unter https://developer.dhl.com und einen API Key. Anschließend könnt ihr die ID der Packstation per Location Endpoint abfragen.

Wahlweise können diese angezeigt pro Tag angezeigt werden, oder innerhalb einer Mushroom Template Card nur den heutigen Tag angezeigt werden.

Nutzt gerne die Möglichkeiten innerhalb von Github und optimiert meine ersten Versuche die Daten möglichst kompakt und dynamisch anzuzeigen.

Viel Spaß mit der Nutzung. Und danke an DHL für die API die der Öffentlichkeit zur Verfügung steht.



Mushroom Template Card:

#Dashboard Cards

type: entities
entities:
  - entity: sensor.dhl_packstation_monday
  - entity: sensor.dhl_packstation_tuesday
  - entity: sensor.dhl_packstation_wednesday
  - entity: sensor.dhl_packstation_thursday
  - entity: sensor.dhl_packstation_friday
  - entity: sensor.dhl_packstation_saturday
  - entity: sensor.dhl_packstation_sunday
title: Packstation Auslastung
state_color: true


type: custom:mushroom-template-card
primary: Auslastung Packstation 
secondary: "\n            {% if 'monday' ==  now().strftime('%A')|lower   %}  \n            {{states(\"sensor.dhl_packstation_monday\")}}\n            {% elif 'tuesday' ==  now().strftime('%A')|lower   %}  \n            {{states(\"sensor.dhl_packstation_tuesday\")}}\n            {% elif 'wednesday' ==  now().strftime('%A')|lower   %}  \n            {{states(\"sensor.dhl_packstation_wednesday\")}}\n            {% elif 'thursday' ==  now().strftime('%A')|lower   %}  \n            {{states(\"sensor.dhl_packstation_thursday\")}}\n            {% elif 'friday' ==  now().strftime('%A')|lower   %}  \n            {{states(\"sensor.dhl_packstation_friday\")}}   \n            {% elif 'saturday' ==  now().strftime('%A')|lower   %}  \n            {{states(\"sensor.dhl_packstation_saturday\")}}     \n            {% elif 'sunday' ==  now().strftime('%A')|lower   %}  \n            {{states(\"sensor.dhl_packstation_sunday\")}}    \_\n            {% endif %}"
icon: mdi:mail
tap_action:
  action: more-info
icon_color: |2-
              {% if 'monday' ==  now().strftime('%A')|lower and is_state('sensor.dhl_packstation_monday', 'Sehr Hoch')   %}  
              red
              {% elif 'monday' ==  now().strftime('%A')|lower and is_state('sensor.dhl_packstation_monday', 'Hoch')   %}  
              orange
              {% elif 'monday' ==  now().strftime('%A')|lower and is_state('sensor.dhl_packstation_monday', 'Niedrig')   %}  
              green
              {% elif 'tuesday' ==  now().strftime('%A')|lower and is_state('sensor.dhl_packstation_tuesday', 'Sehr Hoch')   %}  
              red
              {% elif 'tuesday' ==  now().strftime('%A')|lower and is_state('sensor.dhl_packstation_tuesday', 'Hoch')   %}  
              orange
              {% elif 'tuesday' ==  now().strftime('%A')|lower and is_state('sensor.dhl_packstation_tuesday', 'Niedrig')   %}  
              green
              {% elif 'wednesday' ==  now().strftime('%A')|lower and is_state('sensor.dhl_packstation_wednesday', 'Sehr Hoch')   %}  
              red
              {% elif 'wednesday' ==  now().strftime('%A')|lower and is_state('sensor.dhl_packstation_wednesday', 'Hoch')   %}  
              orange
              {% elif 'wednesday' ==  now().strftime('%A')|lower and is_state('sensor.dhl_packstation_wednesday', 'Niedrig')   %}  
              green
   
              {% elif 'thursday' ==  now().strftime('%A')|lower and is_state('sensor.dhl_packstation_thursday', 'Sehr Hoch')   %}  
              red
              {% elif 'thursday' ==  now().strftime('%A')|lower and is_state('sensor.dhl_packstation_thursday', 'Hoch')   %}  
              orange
              {% elif 'thursday' ==  now().strftime('%A')|lower and is_state('sensor.dhl_packstation_thursday', 'Niedrig')   %}  
              green
   
              {% elif 'friday' ==  now().strftime('%A')|lower and is_state('sensor.dhl_packstation_friday', 'Sehr Hoch')   %}  
              red
              {% elif 'friday' ==  now().strftime('%A')|lower and is_state('sensor.dhl_packstation_friday', 'Hoch')   %}  
              orange
              {% elif 'friday' ==  now().strftime('%A')|lower and is_state('sensor.dhl_packstation_friday', 'Niedrig')   %}  
              green
   
              {% elif 'saturday' ==  now().strftime('%A')|lower and is_state('sensor.dhl_packstation_saturday', 'Sehr Hoch')   %}  
              red
              {% elif 'saturday' ==  now().strftime('%A')|lower and is_state('sensor.dhl_packstation_saturday', 'Hoch')   %}  
              orange
              {% elif 'saturday' ==  now().strftime('%A')|lower and is_state('sensor.dhl_packstation_saturday', 'Niedrig')   %}  
              green
   
              {% elif 'sunday' ==  now().strftime('%A')|lower and is_state('sensor.dhl_packstation_sunday', 'Sehr Hoch')   %}  
              red
              {% elif 'sunday' ==  now().strftime('%A')|lower and is_state('sensor.dhl_packstation_sunday', 'Hoch')   %}  
              orange
              {% elif 'sunday' ==  now().strftime('%A')|lower and is_state('sensor.dhl_packstation_sunday', 'Niedrig')   %}  
              green
              {% endif %}
picture: ''
fill_container: true
layout: vertical
multiline_secondary: true

Configuration.yaml

rest:
  - resource: 'https://api.dhl.com/location-finder/v1/locations/888-location-id'
    scan_interval: 240
    headers:
      DHL-API-Key: your-api-key
    sensor:
      - name: "DHL Packstation Monday"
        value_template: >-
            {% if value_json.averageCapacityDayOfWeek[0].capacity == 'very-low'  %}  
            Sehr Hoch
            {% elif value_json.averageCapacityDayOfWeek[0].capacity == 'low'   %}  
            Hoch
            {% elif value_json.averageCapacityDayOfWeek[0].capacity == 'high'   %}   
            Niedrig
            {% else %}  
            Unbekannt    
            {% endif %}
        unique_id: dhl_packstation_penny_monday
      - name: "DHL Packstation Tuesday"
        value_template: >-
            {% if value_json.averageCapacityDayOfWeek[1].capacity == 'very-low'  %}  
            Sehr Hoch
            {% elif value_json.averageCapacityDayOfWeek[1].capacity == 'low'   %}  
            Hoch
            {% elif value_json.averageCapacityDayOfWeek[1].capacity == 'high'   %}   
            Niedrig
            {% else %}  
            Unbekannt    
            {% endif %}
        unique_id: dhl_packstation_penny_tuesday
      - name: "DHL Packstation Wednesday"
        value_template: >-
            {% if value_json.averageCapacityDayOfWeek[2].capacity == 'very-low'  %}  
            Sehr Hoch
            {% elif value_json.averageCapacityDayOfWeek[2].capacity == 'low'   %}  
            Hoch
            {% elif value_json.averageCapacityDayOfWeek[2].capacity == 'high'   %}   
            Niedrig
            {% else %}  
            Unbekannt    
            {% endif %}
        unique_id: dhl_packstation_penny_wednesday
      - name: "DHL Packstation Thursday"
        value_template: >-
            {% if value_json.averageCapacityDayOfWeek[3].capacity == 'very-low'  %}  
            Sehr Hoch
            {% elif value_json.averageCapacityDayOfWeek[3].capacity == 'low'   %}  
            Hoch
            {% elif value_json.averageCapacityDayOfWeek[3].capacity == 'high'   %}   
            Niedrig
            {% else %}  
            Unbekannt    
            {% endif %}
        unique_id: dhl_packstation_penny_thursday
      - name: "DHL Packstation Friday"
        unique_id: dhl_packstation_penny_friday
        value_template: >-
            {% if value_json.averageCapacityDayOfWeek[4].capacity == 'very-low'  %}  
            Sehr Hoch
            {% elif value_json.averageCapacityDayOfWeek[4].capacity == 'low'   %}  
            Hoch
            {% elif value_json.averageCapacityDayOfWeek[4].capacity == 'high'   %}   
            Niedrig
            {% else %}  
            Unbekannt    
            {% endif %}
      - name: "DHL Packstation Saturday"
        value_template: >-
            {% if value_json.averageCapacityDayOfWeek[5].capacity == 'very-low'  %}  
            Sehr Hoch
            {% elif value_json.averageCapacityDayOfWeek[5].capacity == 'low'   %}  
            Hoch
            {% elif value_json.averageCapacityDayOfWeek[5].capacity == 'high'   %}   
            Niedrig
            {% else %}  
            Unbekannt    
            {% endif %}
        unique_id: dhl_packstation_penny_saturday
      - name: "DHL Packstation Sunday"
        value_template: >-
            {% if value_json.averageCapacityDayOfWeek[6].capacity == 'very-low'  %}  
            Sehr Hoch
            {% elif value_json.averageCapacityDayOfWeek[6].capacity == 'low'   %}  
            Hoch
            {% elif value_json.averageCapacityDayOfWeek[6].capacity == 'high'   %}   
            Niedrig
            {% else %}  
            Unbekannt    
            {% endif %}
        unique_id: dhl_packstation_penny_sunday

Das Gezeigte brachte mich ans Ziel - bin mir aber sicher, dass der ein oder andere eindeutiges Verbesserungspotential sehen kann :slight_smile:

6 „Gefällt mir“

Cool. Auf die Idee, dass ich auch die Packstationen in Home Assistant einbinden kann bin ich noch gar nicht gekommen. :slight_smile:

1 „Gefällt mir“

Hi, funktioniert dies bei euch noch? Ich habe es gerade eingerichtet leider scheint er den Api Key nicht sauber zu nutzen vermute ich?

2026-01-18 00:48:39.314 WARNING (MainThread) [homeassistant.components.rest.data] REST request to https://api.dhl.com/location-finder/v1/locations/8007-ZAHL returned status 401 with application/problem+json response: {„status“:401,„title“:„Unauthorized“,„detail“:„Access to the resource is not allowed.“}

- resource: ‚https://api.dhl.com/location-finder/v1/locations/8007-zahl

scan_interval: 240

headers:

  DHL-API-Key: IRkombitext3

Bei mir funktioniert es noch, gerade wieder frisch integriert:

Deine Zuordnung der Packstation scheint nicht richtig zu sein, sofern “ZAHL” nicht ersetzt wurde durch die tatsächliche ID deiner gewünschten Packstation.

1 „Gefällt mir“

wärst du so nett und würdest deine Codeschnipsel teilen.

Wo zahl steht, habe ich meine ID stehen.

Die Frage ist, ob hier was falsch ist?

den Wert von

API-KEY

trage ich doch in der yaml bei

- resource: ‚https://api.dhl.com/location-finder/v1/locations/8007-43816XXXX‘

scan_interval: 240

headers:

DHL-API-Key: IRc21XXXXXXXXXXXX3

ein oder?

Ich habe den Code exakt von oben übernommen.

So ist eigentlich korrekt würde ich sagen, ja.

rest:
  - resource: 'https://api.dhl.com/location-finder/v1/locations/8007-ZAHL'
    scan_interval: 240
    headers:
      DHL-API-Key: XXX
    sensor:

und die APIs sind die gleichen wie bei mir? @Thomas1509

Ich habe nur diese drinnen

Den yaml für das Kärtchen würd ich glatt nehmen :slight_smile:

das war der entscheidene Hinweis @Thomas1509 die API zu nehmen .

Habe ich wohl in der Anleitung von @Flotomation übersehen.

btw die Card würde ich auch gerne nehmen :slight_smile:

1 „Gefällt mir“
type: custom:stack-in-card
cards:
  - type: custom:mushroom-template-card
    primary: >
      {% set tage =
      ['Montag','Dienstag','Mittwoch','Donnerstag','Freitag','Samstag','Sonntag']
      %} Packstation {{ tage[now().weekday()] }}
    secondary: |
      {% if is_state('input_boolean.packstation_details', 'off') %}
        {# Text wenn zugeklappt: Status von heute #}
        {% set tage_id = ['montag','dienstag','mittwoch','donnerstag','freitag','samstag','sonntag'] %}
        {% set heute = states('sensor.dhl_packstation_' ~ tage_id[now().weekday()]) %}
        Status heute: {{ heute }} (Tippen für Details)
      {% else %}
        {# Text wenn aufgeklappt: Beste Tage finden #}
        {% set tage_kurz = ['Mo','Di','Mi','Do','Fr','Sa','So'] %}
        {% set tage_id = ['montag','dienstag','mittwoch','donnerstag','freitag','samstag','sonntag'] %}
        {% set ns = namespace(beste=[]) %}
        {% for i in range(7) %}
          {% if states('sensor.dhl_packstation_' ~ tage_id[i]) == 'Niedrig' %}
            {% set ns.beste = ns.beste + [tage_kurz[i]] %}
          {% endif %}
        {% endfor %}
        Beste Tage: {{ ns.beste | join(', ') if ns.beste | count > 0 else 'Alle voll' }}
      {% endif %}
    icon: mdi:package-variant-closed
    icon_color: >
      {% set tage_id =
      ['montag','dienstag','mittwoch','donnerstag','freitag','samstag','sonntag']
      %} {% set s = states('sensor.dhl_packstation_' ~ tage_id[now().weekday()])
      %} {% if s == 'Sehr Hoch' %} red {% elif s == 'Hoch' %} orange  {% elif s
      == 'Niedrig' %} green {% else %} grey {% endif %}
    tap_action:
      action: call-service
      service: input_boolean.toggle
      target:
        entity_id: input_boolean.packstation_details
  - type: conditional
    conditions:
      - entity: input_boolean.packstation_details
        state: "on"
    card:
      type: vertical-stack
      cards:
        - type: custom:mushroom-chips-card
          alignment: center
          card_mod:
            style: |
              ha-card {
                padding: 0px 0px 10px 0px;
              }
          chips:
            - type: template
              content: Mo
              icon: mdi:circle
              icon_color: >-
                {% if is_state('sensor.dhl_packstation_montag','Sehr Hoch')
                %}red{% elif is_state('sensor.dhl_packstation_montag','Hoch')
                %}orange{% elif
                is_state('sensor.dhl_packstation_montag','Niedrig') %}green{%
                else %}grey{% endif %}
              card_mod:
                style: >
                  ha-card { {{ 'border: 1px solid var(--primary-color)
                  !important; background: rgba(var(--rgb-primary-color), 0.1)
                  !important;' if now().weekday() == 0 }} }
            - type: template
              content: Di
              icon: mdi:circle
              icon_color: >-
                {% if is_state('sensor.dhl_packstation_dienstag','Sehr Hoch')
                %}red{% elif is_state('sensor.dhl_packstation_dienstag','Hoch')
                %}orange{% elif
                is_state('sensor.dhl_packstation_dienstag','Niedrig') %}green{%
                else %}grey{% endif %}
              card_mod:
                style: >
                  ha-card { {{ 'border: 1px solid var(--primary-color)
                  !important; background: rgba(var(--rgb-primary-color), 0.1)
                  !important;' if now().weekday() == 1 }} }
            - type: template
              content: Mi
              icon: mdi:circle
              icon_color: >-
                {% if is_state('sensor.dhl_packstation_mittwoch','Sehr Hoch')
                %}red{% elif is_state('sensor.dhl_packstation_mittwoch','Hoch')
                %}orange{% elif
                is_state('sensor.dhl_packstation_mittwoch','Niedrig') %}green{%
                else %}grey{% endif %}
              card_mod:
                style: >
                  ha-card { {{ 'border: 1px solid var(--primary-color)
                  !important; background: rgba(var(--rgb-primary-color), 0.1)
                  !important;' if now().weekday() == 2 }} }
            - type: template
              content: Do
              icon: mdi:circle
              icon_color: >-
                {% if is_state('sensor.dhl_packstation_donnerstag','Sehr Hoch')
                %}red{% elif
                is_state('sensor.dhl_packstation_donnerstag','Hoch') %}orange{%
                elif is_state('sensor.dhl_packstation_donnerstag','Niedrig')
                %}green{% else %}grey{% endif %}
              card_mod:
                style: >
                  ha-card { {{ 'border: 1px solid var(--primary-color)
                  !important; background: rgba(var(--rgb-primary-color), 0.1)
                  !important;' if now().weekday() == 3 }} }
            - type: template
              content: Fr
              icon: mdi:circle
              icon_color: >-
                {% if is_state('sensor.dhl_packstation_freitag','Sehr Hoch')
                %}red{% elif is_state('sensor.dhl_packstation_freitag','Hoch')
                %}orange{% elif
                is_state('sensor.dhl_packstation_freitag','Niedrig') %}green{%
                else %}grey{% endif %}
              card_mod:
                style: >
                  ha-card { {{ 'border: 1px solid var(--primary-color)
                  !important; background: rgba(var(--rgb-primary-color), 0.1)
                  !important;' if now().weekday() == 4 }} }
            - type: template
              content: Sa
              icon: mdi:circle
              icon_color: >-
                {% if is_state('sensor.dhl_packstation_samstag','Sehr Hoch')
                %}red{% elif is_state('sensor.dhl_packstation_samstag','Hoch')
                %}orange{% elif
                is_state('sensor.dhl_packstation_samstag','Niedrig') %}green{%
                else %}grey{% endif %}
              card_mod:
                style: >
                  ha-card { {{ 'border: 1px solid var(--primary-color)
                  !important; background: rgba(var(--rgb-primary-color), 0.1)
                  !important;' if now().weekday() == 5 }} }
            - type: template
              content: So
              icon: mdi:circle
              icon_color: >-
                {% if is_state('sensor.dhl_packstation_sonntag','Sehr Hoch')
                %}red{% elif is_state('sensor.dhl_packstation_sonntag','Hoch')
                %}orange{% elif
                is_state('sensor.dhl_packstation_sonntag','Niedrig') %}green{%
                else %}grey{% endif %}
              card_mod:
                style: >
                  ha-card { {{ 'border: 1px solid var(--primary-color)
                  !important; background: rgba(var(--rgb-primary-color), 0.1)
                  !important;' if now().weekday() == 6 }} }

Mittels Helfer (input_boolean.packstation_details) wird das auf-/ und zuklappen gesteuert.

1 „Gefällt mir“

Spannendes Projekt! Sind das Live-Auslastungen oder nur Durchschnittswerte?