Migrate ruuvi_gateway to use entry.runtime_data (#176139)

This commit is contained in:
David Wu
2026-07-29 21:24:05 +08:00
committed by GitHub
parent f78ad3e324
commit 536cee8593
@@ -1,5 +1,4 @@
"""The Ruuvi Gateway integration."""
# pylint: disable=home-assistant-use-runtime-data # Uses legacy hass.data[DOMAIN] pattern
import logging
@@ -13,12 +12,16 @@ from .models import RuuviGatewayRuntimeData
_LOGGER = logging.getLogger(DOMAIN)
type RuuviGatewayConfigEntry = ConfigEntry[RuuviGatewayRuntimeData]
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
async def async_setup_entry(
hass: HomeAssistant, entry: RuuviGatewayConfigEntry
) -> bool:
"""Set up Ruuvi Gateway from a config entry."""
coordinator = RuuviGatewayUpdateCoordinator(hass, entry, _LOGGER)
scanner, unload_scanner = async_connect_scanner(hass, entry, coordinator)
hass.data.setdefault(DOMAIN, {})[entry.entry_id] = RuuviGatewayRuntimeData(
entry.runtime_data = RuuviGatewayRuntimeData(
update_coordinator=coordinator,
scanner=scanner,
)
@@ -26,9 +29,8 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
return True
async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
async def async_unload_entry(
hass: HomeAssistant, entry: RuuviGatewayConfigEntry
) -> bool:
"""Unload a config entry."""
if unload_ok := await hass.config_entries.async_unload_platforms(entry, []):
hass.data[DOMAIN].pop(entry.entry_id)
return unload_ok
return True