home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
69.03k stars 28.28k forks source link

Home Assistant 2024.5.1 broke my Synology Integration #116755

Closed paceo13 closed 1 week ago

paceo13 commented 2 weeks ago

The problem

After the update from HA Core 2024.4.4 to 2024.5.1 the Synology DSM integration could no longer load at the boot of HA. This issue was not present in the previous HA versions. I have tried to delete the Synology DSM integration and add it again, but the integration gave an "TimeoutError" message when trying to add the Synology integration again. Thanks for help.

What version of Home Assistant Core has the issue?

System Information version | core-2024.5.1 -- | -- installation_type | Home Assistant OS dev | false hassio | true docker | true user | root virtualenv | false python_version | 3.12.2 os_name | Linux os_version | 6.1.73-haos-raspi arch | aarch64 timezone | Europe/Paris config_dir | /config
Home Assistant Community Store GitHub API | ok -- | -- GitHub Content | ok GitHub Web | ok GitHub API Calls Remaining | 5000 Installed Version | 1.34.0 Stage | running Available Repositories | 1402 Downloaded Repositories | 25 HACS Data | ok
Home Assistant Cloud logged_in | true -- | -- subscription_expiration | 4 mai 2024 Ć  02:00 relayer_connected | true relayer_region | eu-central-1 remote_enabled | true remote_connected | true alexa_enabled | false google_enabled | true remote_server | eu-central-1-17.ui.nabu.casa certificate_status | ready instance_id | a80370b8430a4f31aa018be0c01e92ff can_reach_cert_server | ok can_reach_cloud_auth | ok can_reach_cloud | ok
Home Assistant Supervisor host_os | Home Assistant OS 12.2 -- | -- update_channel | stable supervisor_version | supervisor-2024.04.4 agent_version | 1.6.0 docker_version | 25.0.5 disk_total | 116.7 GB disk_used | 17.9 GB healthy | true supported | true board | rpi4-64 supervisor_api | ok version_api | ok installed_addons | File editor (5.8.0), Terminal & SSH (9.13.0), Node-RED (17.0.12), Linky (1.4.0), InfluxDB (5.0.0), Grafana (9.2.2), Z-Wave JS (0.5.0), Studio Code Server (5.15.0), Mosquitto broker (6.4.0)
Dashboards dashboards | 3 -- | -- resources | 21 views | 10 mode | storage
Recorder oldest_recorder_run | 24 avril 2024 Ć  09:56 -- | -- current_recorder_run | 3 mai 2024 Ć  21:28 estimated_db_size | 367.06 MiB database_engine | sqlite database_version | 3.44.2
Spotify api_endpoint_reachable | ok -- | --

What was the last working version of Home Assistant Core?

No response

What type of installation are you running?

Home Assistant OS

Integration causing the issue

Synology

Link to integration documentation on our website

https://www.home-assistant.io/integrations/synology_dsm/

Diagnostics information

No response

Example YAML snippet

No response

Anything in the logs that might be useful for us?

No response

Additional information

No response

home-assistant[bot] commented 2 weeks ago

Hey there @hacf-fr, @quentame, @mib1185, mind taking a look at this issue as it has been labeled with an integration (synology_dsm) you are listed as a code owner for? Thanks!

Code owner commands Code owners of `synology_dsm` can trigger bot actions by commenting: - `@home-assistant close` Closes the issue. - `@home-assistant rename Awesome new title` Renames the issue. - `@home-assistant reopen` Reopen the issue. - `@home-assistant unassign synology_dsm` Removes the current integration label and assignees on the issue, add the integration domain after the command. - `@home-assistant add-label needs-more-information` Add a label (needs-more-information, problem in dependency, problem in custom component) to the issue. - `@home-assistant remove-label needs-more-information` Remove a label (needs-more-information, problem in dependency, problem in custom component) on the issue.

(message by CodeOwnersMention)


synology_dsm documentation synology_dsm source (message by IssueLinks)

mib1185 commented 2 weeks ago

Hi @paceo13

please enable debug logging, restart HA and provide the home-assistant.log after you have tried to re-add your Synology to HA. To do so add the following to your configuration.yaml:

logger:
  default: info
  logs:
    homeassistant.components.synology_dsm: debug
    synology_dsm: debug

Note: it is better to drag the log into the comment (which will add it as an attachment) and not copy paste as it is hard to read logs in GitHub.

paceo13 commented 2 weeks ago

Hi, You will find my home-assistant.log attached. home-assistant_2024-05-04T08-20-24.698Z.log

mib1185 commented 2 weeks ago
2024-05-04 10:19:20.970 DEBUG (MainThread) [synology_dsm.synology_dsm] API: SYNO.SurveillanceStation.Camera.Event
2024-05-04 10:19:20.970 DEBUG (MainThread) [synology_dsm.synology_dsm] Request Method: GET
2024-05-04 10:19:22.261 DEBUG (MainThread) [homeassistant.components.synology_dsm.common] Connection error during setup of 'C7L5N00071' with exception: {'api': None, 'code': -1, 'reason': 'Unknown', 'details': 'TimeoutError'}

it times out while fetching details about your cameras - but it already times out after ~1s - did you change the timeout option of this integration?

paceo13 commented 2 weeks ago

I tried to change the integration timeout when I saw the timeout error but it didn't change anything, so I reset it to the default value... If the timeout error is camera related maybe I will have to uninstall "Surveillance Station" on Synology ?

Edit: I stopped surveillance station and reloaded the integration and everything works again... This could be an incompatibility with surveillance Station and the latest Home Assistant update?

WorldOfGZ commented 2 weeks ago

Hello, I'm subject to similar troubles since 2024.5.0 This is what on general log

Error fetching [REDACTED] SynologyDSMCentralUpdateCoordinator data: Error communicating with API: {'api': None, 'code': -1, 'reason': 'Unknown', 'details': 'TimeoutError'}
Error fetching [REDACTED] SynologyDSMCentralUpdateCoordinator data: Error communicating with API: {'api': 'SYNO.Core.System.Utilization', 'code': 1052, 'reason': 'Unknown', 'details': {'err_line': 191, 'err_msg': 'Transmition get failed Result.'}}

We saw on data there is some connect/disconnect regularly image

I tried to double the timeout delay but without success result. In my case, Surveillance Station is not installed on my Nas (DS416 Slim)

paceo13 commented 2 weeks ago

Same thing here. I also have disconnections despite Surveillance Station being disabled. image

bdraco commented 2 weeks ago

Hi, You will find my home-assistant.log attached. home-assistant_2024-05-04T08-20-24.698Z.log

It looks like it logs in successfully, and than throws

synology_dsm.exceptions.SynologyDSMNotLoggedInException: {'api': None, 'code': -1, 'reason': 'Unknown', 'details': 'Not logged in. You have to do login() first.'}

when trying to fetch /webapi/entry.cgi?api=SYNO.DSM.Info&version=2&method=getinfo&_sid

The token being returned has - at the start. Maybe there is still an encoding isuse since before it would retry, get a new token, and be blissfully unaware?

mib1185 commented 2 weeks ago

with https://github.com/mib1185/py-synologydsm-api/pull/301 we run the initial data fetches in one batch - this is proved by the following log lines

2024-05-04 10:19:12.152 DEBUG (MainThread) [homeassistant.components.synology_dsm.common] Enable security api updates for 'C7L5N00071'
2024-05-04 10:19:12.152 DEBUG (MainThread) [homeassistant.components.synology_dsm.common] Enable photos api updates for 'C7L5N00071'
2024-05-04 10:19:12.152 DEBUG (MainThread) [homeassistant.components.synology_dsm.common] Enable storage api updates for 'C7L5N00071'
2024-05-04 10:19:12.153 DEBUG (MainThread) [homeassistant.components.synology_dsm.common] Enable upgrade api updates for 'C7L5N00071'
2024-05-04 10:19:12.153 DEBUG (MainThread) [homeassistant.components.synology_dsm.common] Enable system api updates for 'C7L5N00071'
2024-05-04 10:19:12.153 DEBUG (MainThread) [homeassistant.components.synology_dsm.common] Enable utilisation api updates for 'C7L5N00071'
2024-05-04 10:19:12.153 DEBUG (MainThread) [homeassistant.components.synology_dsm.common] Enable surveillance_station api updates for 'C7L5N00071'
2024-05-04 10:19:12.154 DEBUG (MainThread) [homeassistant.components.synology_dsm.common] Start data update for 'C7L5N00071'
2024-05-04 10:19:12.154 DEBUG (MainThread) [homeassistant.components.synology_dsm.common] Entities not added yet, fetch all for 'C7L5N00071'
2024-05-04 10:19:12.155 DEBUG (MainThread) [synology_dsm.synology_dsm] API: SYNO.DSM.Info
2024-05-04 10:19:12.155 DEBUG (MainThread) [synology_dsm.synology_dsm] Request Method: GET
2024-05-04 10:19:12.158 DEBUG (MainThread) [synology_dsm.synology_dsm] API: SYNO.Core.SecurityScan.Status
2024-05-04 10:19:12.159 DEBUG (MainThread) [synology_dsm.synology_dsm] Request Method: GET
2024-05-04 10:19:12.165 DEBUG (MainThread) [synology_dsm.synology_dsm] API: SYNO.Core.System.Utilization
2024-05-04 10:19:12.165 DEBUG (MainThread) [synology_dsm.synology_dsm] Request Method: GET
2024-05-04 10:19:12.171 DEBUG (MainThread) [synology_dsm.synology_dsm] API: SYNO.Storage.CGI.Storage
2024-05-04 10:19:12.171 DEBUG (MainThread) [synology_dsm.synology_dsm] Request Method: GET
2024-05-04 10:19:12.173 DEBUG (MainThread) [synology_dsm.synology_dsm] API: SYNO.SurveillanceStation.Camera
2024-05-04 10:19:12.173 DEBUG (MainThread) [synology_dsm.synology_dsm] Request Method: GET
2024-05-04 10:19:12.176 DEBUG (MainThread) [synology_dsm.synology_dsm] API: SYNO.Core.System
2024-05-04 10:19:12.176 DEBUG (MainThread) [synology_dsm.synology_dsm] Request Method: GET
2024-05-04 10:19:12.185 DEBUG (MainThread) [synology_dsm.synology_dsm] API: SYNO.Core.Upgrade.Server
2024-05-04 10:19:12.186 DEBUG (MainThread) [synology_dsm.synology_dsm] Request Method: GET

so the timeout we see is not obviously after ~2s, but after 10s

2024-05-04 10:19:12.185 DEBUG (MainThread) [synology_dsm.synology_dsm] API: SYNO.Core.Upgrade.Server
2024-05-04 10:19:12.186 DEBUG (MainThread) [synology_dsm.synology_dsm] Request Method: GET
[...]
2024-05-04 10:19:22.261 DEBUG (MainThread) [homeassistant.components.synology_dsm.common] Connection error during setup of 'C7L5N00071' with exception: {'api': None, 'code': -1, 'reason': 'Unknown', 'details': 'TimeoutError'}

so in summary it is the same issue, as we had in the passt, where the Synology stucks in getting the SYNO.Core.Upgrade.Server data which actually was resolved by #79435 - need to check why this fix do not work anymore ...

mib1185 commented 2 weeks ago

nevermind ... it is not the fetch of SYNO.Core.Upgrade.Server ... something else runs into timeout ...

mib1185 commented 2 weeks ago

it seems that not all initial data fetches within teh batch get ready within the 10s timeout of asyncio, so the integration fails on initial update and fallback to retry šŸ¤” @bdraco you're our async expert šŸ˜ what do you think?

bdraco commented 2 weeks ago

Whats happening with the timeout is that the device is so slow it can't answer all the requests in 10s

Before https://github.com/mib1185/py-synologydsm-api/pull/301 it would do them in series so each request got a 10s timeout. Now that they are created in tasks, the device doesn't seem to be able to keep up and can't answer the requests quick enough.

While it will make it slower for everyone with fast devices, I suggest we revert that PR since we still need to support the slower devices.

mib1185 commented 2 weeks ago

@paceo13 @WorldOfGZ could you please increase the timeout to at least 30s in the integrations option and check if the timeout issue still occur?

WorldOfGZ commented 1 week ago

@mib1185 no problem. I will come back tomorrow to have more records

sdmike commented 1 week ago

Increasing the timeout to 30 seconds seems to have resolved it for me.

mib1185 commented 1 week ago

@sdmike which Synology model do you have?

sdmike commented 1 week ago

DS713+

mib1185 commented 1 week ago

DS713+

quite old with an "Intel Atom D2700" (dual core with HT) from Q3'2011 with 1GB RAM (this is just for our reference, how different models performs) thanks @sdmike

paceo13 commented 1 week ago

No more disconnection for me with the timeout to 30 seconds. I will confirm tomorrow if it is still ok. (for information my NAS is an old DS213+)

mib1185 commented 1 week ago

(for information my NAS is an old DS213+)

"Freescale P1022" CPU (2core w/o HT) - "Power Architecture e500 cores frequencies from 667 MHz to 1200 MHz" (src) with 512MB RAM

Dillton commented 1 week ago

Hi, I am following this thread as I have the same issue with my DS218+ Increasing the timeout to 30s seems to solved it.

mib1185 commented 1 week ago

ok, thanks

Hi, I am following this thread as I have the same issue with my DS218+ Increasing the timeout to 30s seems to solved it.

middle old Intel Celeron J3355 (2 core w/o HT) from Q3'2016 with 2GB RAM

Dillton commented 1 week ago

ok, thanks

Hi, I am following this thread as I have the same issue with my DS218+ Increasing the timeout to 30s seems to solved it.

middle old Intel Celeron J3355 (2 core w/o HT) from Q3'2016 with 2GB RAM

Maybe it's worth to mention that I did an upgrade to 8GB RAM in past but not sure if this is helpful info.

WorldOfGZ commented 1 week ago

Hello Seems really better with 30s but I still had a short cut at 23h35 image

mib1185 commented 1 week ago

@WorldOfGZ your NAS is a DS213 with 512MB of RAM and a Marvell Kirkwood 88F6282 single-core CPU - this is a really quiet old and slow CPU - i think it is in generell a bit exhausted (most properly the RAM, which forces the NAS to use the SWAP, which slows down the system dramatically) with additional enabled "Surveillance Station" and "Photo Station" šŸ¤”

Jirik6 commented 1 week ago

I have same problem with Synology integration. Core ver. 2024.4.4 was last OK. Ver. 2024.5 and 2024.5.1 droped connection.

mib1185 commented 1 week ago

I have same problem with Synology integration. Core ver. 2024.4.4 was last OK. Ver. 2024.5 and 2024.5.1 droped connection.

I assume you've already checked https://github.com/home-assistant/core/issues/116755#issuecomment-2094281502?

WorldOfGZ commented 1 week ago

@mib1185 this is a DS216slim. But this is correct this is very slow. Here my load since I put timeout 30s. image It's works only as NAS, video station, surveillance station and others are uninstalled. Clearly this model is bad... wrong choice at the beginning. But as you can see with timeout of 30 there is only a disconnect of few minutes.

mib1185 commented 1 week ago

@mib1185 this is a DS216slim. But this is correct this is very slow.

mehhh ... i mixed it up with the logs from paceo13 šŸ™ˆ but yes, your system load looks horrible šŸ˜

XDA999 commented 1 week ago

I had also DSM connection issue (DS116, DS1019, RS214). Only thing resolved a problem was to increase timeout (30+ s).