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.
This commit is contained in:
Diego Elio Pettenò 2022-04-30 00:21:12 +01:00 committed by GitHub
parent 852eaa062c
commit cef5d6054c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 4 additions and 6 deletions

View File

@ -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),
),
},
}

View File

@ -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],
),
)

View File

@ -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):