mirror of
https://github.com/home-assistant/core.git
synced 2025-07-20 19:57:07 +00:00
Fix disabled Synology DSM camera (#41686)
This commit is contained in:
parent
e072d8b694
commit
897340b115
@ -2,12 +2,13 @@
|
|||||||
from typing import Dict
|
from typing import Dict
|
||||||
|
|
||||||
from synology_dsm.api.surveillance_station import SynoSurveillanceStation
|
from synology_dsm.api.surveillance_station import SynoSurveillanceStation
|
||||||
|
from synology_dsm.api.surveillance_station.camera import SynoCamera
|
||||||
|
|
||||||
from homeassistant.components.camera import SUPPORT_STREAM, Camera
|
from homeassistant.components.camera import SUPPORT_STREAM, Camera
|
||||||
from homeassistant.config_entries import ConfigEntry
|
from homeassistant.config_entries import ConfigEntry
|
||||||
from homeassistant.helpers.typing import HomeAssistantType
|
from homeassistant.helpers.typing import HomeAssistantType
|
||||||
|
|
||||||
from . import SynologyDSMEntity
|
from . import SynoApi, SynologyDSMEntity
|
||||||
from .const import (
|
from .const import (
|
||||||
DOMAIN,
|
DOMAIN,
|
||||||
ENTITY_CLASS,
|
ENTITY_CLASS,
|
||||||
@ -40,7 +41,7 @@ async def async_setup_entry(
|
|||||||
class SynoDSMCamera(SynologyDSMEntity, Camera):
|
class SynoDSMCamera(SynologyDSMEntity, Camera):
|
||||||
"""Representation a Synology camera."""
|
"""Representation a Synology camera."""
|
||||||
|
|
||||||
def __init__(self, api, camera):
|
def __init__(self, api: SynoApi, camera: SynoCamera):
|
||||||
"""Initialize a Synology camera."""
|
"""Initialize a Synology camera."""
|
||||||
super().__init__(
|
super().__init__(
|
||||||
api,
|
api,
|
||||||
@ -69,6 +70,11 @@ class SynoDSMCamera(SynologyDSMEntity, Camera):
|
|||||||
),
|
),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@property
|
||||||
|
def available(self) -> bool:
|
||||||
|
"""Return the availability of the camera."""
|
||||||
|
return self._camera.is_enabled
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def supported_features(self) -> int:
|
def supported_features(self) -> int:
|
||||||
"""Return supported features of this camera."""
|
"""Return supported features of this camera."""
|
||||||
@ -86,10 +92,14 @@ class SynoDSMCamera(SynologyDSMEntity, Camera):
|
|||||||
|
|
||||||
def camera_image(self) -> bytes:
|
def camera_image(self) -> bytes:
|
||||||
"""Return bytes of camera image."""
|
"""Return bytes of camera image."""
|
||||||
|
if not self.available:
|
||||||
|
return None
|
||||||
return self._api.surveillance_station.get_camera_image(self._camera.id)
|
return self._api.surveillance_station.get_camera_image(self._camera.id)
|
||||||
|
|
||||||
async def stream_source(self) -> str:
|
async def stream_source(self) -> str:
|
||||||
"""Return the source of the stream."""
|
"""Return the source of the stream."""
|
||||||
|
if not self.available:
|
||||||
|
return None
|
||||||
return self._camera.live_view.rtsp
|
return self._camera.live_view.rtsp
|
||||||
|
|
||||||
def enable_motion_detection(self):
|
def enable_motion_detection(self):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user