1
0
mirror of https://github.com/home-assistant/core.git synced 2026-06-03 14:14:40 +01:00
Files
core/homeassistant/components/romy/__init__.py
T
epenet 7f49ecffd3 Use runtime_data in romy integration (#167665)
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-08 12:14:29 +02:00

40 lines
1.3 KiB
Python

"""ROMY Integration."""
import romy
from homeassistant.const import CONF_HOST, CONF_PASSWORD
from homeassistant.core import HomeAssistant
from .const import LOGGER, PLATFORMS
from .coordinator import RomyConfigEntry, RomyVacuumCoordinator
async def async_setup_entry(hass: HomeAssistant, config_entry: RomyConfigEntry) -> bool:
"""Initialize the ROMY platform via config entry."""
new_romy = await romy.create_romy(
config_entry.data[CONF_HOST], config_entry.data.get(CONF_PASSWORD, "")
)
coordinator = RomyVacuumCoordinator(hass, config_entry, new_romy)
await coordinator.async_config_entry_first_refresh()
config_entry.runtime_data = coordinator
await hass.config_entries.async_forward_entry_setups(config_entry, PLATFORMS)
config_entry.async_on_unload(config_entry.add_update_listener(update_listener))
return True
async def async_unload_entry(hass: HomeAssistant, entry: RomyConfigEntry) -> bool:
"""Handle removal of an entry."""
return await hass.config_entries.async_unload_platforms(entry, PLATFORMS)
async def update_listener(hass: HomeAssistant, config_entry: RomyConfigEntry) -> None:
"""Handle options update."""
LOGGER.debug("update_listener")
await hass.config_entries.async_reload(config_entry.entry_id)