PostNord delivery dates in Home Assistant

Home Assistant, PostNord, YAML

I live in Sweden, and the postal service PostNord only delivers post every other day or so. Instead of trying to learn the schedule or just checking PostNord’s website if I’m curious, we are going to poll their API and have a template sensor to automagically update itself depending on the API reply.

The API returns a strange date format in Swedish (“18 mars, 2024”, which is non-standard), and Home Assistant’s template engine runs in en_US so it can’t parse this date. Below hacks around it.

The snippet is stolen from this gist. Thank you tubalainen! (also, great name)

  - platform: template
        friendly_name: "Kommer posten idag"
        value_template: >-
          {{ (state_attr('sensor.postnord_utdelning', 'delivery').split(' ')[0] | int) == now().day }}          
  - platform: rest
    name: "PostNord Utdelning"
    scan_interval: 14400 # 4 hours
    resource: # <-- change me!
    value_template: "{{ }}"
      - "delivery"
      - "upcoming"
      - "city"
      - "postalCode"