mirror of
https://github.com/home-assistant/core.git
synced 2025-08-02 10:08:23 +00:00
Fix ContextVar usage in FirmwareUpdateCoordinator by passing config_entry explicitly
Co-authored-by: joostlek <7083755+joostlek@users.noreply.github.com>
This commit is contained in:
parent
1ebdf2095a
commit
ad648a9dec
@ -12,6 +12,7 @@ from ha_silabs_firmware_client import (
|
||||
ManifestMissing,
|
||||
)
|
||||
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator, UpdateFailed
|
||||
|
||||
@ -24,13 +25,20 @@ FIRMWARE_REFRESH_INTERVAL = timedelta(hours=8)
|
||||
class FirmwareUpdateCoordinator(DataUpdateCoordinator[FirmwareManifest]):
|
||||
"""Coordinator to manage firmware updates."""
|
||||
|
||||
def __init__(self, hass: HomeAssistant, session: ClientSession, url: str) -> None:
|
||||
def __init__(
|
||||
self,
|
||||
hass: HomeAssistant,
|
||||
session: ClientSession,
|
||||
url: str,
|
||||
config_entry: ConfigEntry,
|
||||
) -> None:
|
||||
"""Initialize the firmware update coordinator."""
|
||||
super().__init__(
|
||||
hass,
|
||||
_LOGGER,
|
||||
name="firmware update coordinator",
|
||||
update_interval=FIRMWARE_REFRESH_INTERVAL,
|
||||
config_entry=config_entry,
|
||||
)
|
||||
self.hass = hass
|
||||
self.session = session
|
||||
|
@ -126,6 +126,7 @@ def _async_create_update_entity(
|
||||
hass,
|
||||
session,
|
||||
NABU_CASA_FIRMWARE_RELEASES_URL,
|
||||
config_entry,
|
||||
),
|
||||
entity_description=entity_description,
|
||||
)
|
||||
|
@ -131,6 +131,7 @@ def _async_create_update_entity(
|
||||
hass,
|
||||
session,
|
||||
NABU_CASA_FIRMWARE_RELEASES_URL,
|
||||
config_entry,
|
||||
),
|
||||
entity_description=entity_description,
|
||||
)
|
||||
|
@ -9,6 +9,7 @@ from yarl import URL
|
||||
from homeassistant.components.homeassistant_hardware.coordinator import (
|
||||
FirmwareUpdateCoordinator,
|
||||
)
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
||||
from homeassistant.util import dt as dt_util
|
||||
@ -20,6 +21,9 @@ async def test_firmware_update_coordinator_fetching(
|
||||
"""Test the firmware update coordinator loads manifests."""
|
||||
session = async_get_clientsession(hass)
|
||||
|
||||
# Create a mock config entry
|
||||
mock_config_entry = Mock(spec=ConfigEntry)
|
||||
|
||||
manifest = FirmwareManifest(
|
||||
url=URL("https://example.org/firmware"),
|
||||
html_url=URL("https://example.org/release_notes"),
|
||||
@ -35,7 +39,7 @@ async def test_firmware_update_coordinator_fetching(
|
||||
return_value=mock_client,
|
||||
):
|
||||
coordinator = FirmwareUpdateCoordinator(
|
||||
hass, session, "https://example.org/firmware"
|
||||
hass, session, "https://example.org/firmware", mock_config_entry
|
||||
)
|
||||
|
||||
listener = Mock()
|
||||
|
@ -145,6 +145,7 @@ def _mock_async_create_update_entity(
|
||||
hass,
|
||||
session,
|
||||
TEST_FIRMWARE_RELEASES_URL,
|
||||
config_entry,
|
||||
),
|
||||
entity_description=entity_description,
|
||||
)
|
||||
@ -595,6 +596,7 @@ async def test_update_entity_graceful_firmware_type_callback_errors(
|
||||
hass,
|
||||
session,
|
||||
TEST_FIRMWARE_RELEASES_URL,
|
||||
update_config_entry,
|
||||
),
|
||||
entity_description=TEST_FIRMWARE_ENTITY_DESCRIPTIONS[ApplicationType.EZSP],
|
||||
)
|
||||
|
Loading…
x
Reference in New Issue
Block a user