Explicitly pass in the config_entry in withings coordinator (#137866)

explicitly pass in the config_entry in coordinator
This commit is contained in:
Michael 2025-02-09 14:04:14 +01:00 committed by GitHub
parent 4d5987fa80
commit 0ecff272f2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 53 additions and 18 deletions

View File

@ -120,13 +120,17 @@ async def async_setup_entry(hass: HomeAssistant, entry: WithingsConfigEntry) ->
client.refresh_token_function = _refresh_token client.refresh_token_function = _refresh_token
withings_data = WithingsData( withings_data = WithingsData(
client=client, client=client,
measurement_coordinator=WithingsMeasurementDataUpdateCoordinator(hass, client), measurement_coordinator=WithingsMeasurementDataUpdateCoordinator(
sleep_coordinator=WithingsSleepDataUpdateCoordinator(hass, client), hass, entry, client
bed_presence_coordinator=WithingsBedPresenceDataUpdateCoordinator(hass, client), ),
goals_coordinator=WithingsGoalsDataUpdateCoordinator(hass, client), sleep_coordinator=WithingsSleepDataUpdateCoordinator(hass, entry, client),
activity_coordinator=WithingsActivityDataUpdateCoordinator(hass, client), bed_presence_coordinator=WithingsBedPresenceDataUpdateCoordinator(
workout_coordinator=WithingsWorkoutDataUpdateCoordinator(hass, client), hass, entry, client
device_coordinator=WithingsDeviceDataUpdateCoordinator(hass, client), ),
goals_coordinator=WithingsGoalsDataUpdateCoordinator(hass, entry, client),
activity_coordinator=WithingsActivityDataUpdateCoordinator(hass, entry, client),
workout_coordinator=WithingsWorkoutDataUpdateCoordinator(hass, entry, client),
device_coordinator=WithingsDeviceDataUpdateCoordinator(hass, entry, client),
) )
for coordinator in withings_data.coordinators: for coordinator in withings_data.coordinators:

View File

@ -44,11 +44,17 @@ class WithingsDataUpdateCoordinator[_DataT](DataUpdateCoordinator[_DataT]):
webhooks_connected: bool = False webhooks_connected: bool = False
coordinator_name: str = "" coordinator_name: str = ""
def __init__(self, hass: HomeAssistant, client: WithingsClient) -> None: def __init__(
self,
hass: HomeAssistant,
config_entry: WithingsConfigEntry,
client: WithingsClient,
) -> None:
"""Initialize the Withings data coordinator.""" """Initialize the Withings data coordinator."""
super().__init__( super().__init__(
hass, hass,
LOGGER, LOGGER,
config_entry=config_entry,
name="", name="",
update_interval=self._default_update_interval, update_interval=self._default_update_interval,
) )
@ -95,9 +101,14 @@ class WithingsMeasurementDataUpdateCoordinator(
coordinator_name: str = "measurements" coordinator_name: str = "measurements"
def __init__(self, hass: HomeAssistant, client: WithingsClient) -> None: def __init__(
self,
hass: HomeAssistant,
config_entry: WithingsConfigEntry,
client: WithingsClient,
) -> None:
"""Initialize the Withings data coordinator.""" """Initialize the Withings data coordinator."""
super().__init__(hass, client) super().__init__(hass, config_entry, client)
self.notification_categories = { self.notification_categories = {
NotificationCategory.WEIGHT, NotificationCategory.WEIGHT,
NotificationCategory.PRESSURE, NotificationCategory.PRESSURE,
@ -133,9 +144,14 @@ class WithingsSleepDataUpdateCoordinator(
coordinator_name: str = "sleep" coordinator_name: str = "sleep"
def __init__(self, hass: HomeAssistant, client: WithingsClient) -> None: def __init__(
self,
hass: HomeAssistant,
config_entry: WithingsConfigEntry,
client: WithingsClient,
) -> None:
"""Initialize the Withings data coordinator.""" """Initialize the Withings data coordinator."""
super().__init__(hass, client) super().__init__(hass, config_entry, client)
self.notification_categories = { self.notification_categories = {
NotificationCategory.SLEEP, NotificationCategory.SLEEP,
} }
@ -184,9 +200,14 @@ class WithingsBedPresenceDataUpdateCoordinator(WithingsDataUpdateCoordinator[Non
in_bed: bool | None = None in_bed: bool | None = None
_default_update_interval = None _default_update_interval = None
def __init__(self, hass: HomeAssistant, client: WithingsClient) -> None: def __init__(
self,
hass: HomeAssistant,
config_entry: WithingsConfigEntry,
client: WithingsClient,
) -> None:
"""Initialize the Withings data coordinator.""" """Initialize the Withings data coordinator."""
super().__init__(hass, client) super().__init__(hass, config_entry, client)
self.notification_categories = { self.notification_categories = {
NotificationCategory.IN_BED, NotificationCategory.IN_BED,
NotificationCategory.OUT_BED, NotificationCategory.OUT_BED,
@ -226,9 +247,14 @@ class WithingsActivityDataUpdateCoordinator(
coordinator_name: str = "activity" coordinator_name: str = "activity"
_previous_data: Activity | None = None _previous_data: Activity | None = None
def __init__(self, hass: HomeAssistant, client: WithingsClient) -> None: def __init__(
self,
hass: HomeAssistant,
config_entry: WithingsConfigEntry,
client: WithingsClient,
) -> None:
"""Initialize the Withings data coordinator.""" """Initialize the Withings data coordinator."""
super().__init__(hass, client) super().__init__(hass, config_entry, client)
self.notification_categories = { self.notification_categories = {
NotificationCategory.ACTIVITY, NotificationCategory.ACTIVITY,
} }
@ -265,9 +291,14 @@ class WithingsWorkoutDataUpdateCoordinator(
coordinator_name: str = "workout" coordinator_name: str = "workout"
_previous_data: Workout | None = None _previous_data: Workout | None = None
def __init__(self, hass: HomeAssistant, client: WithingsClient) -> None: def __init__(
self,
hass: HomeAssistant,
config_entry: WithingsConfigEntry,
client: WithingsClient,
) -> None:
"""Initialize the Withings data coordinator.""" """Initialize the Withings data coordinator."""
super().__init__(hass, client) super().__init__(hass, config_entry, client)
self.notification_categories = { self.notification_categories = {
NotificationCategory.ACTIVITY, NotificationCategory.ACTIVITY,
} }