Add OAuth2 config flow scaffold (#28220)

* Add OAuth2 scaffold

* Generate integration if non-existing domain specified

* Update URL
This commit is contained in:
Paulus Schoutsen 2019-10-29 20:34:03 -07:00 committed by GitHub
parent e700384cce
commit 24c29f9227
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
13 changed files with 567 additions and 209 deletions

View file

@ -0,0 +1,49 @@
"""The NEW_NAME integration."""
import asyncio
import voluptuous as vol
from homeassistant.core import HomeAssistant
from homeassistant.config_entries import ConfigEntry
from .const import DOMAIN
CONFIG_SCHEMA = vol.Schema({DOMAIN: vol.Schema({})}, extra=vol.ALLOW_EXTRA)
# TODO List the platforms that you want to support.
# For your initial PR, limit it to 1 platform.
PLATFORMS = ["light"]
async def async_setup(hass: HomeAssistant, config: dict):
"""Set up the NEW_NAME component."""
return True
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry):
"""Set up Somfy from a config entry."""
# TODO Store an API object for your platforms to access
# hass.data[DOMAIN][entry.entry_id] = MyApi(…)
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