Home Assistant Community

Lovelace: PostNL

#1

So, based on the long conversations already going about the PostNL component, I decided to see if I could change the current component to;

  1. Have more information available: Packages you are retrieving. Packages you are submitting. Post you are receiving.
  2. Have a custom Lovelace card available to show all the information
  3. Resolve some bugs

Installation Instructions

To have full freedom to be able to adept everything to my wishes, I created a new package and thus a new component. So it’s a kinda cumbersome process, but perhaps everything can be become part of Home Assistant eventually.

Add the following 3 files to /custom_components/postnl/:

You can keep the same configuration for PostNL as you had before, or just follow the instructions as written on the documentation page:

Restart Home Assistant afterwards. It should now use this component and you should have 3 sensors:
sensor.postnl_letters
sensor.postnl_delivery
sensor.postnl_distribution

Next, you can follow the instructions as described here to add the Lovelace card:

Helpful information

  • You don’t have to fill in the delivery, distribution or letter sensor
  • You can click on the title to get to the PostNL web interface or to see the image of the letter

Untested

  • When you didn’t configure the letters in PostNL

7 Likes
#2

I think this is already looking very good! Going to use it for sure when realeased for public!

Great job

#3

Always like new features. Looks nice.

That said, i’ll be ‘frank’. I never open the post nl app to see what envelopes i am getting. It is nice that it could show it but it takes up a lot of screen. Would at least seperate the 2, 1 card for mail and 1 card for packages. That way it doesn’t matter what the preference is of a person since he can choose both if he/she wants too (or 1 card that does it all)

For the packages an option how many delivered packages it would show is a nice bonus.

And i presume to far fetched but what about an option that it counts the number of mail items untill a reset is given? So if you could have a sensor that just adds up the number of mail, that way you can automate your mailbox further (most have a sensor in the mail to trigger it) but now you could even say “you have more then 5 mail items in your box, it really is time to empty it” just thinking out loud here :wink:
(I actually have a mailbox outside, doesn’t really matter for the people where the mail drops in the house)

#4

Thanks for the input! I had the same feeling with the images.

Already changed some stuff. I’m now waiting for the 0.92 release of HA, since I am overwriting the current component to achieve my results and they made some changes in this release. After that, I have a guide on how to achieve the Lovelace card. Depending on input, I can perhaps override the current component with my component, so you only need to install the lovelace card.

Meanwhile, I am also waiting for a package or mail to arrive. Since I currently have to work with delivered packages and an empty mailbox, which makes it hard to test :frowning:

#5

Well if you want a mail card, just private message your address. Least i can do ha :wink:

#6

Awaiting the 0.92 release (should be available today) to create instructions to have more people test this.

If you click on the ID of the letter, you get to see the image.
If you click on the name of the package, you are taken to the web interface of PostNL itself.

#7

Hi Peter, in case you need more beta testers, I’m gladly to help. Regards, Ramon

#8

Yeah definetly need testers. Will post instructions tomorrow!

Thanks!

1 Like
#9

Topic description has been updated! Hope it contains enough information for you guys to know what to do.

Happy to hear your thoughts and feedback. Also see the list of known issues and upcoming features.

Best to report features and bugs within the Github repository for easy tracking.

Thanks!

#10

Made an issue, if your on discord could just look into it but don’t know your nick there.

#11

Solved some issues with help from @riemers.
Custom component as well as the lovelace card have been updated.

#12

Hi i’m getting the following error:

[homeassistant.components.sensor] Error while setting up platform postnl_custom Traceback (most recent call last): File "/usr/src/app/homeassistant/helpers/entity_platform.py", line 126, in _async_setup_platform SLOW_SETUP_MAX_WAIT, loop=hass.loop) File "/usr/local/lib/python3.7/asyncio/tasks.py", line 416, 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/postnl_custom/sensor.py", line 34, in setup_platform from postnlpy.postnlapi import PostnlApi ModuleNotFoundError: No module named 'postnlpy'

I’m running version 0.92 in a docker container.

#13

I’ve updated the gist by adding a manifest.json file. This is now a requirement as of HA 0.92.

After restart, It should work.

#14

Thanks alot @ptnijssen! Wish I could tell you that it fixed the issue. But I get a different error now…:frowning:

Traceback (most recent call last):
File “/usr/src/app/homeassistant/helpers/entity_platform.py”, line 261, in _async_add_entity
await entity.async_device_update(warning=False)
File “/usr/src/app/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 “/usr/src/app/homeassistant/util/init.py”, line 224, in wrapper
result = method(*args, **kwargs)
File “/config/custom_components/postnl/sensor.py”, line 92, in update
shipments = self._api.get_package_deliveries(True)
File “/config/deps/lib/python3.7/site-packages/postnlpy/postnlapi.py”, line 114, in get_package_deliveries
self.update()
File “/config/deps/lib/python3.7/site-packages/postnlpy/postnlapi.py”, line 79, in update
self.update_letters()
File “/config/deps/lib/python3.7/site-packages/postnlpy/postnlapi.py”, line 105, in update_letters
document_id = documents.get(‘documents’)[0].get(‘documentId’)
IndexError: list index out of range
2019-04-27 07:07:15 ERROR (MainThread) [homeassistant.components.sensor] postnl: Error on device update!
Traceback (most recent call last):
File “/usr/src/app/homeassistant/helpers/entity_platform.py”, line 261, in _async_add_entity
await entity.async_device_update(warning=False)
File “/usr/src/app/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 “/usr/src/app/homeassistant/util/init.py”, line 224, in wrapper
result = method(*args, **kwargs)
File “/config/custom_components/postnl/sensor.py”, line 140, in update
letters = self._api.get_letters()
File “/config/deps/lib/python3.7/site-packages/postnlpy/postnlapi.py”, line 132, in get_letters
self.update()
File “/config/deps/lib/python3.7/site-packages/postnlpy/postnlapi.py”, line 79, in update
self.update_letters()
File “/config/deps/lib/python3.7/site-packages/postnlpy/postnlapi.py”, line 105, in update_letters
document_id = documents.get(‘documents’)[0].get(‘documentId’)
IndexError: list index out of range

Could this be an user error on my side? Running version 92.1 now.

#15

Seems like something I need to fix. I suppose not every letter has an image or the API is not giving a good response.

Let me try to fix something over here. Will report back in half an hour.

#16

Thanks. Take your time.

#17

I’ve updated the custom component. Please see the change in the gist. (Basically change the dependency to 0.2.4).

Either it’s solved, or you will have a very similar error. I aim for the first case :wink:

1 Like
#18

Thank you for the quick fixes! It works now :smiley:

1 Like
#19

very nice!! maybe it’s an idea to add it into the custom updater? so we can update the component and the card very easy. and never miss some work of you :slight_smile:

#20

Thanks Remco!
I’ve already marked it as an thing to do: https://github.com/peternijssen/lovelace-postnl/issues/5

In the end, I also want to update the component in HA. Just making sure it’s now feature complete and it’s working for everyone, before breaking stuff :wink:

2 Likes