UnauthorizedException is back
The UnauthorizedException is back like in the previous issue. Unclear is yet why, but apparently not everyone is suffering from this case, as noted in https://community.home-assistant.io/t/lovelace-postnl/112433/240
I tried to debug, but having a hard time to track my requests on an android device.
The earlier mentioned user agents here don't solve the problem. So it's unclear if it's related to the header.
cc @IcyPalm
Still working like a charm here... Setting the scan_interval most likely helpes keeping the relationship with postnl in good order.
But once a day, guessing we might miss out some alerts. Do we know for sure at what time postnl updates the data?
Okay it is working. But how can I get the latest python-postNL-api to work with LoveLace from https://community.home-assistant.io/u/ptnijssen ? Is there a recently updated howto?
@0x00-0xFF, @peternijssen someone who would like to do a PR with the discussed changes? I could publish it asap and let's get it to HA core.
Done
Thanks @0x00-0xFF, it has been published on PyPi as version 1.2.3.
@peternijssen, @IcyPalm, would you like to try it out? Let's have it thoroughly tested and get it back in HA. For me it works with those changes.
Good work guys! Anyone been in touch with PostNL yet? Any expectations when this could be fixed in HA-core or in a HA-Custom- Component?
I really miss my PostNL info in HA
You could load it as a custom component, the fix is working for me. Clone this repo and add it to your your custom components and let us know if it's working for you as well.
@0x00-0xFF Do you mean to load this new version of the api as a custom component? How should we do that? Or copy the postnl component and adjust it to use the new api?
I followed these steps:
- Download latest home assistant code as zip
- Copy
postnlcomponent folder to mycustom_componentsfolder - Modified the manifest to use api version
1.2.3 - Restarted HA
This is the result:
.
.
.
INFO:homeassistant.util.package:Attempting install of postnl_api==1.2.3
.
.
.
2019-12-15 16:04:57 INFO (SyncWorker_1) [homeassistant.loader] Loaded postnl from custom_components.postnl
.
.
.
2019-12-15 16:04:59 WARNING (MainThread) [homeassistant.loader] You are using a custom integration for postnl which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you do experience issues with Home Assistant.
.
.
.
2019-12-15 16:05:00 ERROR (SyncWorker_7) [custom_components.postnl.sensor] Can't connect to the PostNL webservice
Traceback (most recent call last):
File "/Users/robert/.homeassistant/deps/lib/python/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/Cellar/python/3.7.5/Frameworks/Python.framework/Versions/3.7/lib/python3.7/json/__init__.py", line 348, in loads
return _default_decoder.decode(s)
File "/usr/local/Cellar/python/3.7.5/Frameworks/Python.framework/Versions/3.7/lib/python3.7/json/decoder.py", line 337, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "/usr/local/Cellar/python/3.7.5/Frameworks/Python.framework/Versions/3.7/lib/python3.7/json/decoder.py", line 355, in raw_decode
raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Users/robert/.homeassistant/custom_components/postnl/sensor.py", line 46, in setup_platform
api = PostNL_API(username, password)
File "/Users/robert/.homeassistant/deps/lib/python/site-packages/postnl_api/postnl_api.py", line 57, in __init__
self._request_login()
File "/Users/robert/.homeassistant/deps/lib/python/site-packages/postnl_api/postnl_api.py", line 182, in _request_login
raise (UnauthorizedException())
postnl_api.postnl_api.UnauthorizedException
As you can see @iMicknl it isn't working for me. 😢
I have also tried to install the lib through pypi and that isn't working either. Same error message.
It definitely is working for me though, a few days ago I had to fix the code again -> https://github.com/iMicknl/python-postnl-api/issues/20
I tried again:
$ pip3 install postnl-api
$ python3 -m postnl_api.test_postnl_api [email protected] PaSsW0rdwithlettersandnumbersonly
Error again. Tried with my own internet, a VPN server in NL and one abroad. If it is working for some, I can only assume blocking takes place at the user level. I created a completely new account and tried again. Same error.
My latest fix in PR20 is not merged yet, and also not on pypi. https://github.com/iMicknl/python-postnl-api/pull/22
https://github.com/iMicknl/python-postnl-api/issues/17#issuecomment-562931289:
Clone this repo and add it to your your custom components and let us know if it's working for you as well.
I'm willing to give it a try, but how should I clone the API itself (not the postnl HA component) as a custom component?