Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion homeassistant/components/synology_dsm/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ async def async_coordinator_update_data_cameras() -> dict[
surveillance_station = api.surveillance_station

try:
async with async_timeout.timeout(10):
async with async_timeout.timeout(30):
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is very long and will also delay startup of Home Assistant if the device is offline (because it is blocking during setup). Can you detect if it’s an NVR and if so, make it 30s ? Also what can take up to 30 seconds to reply, that sounds like some other issue

Copy link
Copy Markdown
Member Author

@mib1185 mib1185 Nov 8, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the main problem is, that the surveillance_station.update in the library does multiple API calls sequentially - first gather all cameras, next iterate over each camera and gather the motion detection state.
In case of #58793 the "gather all cameras" lasts already 2s which returns 7 cameras ... each "gather motion detection state" lasts ~1-1.5s, those the 7th iteration was already causing the timeout - honestly the used NAS (model DS214) is not quiet powerful, but also actual models rely often on efficient small ARM cpu's.

Maybe we can limit the timeout to 20s to be more friendly to the entrance class NAS - sure, the overall solution should be to divide the data gathering into own update coordinators per each camera, but this needs also a rework of the library (already on my todo list for the upcoming winter months)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

btw if the NAS is not online during setup a ConfigEntryNotReady is raised

raise ConfigEntryNotReady(details) from err

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm fine with accepting this now to relief some pressure for this release, but this is not the right fix. Instead of a global timeout it should have a timeout per request.

await hass.async_add_executor_job(surveillance_station.update)
except SynologyDSMAPIErrorException as err:
raise UpdateFailed(f"Error communicating with API: {err}") from err
Expand Down