mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 13:17:32 +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
|
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."""
|
"""Initialize the data handler."""
|
||||||
super().__init__(
|
super().__init__(
|
||||||
hass,
|
hass,
|
||||||
_LOGGER,
|
_LOGGER,
|
||||||
|
config_entry=config_entry,
|
||||||
name=f"Tibber {tibber_connection.name}",
|
name=f"Tibber {tibber_connection.name}",
|
||||||
update_interval=timedelta(minutes=20),
|
update_interval=timedelta(minutes=20),
|
||||||
)
|
)
|
||||||
|
@ -285,7 +285,7 @@ async def async_setup_entry(
|
|||||||
if home.has_active_subscription:
|
if home.has_active_subscription:
|
||||||
entities.append(TibberSensorElPrice(home))
|
entities.append(TibberSensorElPrice(home))
|
||||||
if coordinator is None:
|
if coordinator is None:
|
||||||
coordinator = TibberDataCoordinator(hass, tibber_connection)
|
coordinator = TibberDataCoordinator(hass, entry, tibber_connection)
|
||||||
entities.extend(
|
entities.extend(
|
||||||
TibberDataSensor(home, coordinator, entity_description)
|
TibberDataSensor(home, coordinator, entity_description)
|
||||||
for entity_description in SENSORS
|
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 .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
|
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."""
|
"""Test setup Tibber."""
|
||||||
tibber_connection = AsyncMock()
|
tibber_connection = AsyncMock()
|
||||||
tibber_connection.name = "tibber"
|
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.fetch_production_data_active_homes.return_value = None
|
||||||
tibber_connection.get_homes = mock_get_homes
|
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 coordinator._async_update_data()
|
||||||
await async_wait_recording_done(hass)
|
await async_wait_recording_done(hass)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user