core: Synology DSM no longer working with 2FA authentication from 0.117.0b5

The problem

My Synology integration has stopped working since upgrading to 0.117.0b5. Everything has worked fine previously, but I know have no devices & no entities tied to the intregration.

Environment

  • Home Assistant Core release with the issue: 0.117.0b5
  • Last working Home Assistant Core release (if known): 0.116.4
  • Operating environment (OS/Container/Supervised/Core): Supervised
  • Integration causing this issue: SynologyDSM
  • Link to integration documentation on our website: https://www.home-assistant.io/integrations/synology_dsm

Problem-relevant configuration.yaml

  - platform: synology_dsm
    host: <<IP_ADDRESS>>
    username: !secret synology_username
    password: !secret synology_password

Traceback/Error logs

Logger: homeassistant.config_entries
Source: components/synology_dsm/__init__.py:262
First occurred: 9:34:19 (2 occurrences)
Last logged: 9:35:47

Error setting up entry 192.168.1.221 for synology_dsm
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 234, in async_setup
    result = await component.async_setup_entry(hass, self)  # type: ignore
  File "/usr/src/homeassistant/homeassistant/components/synology_dsm/__init__.py", line 168, in async_setup_entry
    await api.async_setup()
  File "/usr/src/homeassistant/homeassistant/components/synology_dsm/__init__.py", line 262, in async_setup
    await self._hass.async_add_executor_job(
  File "/usr/local/lib/python3.8/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/local/lib/python3.8/site-packages/synology_dsm/synology_dsm.py", line 160, in login
    raise switcher.get(
synology_dsm.exceptions.SynologyDSMLogin2SAFailedException: {'api': 'SYNO.API.Auth', 'code': 404, 'reason': 'One time password authenticate failed', 'details': 'Two-step authentication failed, retry with a new pass code'}
Home Assistant has started!

Additional information

I have removed and re-added the integration several times, also tried adding via UI and via configuration, both show the same error.

I have tried creating an entirely new user in DSM, still the same result.

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 3
  • Comments: 37 (8 by maintainers)

Most upvoted comments

ditto - restarted and everything came back!! YAY!!!

The programmers are confirmed AWESOME šŸ‘

analyse of code changes:

with following change by commit 7469bd92664c8c

@@ -253,10 +258,11 @@ async def async_setup(self):
            self._entry.data[CONF_PASSWORD],
            self._entry.data[CONF_SSL],
            timeout=self._entry.options.get(CONF_TIMEOUT),
-            device_token=self._entry.data.get("device_token"),
+        )
+       await self._hass.async_add_executor_job(
+            self.dsm.login, self._entry.data.get("device_token")
+        )

the affective call to login API (source) was changed so far that device_id has been replaced by otp_code, because entry.data.get("device_token") is no longer provided during setup of SynoApi(), but later at call self.dsm.login

EDIT: device_id is not replaced by otp_code, but otp_code is additional set and filled with entry.data.get("device_token")

Agreed; re-instated 2fA on Synology DSM, removed and re-installed this integration and provided the one time password and its working now. Thanks as it’s vital for me to keep 2FA on this key asset…

Working fine here as well. Thx a lot!

Simone

Thanks guys on working on this, I’ve tested this and it works as expected now!

Fixed in 0.117.4 for me! Many Thanks.

Thanks all for looking into the issue, appreciate the efforts.

I’ll report the results one 0.117.3 is released

Same issue on 0.117.2, running hass.io on an Raspberry Pi 4.

All the synology entities are ā€˜unavailable’ before i removed it. I tried to remove and add it again, now i see no entities. I just waited for the scan of 15 minutes but they still disappeared

2020-11-02 09:08:22 ERROR (MainThread) [homeassistant.config_entries] Error setting up entry 192.168.0.1 for synology_dsm Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/config_entries.py", line 234, in async_setup result = await component.async_setup_entry(hass, self) # type: ignore File "/usr/src/homeassistant/homeassistant/components/synology_dsm/__init__.py", line 168, in async_setup_entry await api.async_setup() File "/usr/src/homeassistant/homeassistant/components/synology_dsm/__init__.py", line 262, in async_setup await self._hass.async_add_executor_job( File "/usr/local/lib/python3.8/concurrent/futures/thread.py", line 57, in run result = self.fn(*self.args, **self.kwargs) File "/usr/local/lib/python3.8/site-packages/synology_dsm/synology_dsm.py", line 160, in login raise switcher.get( synology_dsm.exceptions.SynologyDSMLogin2SAFailedException: {'api': 'SYNO.API.Auth', 'code': 404, 'reason': 'One time password authenticate failed', 'details': 'Two-step authentication failed, retry with a new pass code'}

Same issue for me… The 0.117.2 don’t fix it…

Hi, same issue here after removing and re-adding the integration. I’m asked for the 2FA password, dialog says ā€œconfiguration completedā€ but sensors are not created and error below shows up-

2020-11-01 18:12:01 ERROR (MainThread) [homeassistant.config_entries] Error setting up entry homenas for synology_dsm
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 234, in async_setup
    result = await component.async_setup_entry(hass, self)  # type: ignore
  File "/usr/src/homeassistant/homeassistant/components/synology_dsm/__init__.py", line 168, in async_setup_entry
    await api.async_setup()
  File "/usr/src/homeassistant/homeassistant/components/synology_dsm/__init__.py", line 262, in async_setup
    await self._hass.async_add_executor_job(
  File "/usr/local/lib/python3.8/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/local/lib/python3.8/site-packages/synology_dsm/synology_dsm.py", line 160, in login
    raise switcher.get(
synology_dsm.exceptions.SynologyDSMLogin2SAFailedException: {'api': 'SYNO.API.Auth', 'code': 404, 'reason': 'One time password authenticate failed', 'details': 'Two-step authentication failed, retry with a new pass code'}

Simone

Hi,

I was browsing around, and I too have this EXACT same issue where I get the 2FA error. I’ve also did what @robearlam do and nothing works, and I also get the error below too:

* Error setting up entry myDSMserver.com for synology_dsm Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/config_entries.py", line 234, in async_setup result = await component.async_setup_entry(hass, self) # type: ignore File "/usr/src/homeassistant/homeassistant/components/synology_dsm/__init__.py", line 168, in async_setup_entry await api.async_setup() File "/usr/src/homeassistant/homeassistant/components/synology_dsm/__init__.py", line 262, in async_setup await self._hass.async_add_executor_job( File "/usr/local/lib/python3.8/concurrent/futures/thread.py", line 57, in run result = self.fn(*self.args, **self.kwargs) File "/usr/local/lib/python3.8/site-packages/synology_dsm/synology_dsm.py", line 160, in login raise switcher.get( synology_dsm.exceptions.SynologyDSMLogin2SAFailedException: {'api': 'SYNO.API.Auth', 'code': 404, 'reason': 'One time password authenticate failed', 'details': 'Two-step authentication failed, retry with a new pass code'}

I’ve posted this issue on HA forums too:

https://community.home-assistant.io/t/issues-with-synology-dsm-on-latest-hassio-0-117-0/240050

This seems to stem from how 0.117.0 deals with the synology DSM 2fa. Also I too am running the exact OS and Hardware that @robearlam is using funny enough.

The only thing different is I am using the surveillance station package on my DSM, and it was working on the older version before upgrading today.

If anyone has ideas, i’m all ears, or need to test this.