1 """Support for WLED."""
3 from __future__
import annotations
12 from .const
import DOMAIN
13 from .coordinator
import WLEDDataUpdateCoordinator, WLEDReleasesDataUpdateCoordinator
25 type WLEDConfigEntry = ConfigEntry[WLEDDataUpdateCoordinator]
27 WLED_KEY: HassKey[WLEDReleasesDataUpdateCoordinator] =
HassKey(DOMAIN)
28 CONFIG_SCHEMA = cv.config_entry_only_config_schema(DOMAIN)
31 async
def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
32 """Set up the WLED integration.
34 We set up a single coordinator for fetching WLED releases, which
35 is used across all WLED devices (and config entries) to avoid
36 fetching the same data multiple times for each.
39 await hass.data[WLED_KEY].async_request_refresh()
44 """Set up WLED from a config entry."""
46 await entry.runtime_data.async_config_entry_first_refresh()
49 await hass.config_entries.async_forward_entry_setups(entry, PLATFORMS)
52 entry.async_on_unload(entry.add_update_listener(async_reload_entry))
58 """Unload WLED config entry."""
59 if unload_ok := await hass.config_entries.async_unload_platforms(entry, PLATFORMS):
60 coordinator = entry.runtime_data
63 await coordinator.wled.disconnect()
71 """Reload the config entry when it changed."""
72 await hass.config_entries.async_reload(entry.entry_id)
bool async_setup(HomeAssistant hass, ConfigType config)
None async_reload_entry(HomeAssistant hass, ConfigEntry entry)
bool async_unload_entry(HomeAssistant hass, WLEDConfigEntry entry)
bool async_setup_entry(HomeAssistant hass, WLEDConfigEntry entry)