PostNL Integration

Having the same issues right now, after updating HA.

It worked fine the last couple of weeks, not sure what causes it.

I have also tried to take the files from the pull request and use it as a custom component. Same issue.

@un4, @karsie
Can you check if you can login on the PostNL website with your account. I had to change my password before it was working again. Don’t know if I had the same error message, but it seems to be related.

I can login. It also works without custom component I can see my number of packages in the sensor. The failure comes up only when using custom component.

Does the manifest.json of the custom component contain postnlpy 0.4.1?

"requirements": [
  "postnlpy==0.4.1"
],

Yes it does

Hi,

Until Hassio 0.101.2 this custom component was working fine. But sins I installed the latest Hassio 0.101.3 I get the following log error:

Can’t connect to the PostNL API
Traceback (most recent call last):
File “/usr/local/lib/python3.7/site-packages/postnlpy/postnlapi.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 518, 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 “/config/custom_components/postnl/sensor.py”, line 43, in setup_platform
api = PostnlApi(username, password, refresh_rate.total_seconds())
File “/usr/local/lib/python3.7/site-packages/postnlpy/postnlapi.py”, line 62, in init
self._request_login()
File “/usr/local/lib/python3.7/site-packages/postnlpy/postnlapi.py”, line 182, in _request_login
raise (UnauthorizedException())
postnlpy.postnlapi.UnauthorizedException

The standard PostNL integration has no issue with the PostNL API.

Please help.

1 Like

Same error as well. This started appearing when going from 0.101.2 to 3.

1 Like

Yes, checked it and I can normally login to PostNL. It appeared to happen after updating HA

I am on 0.101.1, so that’s the reason it’s still working here then.

On which version of Python are you?

Before I update HA I did a check with the “Check Home Assistant Configuration” and reported that there was an update for Python 3.7.3.

Even after a rollback with a Snapshot to 0.101.2 I have still the same issue.

I have fresh install of 0.101.2 and have this problem.

Then I’m still wondering which version of Python is installed?

I have this problem too after upgrading to 0.101.3.
(Hassio, docker, ubuntu, vmware)
According to Portainer my Python version is 3.7.4

Ah, I have this problem too! At least it’s not just me :slight_smile:

019-11-08 12:33:43 ERROR (SyncWorker_12) [custom_components.postnl.sensor] Can't connect to the PostNL API
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/postnlpy/postnlapi.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 518, 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 "/config/custom_components/postnl/sensor.py", line 43, in setup_platform
    api = PostnlApi(username, password, refresh_rate.total_seconds())
  File "/usr/local/lib/python3.7/site-packages/postnlpy/postnlapi.py", line 62, in __init__
    self._request_login()
  File "/usr/local/lib/python3.7/site-packages/postnlpy/postnlapi.py", line 182, in _request_login
    raise (UnauthorizedException())
postnlpy.postnlapi.UnauthorizedException

Hi all. I am currently away from home so can’t check. Will do so early next week.

I am still awaiting for my PR to be merged so there is no need for a custom component anymore. I haven’t tried it with the latest versions anymore, because I created it almost 30 days ago, but you could try to download these files and see if they work:

Also I want to point out that PostNL had resetted some passwords lately due to hacking attempts. So please verify first that you can login at PostNL itself.

I’ll get back to you all as soon as I can.

Downloaded the files, restarted HA but error is still there:

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 518, 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 "/config/custom_components/postnl/sensor.py", line 50, 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

Same for me with the PR version.

Also checked that I can login successfully via the PostNL website.

Hey Peter(and rest of watchers :slight_smile: )

I just quickly checked if I could find where the source of the problem seems to be.

So I cloned python-postnl-api package and tried some of the included url’s with Postman. At first glance it looks like they changed their endpoint since I get a 403 so there is a chance the API package needs to be reworked.

If I can find the time tonight or tomorrow I will look into it and try to reverse engineer the (changed) endpoint

Update edit: Already found a bit of time and I have found a possible solution, posting an issue to Github!

1 Like

Sure. Do note that my library is deprecated. See my PR above with the actual library that will be used.