Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BadCredentialsException while using correct credentials #278

Closed
iMicknl opened this issue Sep 29, 2020 · 19 comments
Closed

BadCredentialsException while using correct credentials #278

iMicknl opened this issue Sep 29, 2020 · 19 comments
Labels
blocked bug Something isn't working

Comments

@iMicknl
Copy link
Owner

iMicknl commented Sep 29, 2020

Describe the bug
Currently the coordinator is failing on BadCredentialsException for some users, which is not caused by bad credentials...

I have seen the situation myself, however it only happened 5 times.

First occurred: September 28, 2020, 8:27:20 PM (5 occurrences)
Last logged: September 28, 2020, 8:42:41 PM

Another user on the community forum has the same issues, where it looks like his IP is blocked.

Logger: custom_components.tahoma
Source: custom_components/tahoma/coordinator.py:56
Integration: Somfy TaHoma (documentation, issues)
First occurred: 28. September 2020, 20:27:07 (1487 occurrences)
Last logged: 08:56:50

Both of them started September 28 at 20:27, which could be a coincidence or caused by an update on Somfy's side.

To Reproduce
Not sure how to reproduce...

Environment (please complete the following information):

  • ha-tahoma version: 2.3.1
  • Home Assistant version: 0.115.4

Additional context

homebridge-tahoma mentions the same issue: dubocr/homebridge-tahoma#204

Logger: custom_components.tahoma
Source: custom_components/tahoma/coordinator.py:56
Integration: Somfy TaHoma (documentation, issues)
First occurred: 28. September 2020, 20:27:07 (1487 occurrences)
Last logged: 08:56:50

Unexpected error fetching TaHoma Event Fetcher data: Bad credentials

Traceback (most recent call last): File “/config/custom_components/tahoma/coordinator.py”, line 52, in _async_update_data events = await self.client.fetch_events() File “/usr/local/lib/python3.8/site-packages/pyhoma/client.py”, line 150, in fetch_events response = await self.__post(f"events/{self.event_listener_id}/fetch") File “/usr/local/lib/python3.8/site-packages/pyhoma/client.py”, line 250, in __post await self.check_response(response) File “/usr/local/lib/python3.8/site-packages/pyhoma/client.py”, line 286, in check_response raise NotAuthenticatedException(message) pyhoma.exceptions.NotAuthenticatedException: Not authenticated During handling of the above exception, another exception occurred: Traceback (most recent call last): File “/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py”, line 143, in async_refresh self.data = await self._async_update_data() File “/config/custom_components/tahoma/coordinator.py”, line 56, in _async_update_data await self.client.login() File “/usr/local/lib/python3.8/site-packages/pyhoma/client.py”, line 83, in login response = await self.__post(“login”, data=payload) File “/usr/local/lib/python3.8/site-packages/pyhoma/client.py”, line 250, in __post await self.check_response(response) File “/usr/local/lib/python3.8/site-packages/pyhoma/client.py”, line 282, in check_response raise BadCredentialsException(message) pyhoma.exceptions.BadCredentialsException: Bad credentials
@iMicknl iMicknl added the bug Something isn't working label Sep 29, 2020
@iMicknl iMicknl pinned this issue Sep 29, 2020
@halest
Copy link

halest commented Sep 29, 2020

Hey man, it's me again. I'm seeing the same issue since yesterday. I can see an update on the TaHoma box that happened yesterday. Anything I can do to help?

@golles
Copy link

golles commented Sep 29, 2020

I've also seen this a couple of times for a week (or so)

@vdheidenet

This comment has been minimized.

@iMicknl
Copy link
Owner Author

iMicknl commented Sep 29, 2020

Could you check via tahomalink.com which firmware you are running? I am running 2020.4.4-16 at the moment and I have set my update interval to 60 seconds. Did you perhaps change the update interval to a lower value than the default (30)?

Currently there is not much you can do to help.. @tetienne has reached out to his contacts at Somfy to understand if we need to lower our polling interval. However, I believe that our default of 30 is a pretty decent interval and that there could be other issues at Somfy's side.

Try lowering the update interval or removing the integration for a while. Afterwards you can add it back, and try to set the update interval to 60 seconds for example.

@vdheidenet just to be sure, are you using Home Assistant with this plugin or are you using homebridge? I see that you posted in the homebridge issue as well.

@halest
Copy link

halest commented Sep 29, 2020

Of course. I am running the same version 4.4-16. Interval is currently at 1200 seconds which had worked fine the last few weeks. I'll set it down to 30 and reset the HASS

@iMicknl
Copy link
Owner Author

iMicknl commented Sep 29, 2020

Of course. I am running the same version 4.4-16. Interval is currently at 1200 seconds which had worked fine the last few weeks. I'll set it down to 30 and reset the HASS

An interval of 1200 is fine as well, that should even be better than 30! Are you facing this error all the time, or does it just show up in your log a few times?

@halest
Copy link

halest commented Sep 29, 2020

Hey, since it started I haven't been able to move a single cover via HASS, so basically all the time. Neither via direct control nor via automation nor via calling a scene.

@halest
Copy link

halest commented Sep 29, 2020

Strange! After the reboot just now I was able to establish a connection and move a cover for the first time since yesterday. Let's see if it stays like that.

@vdheidenet
Copy link

@iMicknl, darn you're absolutely correct. I experience the same issue with a similar Homebridge Plugin.
I'm not using this plugin for HA, sorry for the confusion. I was confused with the different bug reports regarding the same problem.

But nevertheless, this problem is not specific for this HA-plugin, but also for HomeBridge plugins. So it looks like Somfy has changed the website/API (again).

@sopha80
Copy link

sopha80 commented Sep 30, 2020

had/ have the same issue.
forced DSL reconnect to get new IP solved it for the moment - credentials working again.

@iMicknl
Copy link
Owner Author

iMicknl commented Sep 30, 2020

Unfortunately 'Bad Credentials' is an ambiguous error. It can be caused by bad credentials or by an user being blacklisted due to too many errors or sessions. A way to get out of this blacklist is to stop the requests for a few hours, lowering the interval of requests won't fix it..

We are working on #280 to make sure that we stop calling the Somfy server when they throw 'Bad Credentials'. After some hours the user could reauth in Home Assistant, which should fix the issue.

I will put an update here when #280 is ready for a beta test. In case you have issues at the moment, it would be good to understand the update interval set via integrations -> options and all entries in your log (with debug mode on).

@golles
Copy link

golles commented Sep 30, 2020

Hi, I just had a noteworthy moment.
I went to https://www.tahomalink.com to check something in the web interface and after logging in I got a red screen with bad credentials (I should've made a screenshot, sorry). Logging in again did work.
I use a password manager to fill in the fields, so I'm 100% sure the correct passwords are being filled in.
I tried logging out and in again for 10-15 more times, but couldn't get it anymore.

So I think there is something on their server not working well and nothing related to this component

@halest
Copy link

halest commented Sep 30, 2020

Interesting! My error may have gone away yesterday after I logged into their web interface as well...

@iMicknl iMicknl linked a pull request Oct 4, 2020 that will close this issue
@iMicknl iMicknl unpinned this issue Oct 6, 2020
@iMicknl
Copy link
Owner Author

iMicknl commented Oct 7, 2020

I see that I faced it once again in my log, however the event listener was able to recover from it.

2020-10-07 09:17:06 DEBUG (MainThread) [custom_components.tahoma] Finished fetching TaHoma Event Fetcher data in 0.123 seconds
2020-10-07 09:18:06 ERROR (MainThread) [custom_components.tahoma] Unexpected error fetching TaHoma Event Fetcher data: Bad credentials
Traceback (most recent call last):
  File "/config/custom_components/tahoma/coordinator.py", line 59, in _async_update_data
    events = await self.client.fetch_events()
  File "/usr/local/lib/python3.8/site-packages/pyhoma/client.py", line 163, in fetch_events
    response = await self.__post(f"events/{self.event_listener_id}/fetch")
  File "/usr/local/lib/python3.8/site-packages/pyhoma/client.py", line 263, in __post
    await self.check_response(response)
  File "/usr/local/lib/python3.8/site-packages/pyhoma/client.py", line 299, in check_response
    raise NotAuthenticatedException(message)
pyhoma.exceptions.NotAuthenticatedException: Not authenticated

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 143, in async_refresh
    self.data = await self._async_update_data()
  File "/config/custom_components/tahoma/coordinator.py", line 66, in _async_update_data
    await self.client.login()
  File "/usr/local/lib/python3.8/site-packages/pyhoma/client.py", line 83, in login
    response = await self.__post("login", data=payload)
  File "/usr/local/lib/python3.8/site-packages/pyhoma/client.py", line 263, in __post
    await self.check_response(response)
  File "/usr/local/lib/python3.8/site-packages/pyhoma/client.py", line 295, in check_response
    raise BadCredentialsException(message)
pyhoma.exceptions.BadCredentialsException: Bad credentials
2020-10-07 09:18:06 DEBUG (MainThread) [custom_components.tahoma] Finished fetching TaHoma Event Fetcher data in 0.152 seconds
2020-10-07 09:19:06 INFO (MainThread) [custom_components.tahoma] Fetching TaHoma Event Fetcher data recovered
2020-10-07 09:19:06 DEBUG (MainThread) [custom_components.tahoma] Finished fetching TaHoma Event Fetcher data in 0.857 seconds

@golles
Copy link

golles commented Oct 7, 2020

I haven't seen this in the past few days. I also did a lot of restarts as I did a lot of improvements to my setup (adding sensors and improving UI's).
I've just updated my box (2020.4.4-18) and your component to the latest, I'll keep an eye on this error

@callifo
Copy link

callifo commented Jan 30, 2021

I've had this start happening with my Australian Connexion unit. Occasionally it would happen once or twice a day and no issue, the integration would still work fine. However tonight, I'm not able to use it anymore, with the error '[custom_components.tahoma] invalid_auth' on HA start.

I did get a couple of the 'pyhoma.exceptions.BadCredentialsException: Bad credentials' prior to the blinds stop working.

My update interval was set at 60 seconds, even though these blinds are stateless so just show up as unknown.

@iMicknl
Copy link
Owner Author

iMicknl commented Jan 31, 2021

@callifo I would advise for now to keep your update_interval on a high value (for example weekly). We need to have a look if we can set / disable the update interval for user with only RTS devices (and thus for users with the Connexoon RTS hub).

Are you still blocked, or does it work already?

@callifo
Copy link

callifo commented Feb 3, 2021

It came back after about 24 hours, I did not have to get a new IP or anything. Is this some form of blocking due to constant polling?

I have set it to weekly and will see how it goes again.

I have still be getting these irregularly at the time when I set HA to open my blinds in the morning, it opens four blinds,

2021-02-03 07:05:00 INFO (MainThread) [backoff] Backing off execute_commands(...) for 0.4s (pyhoma.exceptions.NotAuthenticatedException: Not authenticated)
2021-02-03 07:05:00 INFO (MainThread) [backoff] Backing off execute_commands(...) for 0.4s (pyhoma.exceptions.NotAuthenticatedException: Not authenticated)
2021-02-03 07:05:00 INFO (MainThread) [backoff] Backing off execute_commands(...) for 0.2s (pyhoma.exceptions.NotAuthenticatedException: Not authenticated)
2021-02-03 07:05:00 INFO (MainThread) [backoff] Backing off execute_commands(...) for 0.3s (pyhoma.exceptions.NotAuthenticatedException: Not authenticated)

However the blinds open fine.

@iMicknl
Copy link
Owner Author

iMicknl commented Feb 3, 2021

@callifo you are right, this is due to the fact that we pull the updated status of the command via the event listener. We definitely need to change this for your use-case, tracked in #369.

For now, I would temporarily not use this integration, until this is fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
blocked bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants