mirror of
https://github.com/home-assistant/core.git
synced 2025-07-24 21:57:51 +00:00
Fix package camera snapshot (#64145)
This commit is contained in:
parent
8f8ea5b102
commit
f4b5b56427
@ -162,7 +162,10 @@ class ProtectCamera(ProtectDeviceEntity, Camera):
|
|||||||
self, width: int | None = None, height: int | None = None
|
self, width: int | None = None, height: int | None = None
|
||||||
) -> bytes | None:
|
) -> bytes | None:
|
||||||
"""Return the Camera Image."""
|
"""Return the Camera Image."""
|
||||||
last_image = await self.device.get_snapshot(width, height)
|
if self.channel.is_package:
|
||||||
|
last_image = await self.device.get_package_snapshot(width, height)
|
||||||
|
else:
|
||||||
|
last_image = await self.device.get_snapshot(width, height)
|
||||||
self._last_image = last_image
|
self._last_image = last_image
|
||||||
return self._last_image
|
return self._last_image
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
"config_flow": true,
|
"config_flow": true,
|
||||||
"documentation": "https://www.home-assistant.io/integrations/unifiprotect",
|
"documentation": "https://www.home-assistant.io/integrations/unifiprotect",
|
||||||
"requirements": [
|
"requirements": [
|
||||||
"pyunifiprotect==1.6.3"
|
"pyunifiprotect==1.7.0"
|
||||||
],
|
],
|
||||||
"dependencies": [
|
"dependencies": [
|
||||||
"http"
|
"http"
|
||||||
|
@ -2015,7 +2015,7 @@ pytrafikverket==0.1.6.2
|
|||||||
pyudev==0.22.0
|
pyudev==0.22.0
|
||||||
|
|
||||||
# homeassistant.components.unifiprotect
|
# homeassistant.components.unifiprotect
|
||||||
pyunifiprotect==1.6.3
|
pyunifiprotect==1.7.0
|
||||||
|
|
||||||
# homeassistant.components.uptimerobot
|
# homeassistant.components.uptimerobot
|
||||||
pyuptimerobot==21.11.0
|
pyuptimerobot==21.11.0
|
||||||
|
@ -1240,7 +1240,7 @@ pytrafikverket==0.1.6.2
|
|||||||
pyudev==0.22.0
|
pyudev==0.22.0
|
||||||
|
|
||||||
# homeassistant.components.unifiprotect
|
# homeassistant.components.unifiprotect
|
||||||
pyunifiprotect==1.6.3
|
pyunifiprotect==1.7.0
|
||||||
|
|
||||||
# homeassistant.components.uptimerobot
|
# homeassistant.components.uptimerobot
|
||||||
pyuptimerobot==21.11.0
|
pyuptimerobot==21.11.0
|
||||||
|
@ -73,6 +73,44 @@ async def camera_fixture(
|
|||||||
return (camera_obj, "camera.test_camera_high")
|
return (camera_obj, "camera.test_camera_high")
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.fixture(name="camera_package")
|
||||||
|
async def camera_package_fixture(
|
||||||
|
hass: HomeAssistant, mock_entry: MockEntityFixture, mock_camera: Camera
|
||||||
|
):
|
||||||
|
"""Fixture for a single camera for testing the camera platform."""
|
||||||
|
|
||||||
|
camera_obj = mock_camera.copy(deep=True)
|
||||||
|
camera_obj._api = mock_entry.api
|
||||||
|
camera_obj.channels[0]._api = mock_entry.api
|
||||||
|
camera_obj.channels[1]._api = mock_entry.api
|
||||||
|
camera_obj.channels[2]._api = mock_entry.api
|
||||||
|
camera_obj.name = "Test Camera"
|
||||||
|
camera_obj.feature_flags.has_package_camera = True
|
||||||
|
camera_obj.channels[0].is_rtsp_enabled = True
|
||||||
|
camera_obj.channels[0].name = "High"
|
||||||
|
camera_obj.channels[0].rtsp_alias = "test_high_alias"
|
||||||
|
camera_obj.channels[1].is_rtsp_enabled = False
|
||||||
|
camera_obj.channels[2].is_rtsp_enabled = False
|
||||||
|
package_channel = camera_obj.channels[0].copy(deep=True)
|
||||||
|
package_channel.is_rtsp_enabled = False
|
||||||
|
package_channel.name = "Package Camera"
|
||||||
|
package_channel.id = 3
|
||||||
|
package_channel.fps = 2
|
||||||
|
package_channel.rtsp_alias = "test_package_alias"
|
||||||
|
camera_obj.channels.append(package_channel)
|
||||||
|
|
||||||
|
mock_entry.api.bootstrap.cameras = {
|
||||||
|
camera_obj.id: camera_obj,
|
||||||
|
}
|
||||||
|
|
||||||
|
await hass.config_entries.async_setup(mock_entry.entry.entry_id)
|
||||||
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
|
assert_entity_counts(hass, Platform.CAMERA, 3, 2)
|
||||||
|
|
||||||
|
return (camera_obj, "camera.test_camera_package_camera")
|
||||||
|
|
||||||
|
|
||||||
def validate_default_camera_entity(
|
def validate_default_camera_entity(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
camera_obj: ProtectCamera,
|
camera_obj: ProtectCamera,
|
||||||
@ -383,6 +421,19 @@ async def test_camera_image(
|
|||||||
mock_entry.api.get_camera_snapshot.assert_called_once()
|
mock_entry.api.get_camera_snapshot.assert_called_once()
|
||||||
|
|
||||||
|
|
||||||
|
async def test_package_camera_image(
|
||||||
|
hass: HomeAssistant,
|
||||||
|
mock_entry: MockEntityFixture,
|
||||||
|
camera_package: tuple[Camera, str],
|
||||||
|
):
|
||||||
|
"""Test retrieving package camera image."""
|
||||||
|
|
||||||
|
mock_entry.api.get_package_camera_snapshot = AsyncMock()
|
||||||
|
|
||||||
|
await async_get_image(hass, camera_package[1])
|
||||||
|
mock_entry.api.get_package_camera_snapshot.assert_called_once()
|
||||||
|
|
||||||
|
|
||||||
async def test_camera_generic_update(
|
async def test_camera_generic_update(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
mock_entry: MockEntityFixture,
|
mock_entry: MockEntityFixture,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user