diff --git a/custom_components/frigate/__init__.py b/custom_components/frigate/__init__.py index 233ad9a5..87f8cb2e 100644 --- a/custom_components/frigate/__init__.py +++ b/custom_components/frigate/__init__.py @@ -204,6 +204,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: async_get_clientsession(hass), entry.data.get(CONF_USERNAME), entry.data.get(CONF_PASSWORD), + bool(entry.data.get("validate_ssl")), ) coordinator = FrigateDataUpdateCoordinator(hass, client=client) await coordinator.async_config_entry_first_refresh() diff --git a/custom_components/frigate/api.py b/custom_components/frigate/api.py index a39e4217..0e7a5c33 100644 --- a/custom_components/frigate/api.py +++ b/custom_components/frigate/api.py @@ -40,6 +40,7 @@ def __init__( session: aiohttp.ClientSession, username: str | None = None, password: str | None = None, + validate_ssl: bool = True, ) -> None: """Construct API Client.""" self._host = host @@ -47,6 +48,7 @@ def __init__( self._username = username self._password = password self._token_data: dict[str, Any] = {} + self.validate_ssl = validate_ssl async def async_get_version(self) -> str: """Get data from the API.""" @@ -347,7 +349,11 @@ async def api_wrapper( func = getattr(self._session, method) if func: response = await func( - url, headers=headers, raise_for_status=True, json=data + url, + headers=headers, + raise_for_status=True, + json=data, + ssl=self.validate_ssl, ) response.raise_for_status() if is_login_request: diff --git a/custom_components/frigate/config_flow.py b/custom_components/frigate/config_flow.py index 39852f59..47c78dc3 100644 --- a/custom_components/frigate/config_flow.py +++ b/custom_components/frigate/config_flow.py @@ -83,6 +83,7 @@ async def _handle_config_step( session, user_input.get(CONF_USERNAME), user_input.get(CONF_PASSWORD), + bool(user_input.get("validate_ssl")), ) await client.async_get_stats() except FrigateApiClientError: @@ -121,6 +122,9 @@ def _show_config_form( vol.Required( CONF_URL, default=user_input.get(CONF_URL, DEFAULT_HOST) ): str, + vol.Required( + "validate_ssl", default=user_input.get("validate_ssl", True) + ): bool, vol.Optional( CONF_USERNAME, default=user_input.get(CONF_USERNAME, "") ): str, diff --git a/custom_components/frigate/translations/en.json b/custom_components/frigate/translations/en.json index 669ed8b8..f17cd4b0 100644 --- a/custom_components/frigate/translations/en.json +++ b/custom_components/frigate/translations/en.json @@ -5,6 +5,7 @@ "description": "URL you use to access Frigate (ie. `http://frigate:5000/`)\n\nIf you are using HassOS with the addon, the URL should be `http://ccab4aaf-frigate:5000/`\n\nHome Assistant needs access to port 5000 (api) and 8554/8555 (rtsp, webrtc) for all features.\n\nThe integration will setup sensors, cameras, and media browser functionality.\n\nSensors:\n- Stats to monitor frigate performance\n- Object counts for all zones and cameras\n\nCameras:\n- Cameras for image of the last detected object for each camera\n- Camera entities with stream support\n\nMedia Browser:\n- Rich UI with thumbnails for browsing event clips\n- Rich UI for browsing 24/7 recordings by month, day, camera, time\n\nAPI:\n- Notification API with public facing endpoints for images in notifications", "data": { "url": "URL", + "validate_ssl": "Validate SSL", "username": "Username (optional)", "password": "Password (optional)" } diff --git a/custom_components/frigate/translations/fr.json b/custom_components/frigate/translations/fr.json index 8704d828..9adff763 100644 --- a/custom_components/frigate/translations/fr.json +++ b/custom_components/frigate/translations/fr.json @@ -5,6 +5,7 @@ "description": "URL que vous utilisez pour accéder à Frigate (par exemple, `http://frigate:5000/`)\n\nSi vous utilisez HassOS avec l'addon, l'URL devrait être `http://ccab4aaf-frigate:5000/`\n\nHome Assistant a besoin d'accès au port 5000 (api) et 8554/8555 (rtsp, webrtc) pour toutes les fonctionnalités.\n\nL'intégration configurera des capteurs, des caméras et la fonctionnalité de navigateur multimédia.\n\nCapteurs :\n- Statistiques pour surveiller la performance de Frigate\n- Comptes d'objets pour toutes les zones et caméras\n\nCaméras :\n- Caméras pour l'image du dernier objet détecté pour chaque caméra\n- Entités de caméra avec support de flux\n\nNavigateur multimédia :\n- Interface riche avec miniatures pour parcourir les clips d'événements\n- Interface riche pour parcourir les enregistrements 24/7 par mois, jour, caméra, heure\n\nAPI :\n- API de notification avec des points de terminaison publics pour les images dans les notifications", "data": { "url": "URL", + "validate_ssl": "Valider SSL", "username": "Nom d'utilisateur (facultatif)", "password": "Mot de passe (facultatif)" } diff --git a/tests/test_config_flow.py b/tests/test_config_flow.py index 24938103..12a1dd40 100644 --- a/tests/test_config_flow.py +++ b/tests/test_config_flow.py @@ -62,6 +62,7 @@ async def test_user_success(hass: HomeAssistant) -> None: CONF_URL: TEST_URL, CONF_PASSWORD: "", CONF_USERNAME: "", + "validate_ssl": True, } assert len(mock_setup_entry.mock_calls) == 1 assert mock_client.async_get_stats.called @@ -90,6 +91,7 @@ async def test_user_success_with_auth(hass: HomeAssistant) -> None: CONF_PASSWORD: TEST_PASSWORD, CONF_URL: TEST_URL, CONF_USERNAME: TEST_USERNAME, + "validate_ssl": True, }, ) await hass.async_block_till_done() @@ -100,6 +102,7 @@ async def test_user_success_with_auth(hass: HomeAssistant) -> None: CONF_URL: TEST_URL, CONF_PASSWORD: TEST_PASSWORD, CONF_USERNAME: TEST_USERNAME, + "validate_ssl": True, } assert len(mock_setup_entry.mock_calls) == 1 assert mock_client.async_get_stats.called