mirror of
https://github.com/home-assistant/core.git
synced 2026-08-03 20:24:55 +02:00
Migrate ruuvi_gateway to use entry.runtime_data (#176139)
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user