PostNL Integration

Great suggestion! Will add it to the list and add the option very soon.

Got a lot of Unable to perform request b'{"message":"Profile [email protected] does not have validationfeature MyMailValidationCode","type":"ProfileValidationFeatureMissing","extraParams":null}' errors; obviously because this specific profile does not have the letter delivery preview. Did I miss an option to disable that feature for a specific account?

Thanks for your input! Could it be that you don’t have the letter functionality enabled? I didn’t had a test case, so I wasn’t sure how their API would respond.

I have 2-3 accounts for different people. One has letter access ‘at PostNL’, the others don’t.

Thanks! I’ll dive in to it in the upcoming days.

UPDATE

Just released 0.9.0. This contains several new functionalities:

  • Ability to hide the header
  • Ability to set the date format
  • Ability to set the time format
  • Ability to set how many days in the past you want to display

You can find the configuration instructions within the README of the github repository.

Note: To use some of the new features, you will need to include MomentJS.

resources:
  - url: https://unpkg.com/[email protected]/moment.js
    type: js
  - url: /customcards/postnl-card.js
    type: module
1 Like

This is amazing, great job. Will update and test it!

2 things I forgot to mention. (It was already late ;))

Date and time formatting options can be found here;
https://momentjs.com/docs/#/displaying/format/

I am aware that currently the delivery and or letter headers stay when there is nothing. This requires a bigger instance which I will do later.

I am also not sure if I should filter on component or card level.

UPDATE

Small rewrite of some code. Please let me know if something doesn’t work for you anymore, since I was unable to test the letters.

0.9.1:

  • Sections are no longer displayed if there is nothing
  • Packages / letters en route will now show “today” or “tomorrow” rather then the date
  • Small warning at the bottom to include MomentJS since it seriously degrades the functionality of the card at this point.

Next up:

  • Figuring out if we can handle translations in custom cards
  • Sort the order of packages at Component side rather than Lovelace side

Wishlist:

  • Image carousel through letters

If I missed something, feel free to create an issue on Github.

After the last update (updated with custom updater) the card doesn’t show anymore (I used a pop up card) it just shows the original more-info now. Will try again tonight.

Edit: nvm, after the update from 2 hours ago it is working again!

Yeah I had the same issue :wink: 0.9.3 should fix that as you noticed :slight_smile:

I got an infinite loop with letters.

This is my config:
date_format: DD MMM YYYY
delivery: sensor.postnl_delivery
distribution: sensor.postnl_distribution
hide:
delivered: true
first_letter: false
header: false
letters: sensor.postnl_letters
past_days: 5
time_format: ‘HH:mm’
type: ‘custom:postnl-card’

Thanks for reporting! Should be fixed in 0.9.4, which is now available.

1 Like

Thanks! Looks like that fixed it :smile:

1 Like

great work, I would like to use this very hard, but have a little problem.
My system is a docker with hassio.
I have the default postnl default component setup as:
sensor:

  • platform: postnl
    username: !secret postnl_username
    password: !secret postnl_password

Then I followed you tutorial but i got the message that i cannot find the 3 sensors.

I setup the custom component, use updater to use the latest script version.
I also tried to disable the default postnl sensor, but didn’t know where to put my username and password then. What do I miss here?

You don’t need to “disable” the official component. Just make sure you put these 3 files in custom_components.

All configuration in sensor.yaml (or configuration.yaml if you did not split the files) will stay the same.

Edit: make sure you open the actual page to the code, the code on this forum is truncated. If you copied the code from this thread alone it will probably not work as it is only half of it.

1 Like

I have not disabled my splitted config now, and I doubled check my user/pass.

logging say:

Log Details (ERROR)
Wed May 15 2019 20:04:20 GMT+0200 (Midden-Europese zomertijd)
postnl: Error on device update!
Traceback (most recent call last):
File “/usr/local/lib/python3.7/site-packages/homeassistant/helpers/entity_platform.py”, line 261, in _async_add_entity
await entity.async_device_update(warning=False)
File “/usr/local/lib/python3.7/site-packages/homeassistant/helpers/entity.py”, line 377, in async_device_update
await self.hass.async_add_executor_job(self.update)
File “/usr/local/lib/python3.7/concurrent/futures/thread.py”, line 57, in run
result = self.fn(*self.args, **self.kwargs)
File “/config/custom_components/postnl/sensor.py”, line 93, in update
shipments = self._api.get_delivery()
File “/config/deps/lib/python3.7/site-packages/postnlpy/postnlapi.py”, line 106, in get_delivery
self.update()
File “/config/deps/lib/python3.7/site-packages/postnlpy/postnlapi.py”, line 77, in update
self.update_packages()
File “/config/deps/lib/python3.7/site-packages/postnlpy/postnlapi.py”, line 92, in update_packages
self._delivery[package[‘key’]] = Package(package)
File “/config/deps/lib/python3.7/site-packages/postnlpy/items/package.py”, line 11, in init
self.planned_date = data.get(‘status’).get(‘enroute’).get(‘timeframe’).get(‘date’)
AttributeError: ‘NoneType’ object has no attribute ‘get’

That seems to be an error that I need to fix. Will check :slight_smile:

1 Like

let me know if there is something you need to know or that I must test for you.

Yes, please update the component files with this version:

Also @Saturnus, please do the same. Update the component files with the files above.
I believe it fixes both your problems.