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:
Copilot 2025-07-31 12:06:04 +02:00 committed by GitHub
parent 42101dd432
commit 3952544822
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 18 additions and 2 deletions

View File

@ -12,6 +12,7 @@ from ha_silabs_firmware_client import (
ManifestMissing, ManifestMissing,
) )
from homeassistant.config_entries import ConfigEntry
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator, UpdateFailed from homeassistant.helpers.update_coordinator import DataUpdateCoordinator, UpdateFailed
@ -24,13 +25,20 @@ FIRMWARE_REFRESH_INTERVAL = timedelta(hours=8)
class FirmwareUpdateCoordinator(DataUpdateCoordinator[FirmwareManifest]): class FirmwareUpdateCoordinator(DataUpdateCoordinator[FirmwareManifest]):
"""Coordinator to manage firmware updates.""" """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.""" """Initialize the firmware update coordinator."""
super().__init__( super().__init__(
hass, hass,
_LOGGER, _LOGGER,
name="firmware update coordinator", name="firmware update coordinator",
update_interval=FIRMWARE_REFRESH_INTERVAL, update_interval=FIRMWARE_REFRESH_INTERVAL,
config_entry=config_entry,
) )
self.hass = hass self.hass = hass
self.session = session self.session = session

View File

@ -124,6 +124,7 @@ def _async_create_update_entity(
config_entry=config_entry, config_entry=config_entry,
update_coordinator=FirmwareUpdateCoordinator( update_coordinator=FirmwareUpdateCoordinator(
hass, hass,
config_entry,
session, session,
NABU_CASA_FIRMWARE_RELEASES_URL, NABU_CASA_FIRMWARE_RELEASES_URL,
), ),

View File

@ -129,6 +129,7 @@ def _async_create_update_entity(
config_entry=config_entry, config_entry=config_entry,
update_coordinator=FirmwareUpdateCoordinator( update_coordinator=FirmwareUpdateCoordinator(
hass, hass,
config_entry,
session, session,
NABU_CASA_FIRMWARE_RELEASES_URL, NABU_CASA_FIRMWARE_RELEASES_URL,
), ),

View File

@ -13,6 +13,8 @@ from homeassistant.core import HomeAssistant
from homeassistant.helpers.aiohttp_client import async_get_clientsession from homeassistant.helpers.aiohttp_client import async_get_clientsession
from homeassistant.util import dt as dt_util from homeassistant.util import dt as dt_util
from tests.common import MockConfigEntry
async def test_firmware_update_coordinator_fetching( async def test_firmware_update_coordinator_fetching(
hass: HomeAssistant, caplog: pytest.LogCaptureFixture hass: HomeAssistant, caplog: pytest.LogCaptureFixture
@ -20,6 +22,8 @@ async def test_firmware_update_coordinator_fetching(
"""Test the firmware update coordinator loads manifests.""" """Test the firmware update coordinator loads manifests."""
session = async_get_clientsession(hass) session = async_get_clientsession(hass)
mock_config_entry = MockConfigEntry()
manifest = FirmwareManifest( manifest = FirmwareManifest(
url=URL("https://example.org/firmware"), url=URL("https://example.org/firmware"),
html_url=URL("https://example.org/release_notes"), html_url=URL("https://example.org/release_notes"),
@ -35,7 +39,7 @@ async def test_firmware_update_coordinator_fetching(
return_value=mock_client, return_value=mock_client,
): ):
coordinator = FirmwareUpdateCoordinator( coordinator = FirmwareUpdateCoordinator(
hass, session, "https://example.org/firmware" hass, mock_config_entry, session, "https://example.org/firmware"
) )
listener = Mock() listener = Mock()

View File

@ -143,6 +143,7 @@ def _mock_async_create_update_entity(
config_entry=config_entry, config_entry=config_entry,
update_coordinator=FirmwareUpdateCoordinator( update_coordinator=FirmwareUpdateCoordinator(
hass, hass,
config_entry,
session, session,
TEST_FIRMWARE_RELEASES_URL, TEST_FIRMWARE_RELEASES_URL,
), ),
@ -593,6 +594,7 @@ async def test_update_entity_graceful_firmware_type_callback_errors(
config_entry=update_config_entry, config_entry=update_config_entry,
update_coordinator=FirmwareUpdateCoordinator( update_coordinator=FirmwareUpdateCoordinator(
hass, hass,
update_config_entry,
session, session,
TEST_FIRMWARE_RELEASES_URL, TEST_FIRMWARE_RELEASES_URL,
), ),