Added support for Wyze bridge camera mapping
This commit is contained in:
parent
91ca9e88bc
commit
c7e07f309d
|
@ -12,6 +12,7 @@ logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
class FrigateConfig:
|
class FrigateConfig:
|
||||||
_URL_ADDRESS_REGEX: ClassVar[Pattern[str]] = re.compile('(^|(?<=://)|(?<=@))[a-z0-9.\\-]+(:[0-9]+)?($|(?=/))')
|
_URL_ADDRESS_REGEX: ClassVar[Pattern[str]] = re.compile('(^|(?<=://)|(?<=@))[a-z0-9.\\-]+(:[0-9]+)?($|(?=/))')
|
||||||
|
_WYZE_CAMERAS: ClassVar[dict[str, str]] = {'back_yard_cam': '192.168.0.202:554'}
|
||||||
|
|
||||||
def __init__(self, frigate_base_url: str = 'http://frigate:5000') -> None:
|
def __init__(self, frigate_base_url: str = 'http://frigate:5000') -> None:
|
||||||
self._frigate_config_url = f'{frigate_base_url}/api/config'
|
self._frigate_config_url = f'{frigate_base_url}/api/config'
|
||||||
|
@ -56,7 +57,12 @@ class FrigateConfig:
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def _get_address_from_url(cls, url: str) -> str:
|
def _get_address_from_url(cls, url: str) -> str:
|
||||||
match = cls._URL_ADDRESS_REGEX.search(url)
|
match = cls._URL_ADDRESS_REGEX.search(url.lower())
|
||||||
if match is None:
|
if match is None:
|
||||||
raise ValueError(f'Failed to retrieve address from {url=}')
|
raise ValueError(f'Failed to retrieve address from {url=}')
|
||||||
|
|
||||||
|
# Handle case of wyze-bridge and hardcode cameras
|
||||||
|
if match.group().startswith('wyze-bridge'):
|
||||||
|
wyze_camera = url.lower().rsplit('/', 1)[-1].replace('-', '_')
|
||||||
|
return cls._WYZE_CAMERAS[wyze_camera]
|
||||||
return match.group()
|
return match.group()
|
||||||
|
|
Loading…
Reference in New Issue