Skip to content

Increase timeout for fetching camera data on Synology DSM#59237

Merged
balloob merged 1 commit intohome-assistant:devfrom
mib1185:synology_dsm/increase-timeout-for-fetching-camera-data
Nov 9, 2021
Merged

Increase timeout for fetching camera data on Synology DSM#59237
balloob merged 1 commit intohome-assistant:devfrom
mib1185:synology_dsm/increase-timeout-for-fetching-camera-data

Conversation

@mib1185
Copy link
Copy Markdown
Member

@mib1185 mib1185 commented Nov 6, 2021

Proposed change

This will increase the timeout from 10 to 30s for fetching camera data from "Surveillance Station" on Synology DSM, those it fixes running into timeout, when having some more cameras connected or encounter a higher systemload.

Type of change

  • Dependency upgrade
  • Bugfix (non-breaking change which fixes an issue)
  • New integration (thank you!)
  • New feature (which adds functionality to an existing integration)
  • Breaking change (fix/feature causing existing functionality to break)
  • Code quality improvements to existing code or addition of tests

Additional information

Checklist

  • The code change is tested and works locally.
  • Local tests pass. Your PR cannot be merged unless tests pass
  • There is no commented out code in this PR.
  • I have followed the development checklist
  • The code has been formatted using Black (black --fast homeassistant tests)
  • Tests have been added to verify that the new code works.

If user exposed functionality or configuration variables are added/changed:

If the code communicates with devices, web services, or third-party tools:

  • The manifest file has all fields filled out correctly.
    Updated and included derived files by running: python3 -m script.hassfest.
  • New or updated dependencies have been added to requirements_all.txt.
    Updated by running python3 -m script.gen_requirements_all.
  • For the updated dependencies - a link to the changelog, or at minimum a diff between library versions is added to the PR description.
  • Untested files have been added to .coveragerc.

The integration reached or maintains the following Integration Quality Scale:

  • No score or internal
  • 🥈 Silver
  • 🥇 Gold
  • 🏆 Platinum

To help with the load of incoming pull requests:

@mib1185 mib1185 added this to the 2021.11.2 milestone Nov 6, 2021
@mib1185 mib1185 requested a review from Quentame as a code owner November 6, 2021 14:40
@probot-home-assistant probot-home-assistant bot added bugfix integration: synology_dsm Synology DSM small-pr PRs with less than 30 lines. labels Nov 6, 2021
@probot-home-assistant
Copy link
Copy Markdown

Hey there @hacf-fr, @Quentame, mind taking a look at this pull request as it has been labeled with an integration (synology_dsm) you are listed as a code owner for? Thanks!
(message by CodeOwnersMention)


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.

@mib1185
Copy link
Copy Markdown
Member Author

mib1185 commented Nov 8, 2021

Forgot to link an additional issue (#58793) which will benefit from this PR

@balloob balloob merged commit a22a966 into home-assistant:dev Nov 9, 2021
@balloob balloob mentioned this pull request Nov 9, 2021
@mib1185 mib1185 deleted the synology_dsm/increase-timeout-for-fetching-camera-data branch November 9, 2021 09:17
@github-actions github-actions bot locked and limited conversation to collaborators Nov 10, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Camera of Synology DSM integration become unavailable after seconds Synology DSM Integration not showing cameras

3 participants