mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 13:17:32 +00:00
fix mjpeg issue along with some cameras not returning event capabilities properly (#35885)
This commit is contained in:
parent
ed2a43ba5b
commit
a82900ae27
@ -106,11 +106,6 @@ class ONVIFCameraEntity(ONVIFBaseEntity, Camera):
|
||||
|
||||
async def stream_source(self):
|
||||
"""Return the stream source."""
|
||||
if self._stream_uri is None:
|
||||
uri_no_auth = await self.device.async_get_stream_uri(self.profile)
|
||||
self._stream_uri = uri_no_auth.replace(
|
||||
"rtsp://", f"rtsp://{self.device.username}:{self.device.password}@", 1
|
||||
)
|
||||
return self._stream_uri
|
||||
|
||||
async def async_camera_image(self):
|
||||
@ -118,11 +113,6 @@ class ONVIFCameraEntity(ONVIFBaseEntity, Camera):
|
||||
image = None
|
||||
|
||||
if self.device.capabilities.snapshot:
|
||||
if self._snapshot_uri is None:
|
||||
self._snapshot_uri = await self.device.async_get_snapshot_uri(
|
||||
self.profile
|
||||
)
|
||||
|
||||
auth = None
|
||||
if self.device.username and self.device.password:
|
||||
auth = HTTPDigestAuth(self.device.username, self.device.password)
|
||||
@ -181,6 +171,16 @@ class ONVIFCameraEntity(ONVIFBaseEntity, Camera):
|
||||
finally:
|
||||
await stream.close()
|
||||
|
||||
async def async_added_to_hass(self):
|
||||
"""Run when entity about to be added to hass."""
|
||||
uri_no_auth = await self.device.async_get_stream_uri(self.profile)
|
||||
self._stream_uri = uri_no_auth.replace(
|
||||
"rtsp://", f"rtsp://{self.device.username}:{self.device.password}@", 1
|
||||
)
|
||||
|
||||
if self.device.capabilities.snapshot:
|
||||
self._snapshot_uri = await self.device.async_get_snapshot_uri(self.profile)
|
||||
|
||||
async def async_perform_ptz(
|
||||
self,
|
||||
distance,
|
||||
|
@ -223,7 +223,7 @@ class ONVIFDevice:
|
||||
try:
|
||||
media_service = self.device.create_media_service()
|
||||
media_capabilities = await media_service.GetServiceCapabilities()
|
||||
snapshot = media_capabilities.SnapshotUri
|
||||
snapshot = media_capabilities and media_capabilities.SnapshotUri
|
||||
except (ONVIFError, Fault):
|
||||
pass
|
||||
|
||||
@ -231,7 +231,7 @@ class ONVIFDevice:
|
||||
try:
|
||||
event_service = self.device.create_events_service()
|
||||
event_capabilities = await event_service.GetServiceCapabilities()
|
||||
pullpoint = event_capabilities.WSPullPointSupport
|
||||
pullpoint = event_capabilities and event_capabilities.WSPullPointSupport
|
||||
except (ONVIFError, Fault):
|
||||
pass
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user