From c7e17ffb365d113c9b2dedaa3e9d7b9a4f119a01 Mon Sep 17 00:00:00 2001 From: mib1185 Date: Sun, 9 Feb 2025 20:38:53 +0000 Subject: [PATCH] deprecate usage of ContextVar for config_entry in coordinator --- homeassistant/helpers/update_coordinator.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/homeassistant/helpers/update_coordinator.py b/homeassistant/helpers/update_coordinator.py index be765ff422d..fadb026d9bb 100644 --- a/homeassistant/helpers/update_coordinator.py +++ b/homeassistant/helpers/update_coordinator.py @@ -84,9 +84,18 @@ class DataUpdateCoordinator(BaseDataUpdateCoordinatorProtocol, Generic[_DataT]): self.update_interval = update_interval self._shutdown_requested = False if config_entry is UNDEFINED: + # late import to avoid circular imports + from . import frame # pylint: disable=import-outside-toplevel + + frame.report_usage( + "ContextVar used, should passing the config entry explicitly - see " + "https://developers.home-assistant.io/blog/xxxxxxx", + core_behavior=frame.ReportBehavior.ERROR, + custom_integration_behavior=frame.ReportBehavior.LOG, + breaks_in_ha_version="2026.3", + ) + self.config_entry = config_entries.current_entry.get() - # This should be deprecated once all core integrations are updated - # to pass in the config entry explicitly. else: self.config_entry = config_entry self.always_update = always_update