Added support for Wyze bridge camera mapping

This commit is contained in:
Ashish D'Souza 2024-02-18 10:45:13 -06:00
parent 91ca9e88bc
commit c7e07f309d
1 changed files with 7 additions and 1 deletions

View File

@ -12,6 +12,7 @@ logger = logging.getLogger(__name__)
class FrigateConfig:
_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:
self._frigate_config_url = f'{frigate_base_url}/api/config'
@ -56,7 +57,12 @@ class FrigateConfig:
@classmethod
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:
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()