From cef5d6054c620a13176fb98f54ff5e17c6f3001f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Diego=20Elio=20Petten=C3=B2?= Date: Sat, 30 Apr 2022 00:21:12 +0100 Subject: [PATCH] withings: don't store the webhook URL in the state. (#69191) The webhook url should be calculated at startup, not stored in the state as otherwise a change in network requires re-configuring the integration from scratch. This is particularly important as external network configuration might change when moving HA between networks, and it's not obvious it needs to be re-added just for this. --- homeassistant/components/withings/__init__.py | 4 ---- homeassistant/components/withings/common.py | 5 ++++- homeassistant/components/withings/const.py | 1 - 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/homeassistant/components/withings/__init__.py b/homeassistant/components/withings/__init__.py index 701694e40e9..9d1fe1a600f 100644 --- a/homeassistant/components/withings/__init__.py +++ b/homeassistant/components/withings/__init__.py @@ -111,10 +111,6 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: const.CONF_USE_WEBHOOK ], CONF_WEBHOOK_ID: webhook_id, - const.CONF_WEBHOOK_URL: entry.data.get( - const.CONF_WEBHOOK_URL, - webhook.async_generate_url(hass, webhook_id), - ), }, } diff --git a/homeassistant/components/withings/common.py b/homeassistant/components/withings/common.py index f2fe7bfb1ec..c0dadb47924 100644 --- a/homeassistant/components/withings/common.py +++ b/homeassistant/components/withings/common.py @@ -27,6 +27,7 @@ from withings_api.common import ( query_measure_groups, ) +from homeassistant.components import webhook from homeassistant.components.binary_sensor import DOMAIN as BINARY_SENSOR_DOMAIN from homeassistant.components.http import HomeAssistantView from homeassistant.components.sensor import DOMAIN as SENSOR_DOMAIN @@ -1046,7 +1047,9 @@ async def async_get_data_manager( config_entry.data["token"]["userid"], WebhookConfig( id=config_entry.data[CONF_WEBHOOK_ID], - url=config_entry.data[const.CONF_WEBHOOK_URL], + url=webhook.async_generate_url( + hass, config_entry.data[CONF_WEBHOOK_ID] + ), enabled=config_entry.data[const.CONF_USE_WEBHOOK], ), ) diff --git a/homeassistant/components/withings/const.py b/homeassistant/components/withings/const.py index dd744152bb1..a5a99c193ab 100644 --- a/homeassistant/components/withings/const.py +++ b/homeassistant/components/withings/const.py @@ -13,7 +13,6 @@ DOMAIN = "withings" LOG_NAMESPACE = "homeassistant.components.withings" PROFILE = "profile" PUSH_HANDLER = "push_handler" -CONF_WEBHOOK_URL = "webhook_url" class Measurement(Enum):