diff --git a/homeassistant/components/withings/__init__.py b/homeassistant/components/withings/__init__.py index 9338c28da1c..bea4af3627a 100644 --- a/homeassistant/components/withings/__init__.py +++ b/homeassistant/components/withings/__init__.py @@ -259,10 +259,16 @@ class WithingsWebhookManager: self.hass, self.entry.data[CONF_WEBHOOK_ID] ) url = URL(webhook_url) - if url.scheme != "https" or url.port != 443: + if url.scheme != "https": LOGGER.warning( - "Webhook not registered - " - "https and port 443 is required to register the webhook" + "Webhook not registered - HTTPS is required. " + "See https://www.home-assistant.io/integrations/withings/#webhook-requirements" + ) + return + if url.port != 443: + LOGGER.warning( + "Webhook not registered - port 443 is required. " + "See https://www.home-assistant.io/integrations/withings/#webhook-requirements" ) return diff --git a/tests/components/withings/test_init.py b/tests/components/withings/test_init.py index 86c4f1d8cbb..b5035df7afe 100644 --- a/tests/components/withings/test_init.py +++ b/tests/components/withings/test_init.py @@ -348,7 +348,13 @@ async def test_setup_with_cloud( assert not hass.config_entries.async_entries(DOMAIN) -@pytest.mark.parametrize("url", ["http://example.com", "https://example.com:444"]) +@pytest.mark.parametrize( + ("url", "expected_message"), + [ + ("http://example.com", "HTTPS is required"), + ("https://example.com:444", "port 443 is required"), + ], +) async def test_setup_no_webhook( hass: HomeAssistant, webhook_config_entry: MockConfigEntry, @@ -356,6 +362,7 @@ async def test_setup_no_webhook( caplog: pytest.LogCaptureFixture, freezer: FrozenDateTimeFactory, url: str, + expected_message: str, ) -> None: """Test if set up with cloud link and without https.""" hass.config.components.add("cloud") @@ -378,7 +385,7 @@ async def test_setup_no_webhook( await hass.async_block_till_done() mock_async_generate_url.assert_called_once() - assert "https and port 443 is required to register the webhook" in caplog.text + assert expected_message in caplog.text async def test_cloud_disconnect(