Skip to content

Commit 3952544

Browse files
Copilotjoostlekmib1185
authored
Fix ContextVar deprecation warning in homeassistant_hardware integration (home-assistant#149687)
Co-authored-by: copilot-swe-agent[bot] <[email protected]> Co-authored-by: joostlek <[email protected]> Co-authored-by: mib1185 <[email protected]>
1 parent 42101dd commit 3952544

File tree

5 files changed

+18
-2
lines changed

5 files changed

+18
-2
lines changed

homeassistant/components/homeassistant_hardware/coordinator.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
ManifestMissing,
1313
)
1414

15+
from homeassistant.config_entries import ConfigEntry
1516
from homeassistant.core import HomeAssistant
1617
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator, UpdateFailed
1718

@@ -24,13 +25,20 @@
2425
class FirmwareUpdateCoordinator(DataUpdateCoordinator[FirmwareManifest]):
2526
"""Coordinator to manage firmware updates."""
2627

27-
def __init__(self, hass: HomeAssistant, session: ClientSession, url: str) -> None:
28+
def __init__(
29+
self,
30+
hass: HomeAssistant,
31+
config_entry: ConfigEntry,
32+
session: ClientSession,
33+
url: str,
34+
) -> None:
2835
"""Initialize the firmware update coordinator."""
2936
super().__init__(
3037
hass,
3138
_LOGGER,
3239
name="firmware update coordinator",
3340
update_interval=FIRMWARE_REFRESH_INTERVAL,
41+
config_entry=config_entry,
3442
)
3543
self.hass = hass
3644
self.session = session

homeassistant/components/homeassistant_sky_connect/update.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ def _async_create_update_entity(
124124
config_entry=config_entry,
125125
update_coordinator=FirmwareUpdateCoordinator(
126126
hass,
127+
config_entry,
127128
session,
128129
NABU_CASA_FIRMWARE_RELEASES_URL,
129130
),

homeassistant/components/homeassistant_yellow/update.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ def _async_create_update_entity(
129129
config_entry=config_entry,
130130
update_coordinator=FirmwareUpdateCoordinator(
131131
hass,
132+
config_entry,
132133
session,
133134
NABU_CASA_FIRMWARE_RELEASES_URL,
134135
),

tests/components/homeassistant_hardware/test_coordinator.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,17 @@
1313
from homeassistant.helpers.aiohttp_client import async_get_clientsession
1414
from homeassistant.util import dt as dt_util
1515

16+
from tests.common import MockConfigEntry
17+
1618

1719
async def test_firmware_update_coordinator_fetching(
1820
hass: HomeAssistant, caplog: pytest.LogCaptureFixture
1921
) -> None:
2022
"""Test the firmware update coordinator loads manifests."""
2123
session = async_get_clientsession(hass)
2224

25+
mock_config_entry = MockConfigEntry()
26+
2327
manifest = FirmwareManifest(
2428
url=URL("https://example.org/firmware"),
2529
html_url=URL("https://example.org/release_notes"),
@@ -35,7 +39,7 @@ async def test_firmware_update_coordinator_fetching(
3539
return_value=mock_client,
3640
):
3741
coordinator = FirmwareUpdateCoordinator(
38-
hass, session, "https://example.org/firmware"
42+
hass, mock_config_entry, session, "https://example.org/firmware"
3943
)
4044

4145
listener = Mock()

tests/components/homeassistant_hardware/test_update.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@ def _mock_async_create_update_entity(
143143
config_entry=config_entry,
144144
update_coordinator=FirmwareUpdateCoordinator(
145145
hass,
146+
config_entry,
146147
session,
147148
TEST_FIRMWARE_RELEASES_URL,
148149
),
@@ -593,6 +594,7 @@ async def test_update_entity_graceful_firmware_type_callback_errors(
593594
config_entry=update_config_entry,
594595
update_coordinator=FirmwareUpdateCoordinator(
595596
hass,
597+
update_config_entry,
596598
session,
597599
TEST_FIRMWARE_RELEASES_URL,
598600
),

0 commit comments

Comments
 (0)