1 """The madvr-envy integration."""
3 from __future__
import annotations
7 from madvr.madvr
import Madvr
13 from .coordinator
import MadVRCoordinator
15 PLATFORMS: list[Platform] = [Platform.BINARY_SENSOR, Platform.REMOTE, Platform.SENSOR]
18 type MadVRConfigEntry = ConfigEntry[MadVRCoordinator]
20 _LOGGER = logging.getLogger(__name__)
25 _LOGGER.debug(
"Integration unloading")
26 coordinator.client.stop()
27 await coordinator.client.async_cancel_tasks()
28 _LOGGER.debug(
"Integration closing connection")
29 await coordinator.client.close_connection()
30 _LOGGER.debug(
"Unloaded")
34 """Set up the integration from a config entry."""
35 assert entry.unique_id
37 host=entry.data[CONF_HOST],
39 port=entry.data[CONF_PORT],
46 entry.runtime_data = coordinator
48 await hass.config_entries.async_forward_entry_setups(entry, PLATFORMS)
50 async
def handle_unload(event: Event) ->
None:
55 hass.bus.async_listen_once(EVENT_HOMEASSISTANT_STOP, handle_unload)
58 await coordinator.handle_coordinator_load()
63 """Unload a config entry."""
64 unload_ok = await hass.config_entries.async_unload_platforms(entry, PLATFORMS)
66 coordinator: MadVRCoordinator = entry.runtime_data
bool async_setup_entry(HomeAssistant hass, MadVRConfigEntry entry)
None async_handle_unload(MadVRCoordinator coordinator)
bool async_unload_entry(HomeAssistant hass, MadVRConfigEntry entry)