Explicitly pass in the config_entry in tibber coordinator (#137904)

explicitly pass in the config_entry in coordinator
This commit is contained in:
Michael 2025-02-09 14:33:54 +01:00 committed by GitHub
parent eb81c935ce
commit 794143c32f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 13 additions and 4 deletions

View File

@ -33,11 +33,17 @@ class TibberDataCoordinator(DataUpdateCoordinator[None]):
config_entry: ConfigEntry
def __init__(self, hass: HomeAssistant, tibber_connection: tibber.Tibber) -> None:
def __init__(
self,
hass: HomeAssistant,
config_entry: ConfigEntry,
tibber_connection: tibber.Tibber,
) -> None:
"""Initialize the data handler."""
super().__init__(
hass,
_LOGGER,
config_entry=config_entry,
name=f"Tibber {tibber_connection.name}",
update_interval=timedelta(minutes=20),
)

View File

@ -285,7 +285,7 @@ async def async_setup_entry(
if home.has_active_subscription:
entities.append(TibberSensorElPrice(home))
if coordinator is None:
coordinator = TibberDataCoordinator(hass, tibber_connection)
coordinator = TibberDataCoordinator(hass, entry, tibber_connection)
entities.extend(
TibberDataSensor(home, coordinator, entity_description)
for entity_description in SENSORS

View File

@ -10,10 +10,13 @@ from homeassistant.util import dt as dt_util
from .test_common import CONSUMPTION_DATA_1, PRODUCTION_DATA_1, mock_get_homes
from tests.common import MockConfigEntry
from tests.components.recorder.common import async_wait_recording_done
async def test_async_setup_entry(recorder_mock: Recorder, hass: HomeAssistant) -> None:
async def test_async_setup_entry(
recorder_mock: Recorder, hass: HomeAssistant, config_entry: MockConfigEntry
) -> None:
"""Test setup Tibber."""
tibber_connection = AsyncMock()
tibber_connection.name = "tibber"
@ -21,7 +24,7 @@ async def test_async_setup_entry(recorder_mock: Recorder, hass: HomeAssistant) -
tibber_connection.fetch_production_data_active_homes.return_value = None
tibber_connection.get_homes = mock_get_homes
coordinator = TibberDataCoordinator(hass, tibber_connection)
coordinator = TibberDataCoordinator(hass, config_entry, tibber_connection)
await coordinator._async_update_data()
await async_wait_recording_done(hass)