mirror of
https://github.com/home-assistant/core.git
synced 2025-04-24 09:17:53 +00:00
Explicitly pass in the config_entry in tibber coordinator (#137904)
explicitly pass in the config_entry in coordinator
This commit is contained in:
parent
eb81c935ce
commit
794143c32f
@ -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),
|
||||
)
|
||||
|
@ -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
|
||||
|
@ -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)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user