summaryrefslogtreecommitdiff
path: root/include/py/homekit/camera
diff options
context:
space:
mode:
Diffstat (limited to 'include/py/homekit/camera')
-rw-r--r--include/py/homekit/camera/config.py24
-rw-r--r--include/py/homekit/camera/types.py5
2 files changed, 18 insertions, 11 deletions
diff --git a/include/py/homekit/camera/config.py b/include/py/homekit/camera/config.py
index 8aeb392..0ed75cf 100644
--- a/include/py/homekit/camera/config.py
+++ b/include/py/homekit/camera/config.py
@@ -30,6 +30,7 @@ class IpcamConfig(ConfigUnit):
'type': 'dict',
'schema': {
'type': {'type': 'string', 'allowed': [t.value for t in CameraType], 'required': True},
+ 'enabled': {'type': 'boolean'},
'motion': {
'type': 'dict',
'schema': {
@@ -87,13 +88,16 @@ class IpcamConfig(ConfigUnit):
@staticmethod
def custom_validator(data):
- for n, cam in data['cams'].items():
- linux_box = _lbc[cam['server']]
- if 'ext_hdd' not in linux_box:
- raise ValueError(f'cam-{n}: linux box {cam["server"]} must have ext_hdd defined')
- disk = cam['disk']-1
- if disk < 0 or disk >= len(linux_box['ext_hdd']):
- raise ValueError(f'cam-{n}: invalid disk index for linux box {cam["server"]}')
+ pass
+
+ # FIXME rewrite or delete, looks kinda obsolete
+ # for n, cam in data['cameras'].items():
+ # linux_box = _lbc[cam['server']]
+ # if 'ext_hdd' not in linux_box:
+ # raise ValueError(f'cam-{n}: linux box {cam["server"]} must have ext_hdd defined')
+ # disk = cam['disk']-1
+ # if disk < 0 or disk >= len(linux_box['ext_hdd']):
+ # raise ValueError(f'cam-{n}: invalid disk index for linux box {cam["server"]}')
@classmethod
def _url_templates_schema(cls) -> dict:
@@ -114,7 +118,7 @@ class IpcamConfig(ConfigUnit):
cams = []
if filter_by_server is not None and filter_by_server not in _lbc:
raise ValueError(f'invalid filter_by_server: {filter_by_server} not found in {_lbc.__class__.__name__}')
- for cam, params in self['cams'].items():
+ for cam, params in self['cameras'].items():
if filter_by_server is None or params['server'] == filter_by_server:
if filter_by_disk is None or params['disk'] == filter_by_disk:
cams.append(int(cam))
@@ -126,13 +130,13 @@ class IpcamConfig(ConfigUnit):
# filter_by_disk=filter_by_disk)
# def get_cam_server_and_disk(self, cam: int) -> tuple[str, int]:
- # return self['cams'][cam]['server'], self['cams'][cam]['disk']
+ # return self['cameras'][cam]['server'], self['cameras'][cam]['disk']
def get_camera_container(self, camera: int) -> VideoContainerType:
return self.get_camera_type(camera).get_container()
def get_camera_type(self, camera: int) -> CameraType:
- return CameraType(self['cams'][camera]['type'])
+ return CameraType(self['cameras'][camera]['type'])
def get_rtsp_creds(self) -> tuple[str, str]:
return self['rtsp_creds']['login'], self['rtsp_creds']['password']
diff --git a/include/py/homekit/camera/types.py b/include/py/homekit/camera/types.py
index da0fcc6..1a97e63 100644
--- a/include/py/homekit/camera/types.py
+++ b/include/py/homekit/camera/types.py
@@ -23,7 +23,7 @@ class CameraType(Enum):
if channel == 1:
return ''
elif channel == 2:
- if self.value in (CameraType.HIKVISION_264, CameraType.HIKVISION_265):
+ if self.is_hikvision():
return '/Streaming/Channels/2'
elif self.value == CameraType.ALIEXPRESS_NONAME:
return '/?stream=1.sdp'
@@ -41,6 +41,9 @@ class CameraType(Enum):
def get_container(self) -> VideoContainerType:
return VideoContainerType.MP4 if self.get_codec(1) == VideoCodecType.H264 else VideoContainerType.MOV
+ def is_hikvision(self) -> bool:
+ return self in (CameraType.HIKVISION_264.value, CameraType.HIKVISION_265)
+
class TimeFilterType(Enum):
FIX = 'fix'