PostNL Integration

Update

Just released 0.12.0

  • Ability to swipe through letter images
  • Bugfix when setting past days to 0

I’ve noticed the card is relatively big in regards to bytes. Just figuring out why this is and will try to make it smaller.
Also not sure if the swiper completely works perfect. So hoping to get some input from you guys.

@ptnijssen

I just installed v0.12.0 using HACS and now i’m getting error messages in the Javascript console. It looks like an issue with the swiper.

postnl-card.js:4631 Uncaught (in promise) TypeError: Cannot read property 'constructor' of null
    at new Ta (postnl-card.js:4631)
    at HTMLElement._initialLoad (postnl-card.js:7799)

Line 7799 of the JS file contains:
await this.updateComplete, this.swiper = new Ta(this.shadowRoot.querySelector(".swiper-container"));

The previous version (0.10.0) worked without any problems.

For HACS users it will serve up a compressed version that is a lot smaler :slight_smile:
image

How would I go about adding two accounts into this card without duplicating the information (ie, not having a second card for the second person)?
Because there are two people in my house have an account, the information is user specific, so I’d like to add both accounts into the one view.

Also, any idea why two of my icons are repeating but with no data?

Lastly, I have a “Retourzending” which seems to be stuck under the “Enroute”, but is delivered, any way I can hide this?
“type”: “Receiver”,
“status”: “Delivered”,
“status_message”: “Retourzending overgedragen aan afzender”,
“delivery_date”: null,
“planned_date”: null,
“planned_from”: null,
“planned_to”: null,

@Zisla_Taranta That is strange :frowning: I will try locally to reinstall and see if I have the same problem.

@Veldkornet
The repeating is because of deliveries and distributions. If you never send packages, you can remove the distributions from it. Else for now, you have to keep in mind the first 2 are deliveries, the other 2 are distributions. I will have a look if I can make that more clear.

In regards of the one you are sending back, I think that is a bug in my system since the status is “delivered”. I will have a look.

In regards of combining two accounts, that ain’t possible at this point. If there are more people having this issue then I will have a look if that can be solved. As a potential work-around, what you could do is use the pop-up card in between with 2 separate buttons, that pop-up either one of both cards.

@ludeeus awesome!
However, if I just compare the bundles from kalkih and mine, I just see an increase of 300% which I just don’t get. Guess my front-end knowledge is not big enough.


Can anyone help with an automation which will just send a message if a package is “registered” which lets you know the relevant details of that package?

I’m not getting it quite right, I think mostly because if I look in the sensor page, the sensor looks like this by the attributes:
enroute: [object Object],[object Object]

So I’ve been trying to call them like this:
{{ states.sensor.postnl_delivery.state.attributes.enroute[0]['id'] }}

But then I get the below…
Error while executing automation automation.postnl. Error rendering template for call_service at pos 1: UndefinedError: 'str object' has no attribute 'attributes'

@ptnijssen I also noticed that my letter images take some time to load (or never load), it looks like the below. However, if I right click on that red, white, blue thing, and say open image in new tab, it shows instantly. Actually, I’ve notice that the image is there, it’s just compressed into a very tiny long space. I can drag that image, and then I start to see pieces of the image, like a peekable scroll bar thing.
image

Nice improvements.

But everytime I start up I get the following error:

Jul 11 23:23:51 osmc hass[23299]: Traceback (most recent call last):
Jul 11 23:23:51 osmc hass[23299]:   File "/srv/homeassistant/lib/python3.7/site-packages/homeassistant/helpers/entity_platform.py", line 261, in _async_add_entity
Jul 11 23:23:51 osmc hass[23299]:     await entity.async_device_update(warning=False)
Jul 11 23:23:51 osmc hass[23299]:   File "/srv/homeassistant/lib/python3.7/site-packages/homeassistant/helpers/entity.py", line 377, in async_device_update
Jul 11 23:23:51 osmc hass[23299]:     await self.hass.async_add_executor_job(self.update)
Jul 11 23:23:51 osmc hass[23299]:   File "/usr/local/lib/python3.7/concurrent/futures/thread.py", line 57, in run
Jul 11 23:23:51 osmc hass[23299]:     result = self.fn(*self.args, **self.kwargs)
Jul 11 23:23:51 osmc hass[23299]:   File "/home/homeassistant/.homeassistant/custom_components/postnl/sensor.py", line 201, in update
Jul 11 23:23:51 osmc hass[23299]:     self._attributes['enabled'] = self._api.is_letters_activated()
Jul 11 23:23:51 osmc hass[23299]: AttributeError: 'PostnlApi' object has no attribute 'is_letters_activated'

The letters sensor is also not available after start up. Even re-registered for viewing letters, but that did not solve anything.

1 Like

Hi Peter,

Kudos for making a better version of the postnl component.
I migrated from the standard version to yours via HACS, but after several reboots I can still only see the default sensor (so only 1 is visible).

I installed it via HACS.
I edited the lovelaceui file.

Do I need to edit any more?

Hello,

I’m very interested in this topic. I tried to install the custom card but I failed. I installed HACS and added the postnl plugin. I added the sensor quote in my config.yaml and added the custom card in lovelaceui. But it stays empty and the sensor stays on 0. even with history on.

can anyone provide a bit help?

1 Like

Got exacly the same, triple checked my config, instaled with HACS

Have the standard PostNL card working. But dont see see any other post sensors…

resources:

  - type: module
    url: /community_plugin/lovelace-postnl-card/postnl-card.js

Custome card:

type: 'custom:postnl-card'
delivery: sensor.postnl_delivery
distribution: sensor.postnl_distribution
letters: sensor.postnl_letters
hide:
  delivered: false
  first_letter: false
  header: false
date_format: DD MMM YYYY
time_format: 'HH:mm'
past_days: 1

this is what I have and it is working right now…

config.yaml

sensor:
  - platform: postnl
    username: '!secret username'
    password: '!secret pass'

Lovelaceui

date_format: DD MMM YYYY
delivery: sensor.postnl_delivery
distribution: sensor.postnl_distribution
hide:
  delivered: false
  first_letter: false
  header: false
letters: sensor.postnl_letters
past_days: 10
time_format: 'HH:mm'
type: 'custom:postnl-card'
resources:
  - type: module
    url: /community_plugin/lovelace-postnl-card/postnl-card.js

hope I helped you…

Double checked everything but installation via HACS doesn’t work.

Have you also installed the Post NL custom component as mentioned in the start post?

i am not getting the:
sensor.postnl_letters
sensor.postnl_delivery
sensor.postnl_distribution

Have installed via hacs multiple times, and tipple checked files. Resources are also good because the card works but i only see the titel and no info beneath. But the 3 sensors just dont appear:(

Through HACS you can only install the Lovelace card. You need the custom Post NL component mentioned in the start post too.

1 Like

Well damn thats the problem haha, feel like such a noob now lol. Thanks!
Only the Letter component is not showing now… copied the raw file from the postnl custom pomponent to be sure i did not miss a line of code

Solved this issue. Somehow the manifest file still referred to an older version of the dependency.

Hi,

since 0.96 my postnl custom sensor is not working anymore. I will not get the 3 sensors.

This is the error:

Traceback (most recent call last):
File “/usr/src/app/homeassistant/helpers/entity_platform.py”, line 126, in _async_setup_platform
SLOW_SETUP_MAX_WAIT)
File “/usr/local/lib/python3.7/asyncio/tasks.py”, line 442, in wait_for
return fut.result()
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/post/sensor.py”, line 34, in setup_platform
from postnlpy.postnlapi import PostnlApi
ModuleNotFoundError: No module named ‘postnlpy’

Do you have any idea? Maby the python update?

edit: I had the custom postnl sensor in a folder called post. Changed this to postnl and seems working now

Hi all,

Sorry for not replying earlier. Holiday period :wink:

I am currently updating to 0.96.X to see if everything is running at my side. I am not sure if there still are any more issues from other people?

Also I am in the works of updating the original library, after which I will update the component in Home Assistant itself, which removes the custom component. Just waiting for the original author to review my pull request for the library:

If you come across bugs or issues, best to report the on Github, because it makes it easier for me to track them.

All seems to be working on my end with the latest release of HA.
If anyone is still experiencing issues, please let me know.

This thread can be confusing, so you can also;

1 Like