PostNL sensor stopped working

Suddenly the PostNL sensor stopped working, don’t remember exactly since which version, but I didn’t change anything in de PostNL config part and authentication on the postnl website with the same credentials still work. Anyone has an idea why I get this error?

Log Details (ERROR)

Tue Jan 07 2020 14:39:00 GMT+0100 (Central European Standard Time)
Can't connect to the PostNL webservice
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/postnl_api/postnl_api.py", line 179, in _request_login
    data = response.json()
  File "/usr/local/lib/python3.7/site-packages/requests/models.py", line 897, in json
    return complexjson.loads(self.text, **kwargs)
  File "/usr/local/lib/python3.7/site-packages/simplejson/__init__.py", line 525, in loads
    return _default_decoder.decode(s)
  File "/usr/local/lib/python3.7/site-packages/simplejson/decoder.py", line 370, in decode
    obj, end = self.raw_decode(s)
  File "/usr/local/lib/python3.7/site-packages/simplejson/decoder.py", line 400, in raw_decode
    return self.scan_once(s, idx=_w(s, idx).end())
simplejson.errors.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/postnl/sensor.py", line 46, in setup_platform
    api = PostNL_API(username, password)
  File "/usr/local/lib/python3.7/site-packages/postnl_api/postnl_api.py", line 57, in __init__
    self._request_login()
  File "/usr/local/lib/python3.7/site-packages/postnl_api/postnl_api.py", line 182, in _request_login
    raise (UnauthorizedException())
postnl_api.postnl_api.UnauthorizedException

It’s offline and will be removed in a next release…

Obviously they don’t know what they are doing. I mean if you want to prevent the misuse of your API’s you use an API management solution which throttles / denies requests on a set of criteria or implement security tokens (for developers) to access their API’s.

2 Likes

hi there,
is the POSTNL issue still relevant?
I wan’t to add this function to my HA.

thnx

Nope: Lovelace: PostNL

I’ve discovered a method to obtain JSON-formatted API data from PostNL for free. This data includes essential information such as delivery dates, sender details, and more.

To achieve this, I’ve set up a REST sensor and multiple template sensors. These sensors regularly update and store all the relevant data in attributes. After testing, I can confirm that it works seamlessly.

In the future, I’m planning to create an HACS integration for this instead of relying on templates. If you’re interested, I’ll make this solution available for easy integration.

Here’s how it currently operates: We use two text helpers, one for the postal code and one for the package ID (known as a trace code). These are added to the dashboard, where I’ve embedded a script and a button to trigger updates. When the update button is pressed, it calls the ‘update entity’ service to fetch data from the PostNL API. This data is then made available through four sensors and numerous attributes for your convenience.

i will post it soon on this forum or i will release a hacs integration if i have time.
i will play a bit more and test before releasing it.

1 Like