1 """The Coolmaster integration."""
3 from pycoolmasternet_async
import CoolMasterNet
10 from .const
import CONF_SWING_SUPPORT, DATA_COORDINATOR, DATA_INFO, DOMAIN
11 from .coordinator
import CoolmasterDataUpdateCoordinator
13 PLATFORMS = [Platform.BINARY_SENSOR, Platform.BUTTON, Platform.CLIMATE, Platform.SENSOR]
17 """Set up Coolmaster from a config entry."""
18 host = entry.data[CONF_HOST]
19 port = entry.data[CONF_PORT]
20 if not entry.data.get(CONF_SWING_SUPPORT):
21 coolmaster = CoolMasterNet(
29 coolmaster = CoolMasterNet(
36 info = await coolmaster.info()
38 raise ConfigEntryNotReady
39 except OSError
as error:
40 raise ConfigEntryNotReady
from error
42 hass.data.setdefault(DOMAIN, {})
43 await coordinator.async_config_entry_first_refresh()
44 hass.data[DOMAIN][entry.entry_id] = {
46 DATA_COORDINATOR: coordinator,
48 await hass.config_entries.async_forward_entry_setups(entry, PLATFORMS)
54 """Unload a Coolmaster config entry."""
55 unload_ok = await hass.config_entries.async_unload_platforms(entry, PLATFORMS)
57 hass.data[DOMAIN].pop(entry.entry_id)
bool async_setup_entry(HomeAssistant hass, ConfigEntry entry)
bool async_unload_entry(HomeAssistant hass, ConfigEntry entry)