Home Assistant Unofficial Reference 2024.12.1
__init__.py
Go to the documentation of this file.
1 """Support for Melissa climate."""
2 
3 from melissa import AsyncMelissa
4 import voluptuous as vol
5 
6 from homeassistant.const import CONF_PASSWORD, CONF_USERNAME, Platform
7 from homeassistant.core import HomeAssistant
8 from homeassistant.helpers import config_validation as cv
9 from homeassistant.helpers.discovery import async_load_platform
10 from homeassistant.helpers.typing import ConfigType
11 
12 DOMAIN = "melissa"
13 DATA_MELISSA = "MELISSA"
14 
15 
16 CONFIG_SCHEMA = vol.Schema(
17  {
18  DOMAIN: vol.Schema(
19  {
20  vol.Required(CONF_USERNAME): cv.string,
21  vol.Required(CONF_PASSWORD): cv.string,
22  }
23  )
24  },
25  extra=vol.ALLOW_EXTRA,
26 )
27 
28 
29 async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
30  """Set up the Melissa Climate component."""
31  conf = config[DOMAIN]
32  username = conf.get(CONF_USERNAME)
33  password = conf.get(CONF_PASSWORD)
34  api = AsyncMelissa(username=username, password=password)
35  await api.async_connect()
36  hass.data[DATA_MELISSA] = api
37 
38  hass.async_create_task(
39  async_load_platform(hass, Platform.CLIMATE, DOMAIN, {}, config)
40  )
41  return True
bool async_setup(HomeAssistant hass, ConfigType config)
Definition: __init__.py:29
None async_load_platform(core.HomeAssistant hass, Platform|str component, str platform, DiscoveryInfoType|None discovered, ConfigType hass_config)
Definition: discovery.py:152