<reponame>aijayadams/core
"""The Genie Aladdin integration."""
import asyncio

import voluptuous as vol
from homeassistant.const import CONF_PASSWORD, CONF_TIMEOUT, CONF_EMAIL
from homeassistant.config_entries import ConfigEntry
from homeassistant.core import HomeAssistant
from genie_aladdin.api import AladdinConnection

from .const import DOMAIN


CONFIG_SCHEMA = vol.Schema(
    {
        DOMAIN: vol.Schema(
            {vol.Required(CONF_EMAIL): str, vol.Required(CONF_PASSWORD): str,}
        )
    },
    extra=vol.ALLOW_EXTRA,
)

# TODO List the platforms that you want to support.
# For your initial PR, limit it to 1 platform.
PLATFORMS = ["binary_sensor"]


async def async_setup(hass: HomeAssistant, config: dict):
    """Set up the Genie Aladdin component."""
    return True


async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry):
    """Set up Genie Aladdin from a config entry."""
    # TODO Store an API object for your platforms to access
    # hass.data[DOMAIN][entry.entry_id] = AladdinConnection

    import pprint

    pprint.pprint(entry.as_dict())

    for component in PLATFORMS:
        hass.async_create_task(
            hass.config_entries.async_forward_entry_setup(entry, component)
        )

    return True


async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry):
    """Unload a config entry."""
    unload_ok = all(
        await asyncio.gather(
            *[
                hass.config_entries.async_forward_entry_unload(entry, component)
                for component in PLATFORMS
            ]
        )
    )
    if unload_ok:
        hass.data[DOMAIN].pop(entry.entry_id)

    return unload_ok

"""The Genie Aladdin integration."""
import asyncio

import voluptuous as vol
from homeassistant.const import CONF_PASSWORD, CONF_TIMEOUT, CONF_EMAIL
from homeassistant.config_entries import ConfigEntry
from homeassistant.core import HomeAssistant
from genie_aladdin.api import AladdinConnection

from .const import DOMAIN


CONFIG_SCHEMA = vol.Schema(
    {
        DOMAIN: vol.Schema(
            {vol.Required(CONF_EMAIL): str, vol.Required(CONF_PASSWORD): str,}
        )
    },
    extra=vol.ALLOW_EXTRA,
)

# TODO List the platforms that you want to support.
# For your initial PR, limit it to 1 platform.
PLATFORMS = ["binary_sensor"]


async def async_setup(hass: HomeAssistant, config: dict):
    """Set up the Genie Aladdin component."""
    return True


async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry):
    """Set up Genie Aladdin from a config entry."""
    # TODO Store an API object for your platforms to access
    # hass.data[DOMAIN][entry.entry_id] = AladdinConnection

    import pprint

    pprint.pprint(entry.as_dict())

    for component in PLATFORMS:
        hass.async_create_task(
            hass.config_entries.async_forward_entry_setup(entry, component)
        )

    return True


async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry):
    """Unload a config entry."""
    unload_ok = all(
        await asyncio.gather(
            *[
                hass.config_entries.async_forward_entry_unload(entry, component)
                for component in PLATFORMS
            ]
        )
    )
    if unload_ok:
        hass.data[DOMAIN].pop(entry.entry_id)

    return unload_ok
The Genie Aladdin integration. # TODO List the platforms that you want to support. # For your initial PR, limit it to 1 platform. Set up the Genie Aladdin component. Set up Genie Aladdin from a config entry. # TODO Store an API object for your platforms to access # hass.data[DOMAIN][entry.entry_id] = AladdinConnection Unload a config entry.