Skip to content

Fix Onvif Camera that does not have SnapshotUri such as Sricam#33902

Merged
balloob merged 1 commit into
home-assistant:devfrom
Minims:onvif_fix
Apr 10, 2020
Merged

Fix Onvif Camera that does not have SnapshotUri such as Sricam#33902
balloob merged 1 commit into
home-assistant:devfrom
Minims:onvif_fix

Conversation

@Minims
Copy link
Copy Markdown
Contributor

@Minims Minims commented Apr 9, 2020

Proposed change

This change allow some ONVIF camera that does not have the GetSnapshotUri to work as in 0.107.7

Logs I had before this patch :

2020-04-09 11:56:41 DEBUG (MainThread) [homeassistant.components.onvif.camera] Retrieving current camera date/time
2020-04-09 11:56:42 WARNING (MainThread) [homeassistant.components.onvif.camera] Couldn't get camera 'JustIN' date/time. Error: None
2020-04-09 11:56:42 DEBUG (MainThread) [homeassistant.components.onvif.camera] Connecting with ONVIF Camera: 192.168.1.52 on port 5000
2020-04-09 11:56:42 DEBUG (MainThread) [homeassistant.components.onvif.camera] Retrieving profiles
2020-04-09 11:56:44 DEBUG (MainThread) [homeassistant.components.onvif.camera] Retrieved '2' profiles
2020-04-09 11:56:44 DEBUG (MainThread) [homeassistant.components.onvif.camera] Using profile index '0'
2020-04-09 11:56:44 DEBUG (MainThread) [homeassistant.components.onvif.camera] Retrieving stream uri
2020-04-09 11:56:46 DEBUG (MainThread) [homeassistant.components.onvif.camera] ONVIF Camera Using the following URL for JustIN: rtsp://<user>:<password>@192.168.1.52:554/onvif1
2020-04-09 11:56:46 DEBUG (MainThread) [homeassistant.components.onvif.camera] Connecting with ONVIF Camera: 192.168.1.52 on port 5000
2020-04-09 11:56:46 DEBUG (MainThread) [homeassistant.components.onvif.camera] Retrieving profiles
2020-04-09 11:56:49 DEBUG (MainThread) [homeassistant.components.onvif.camera] Retrieved '2' profiles
2020-04-09 11:56:49 DEBUG (MainThread) [homeassistant.components.onvif.camera] Using profile index '0'
2020-04-09 11:56:49 DEBUG (MainThread) [homeassistant.components.onvif.camera] Retrieving snapshot uri
2020-04-09 11:56:51 WARNING (MainThread) [homeassistant.components.onvif.camera] Couldn't connect to camera 'JustIN', but will retry later. Error: None

I goes in python ClientConnectionError with err value "None". This error is from the await self.async_obtain_snapshot_uri() that could not retrieve the snapshot uri.

Type of change

  • Dependency upgrade
  • [ x] 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

  • This PR fixes or closes issue: fixes #
  • This PR is related to issue:
  • Link to documentation pull request:

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.
  • Untested files have been added to .coveragerc.

The integration reached or maintains the following Integration Quality Scale:

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

@probot-home-assistant probot-home-assistant Bot added integration: onvif small-pr PRs with less than 30 lines. labels Apr 9, 2020
@MartinHjelmare MartinHjelmare changed the title Fix Onvif Camera that does not have SnapshotUri such as Sricam. Fix Onvif Camera that does not have SnapshotUri such as Sricam Apr 9, 2020
@MartinHjelmare
Copy link
Copy Markdown
Member

I see you already opened a PR. 👍

Copy link
Copy Markdown
Member

@MartinHjelmare MartinHjelmare left a comment

Choose a reason for hiding this comment

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

Looks ok to me.

@MartinHjelmare
Copy link
Copy Markdown
Member

It would be good to paste the log that you got also here in the PR description for completeness.

@Minims
Copy link
Copy Markdown
Contributor Author

Minims commented Apr 9, 2020

It would be good to paste the log that you got also here in the PR description for completeness.

I have add my logs at the beginning, thanks 👍

@springstan
Copy link
Copy Markdown
Member

@MartinHjelmare should we tag this for 0.108.2?

Comment on lines +414 to +418
try:
snapshot_uri = await media_service.GetSnapshotUri(req)
self._snapshot = snapshot_uri.Uri
except ServerDisconnectedError as err:
_LOGGER.debug("Camera does not support GetSnapshotUri: %s", 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.

Is ONVIFError different than ServerDisconnectedError ? What can still raise ONVIFError ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I think we need both exception. Here ServerDisconnectedErroris caught because the sever reset the connection. But if the onvif web server can answer but can't reply the right thing, it will raise ONVIFError as I understand.

@balloob balloob added this to the 0.108.3 milestone Apr 10, 2020
@balloob balloob merged commit 7b9585c into home-assistant:dev Apr 10, 2020
@balloob balloob mentioned this pull request Apr 10, 2020
@lock lock Bot locked and limited conversation to collaborators Apr 15, 2020
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.

5 participants