mirror of
https://github.com/home-assistant/core.git
synced 2025-08-02 01:58:20 +00:00
Fix ContextVar deprecation warning in homeassistant_hardware integration (#149687)
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: joostlek <7083755+joostlek@users.noreply.github.com> Co-authored-by: mib1185 <35783820+mib1185@users.noreply.github.com>
This commit is contained in:
parent
42101dd432
commit
3952544822
@ -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,
|
||||
config_entry: ConfigEntry,
|
||||
session: ClientSession,
|
||||
url: str,
|
||||
) -> 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
|
||||
|
@ -124,6 +124,7 @@ def _async_create_update_entity(
|
||||
config_entry=config_entry,
|
||||
update_coordinator=FirmwareUpdateCoordinator(
|
||||
hass,
|
||||
config_entry,
|
||||
session,
|
||||
NABU_CASA_FIRMWARE_RELEASES_URL,
|
||||
),
|
||||
|
@ -129,6 +129,7 @@ def _async_create_update_entity(
|
||||
config_entry=config_entry,
|
||||
update_coordinator=FirmwareUpdateCoordinator(
|
||||
hass,
|
||||
config_entry,
|
||||
session,
|
||||
NABU_CASA_FIRMWARE_RELEASES_URL,
|
||||
),
|
||||
|
@ -13,6 +13,8 @@ from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
||||
from homeassistant.util import dt as dt_util
|
||||
|
||||
from tests.common import MockConfigEntry
|
||||
|
||||
|
||||
async def test_firmware_update_coordinator_fetching(
|
||||
hass: HomeAssistant, caplog: pytest.LogCaptureFixture
|
||||
@ -20,6 +22,8 @@ async def test_firmware_update_coordinator_fetching(
|
||||
"""Test the firmware update coordinator loads manifests."""
|
||||
session = async_get_clientsession(hass)
|
||||
|
||||
mock_config_entry = MockConfigEntry()
|
||||
|
||||
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, mock_config_entry, session, "https://example.org/firmware"
|
||||
)
|
||||
|
||||
listener = Mock()
|
||||
|
@ -143,6 +143,7 @@ def _mock_async_create_update_entity(
|
||||
config_entry=config_entry,
|
||||
update_coordinator=FirmwareUpdateCoordinator(
|
||||
hass,
|
||||
config_entry,
|
||||
session,
|
||||
TEST_FIRMWARE_RELEASES_URL,
|
||||
),
|
||||
@ -593,6 +594,7 @@ async def test_update_entity_graceful_firmware_type_callback_errors(
|
||||
config_entry=update_config_entry,
|
||||
update_coordinator=FirmwareUpdateCoordinator(
|
||||
hass,
|
||||
update_config_entry,
|
||||
session,
|
||||
TEST_FIRMWARE_RELEASES_URL,
|
||||
),
|
||||
|
Loading…
x
Reference in New Issue
Block a user