1
mirror of https://github.com/home-assistant/core synced 2024-08-02 23:40:32 +02:00
ha-core/homeassistant/components/opengarage/__init__.py
2021-09-29 09:43:51 -06:00

39 lines
1.1 KiB
Python

"""The OpenGarage integration."""
from __future__ import annotations
import opengarage
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import CONF_HOST, CONF_PORT, CONF_VERIFY_SSL
from homeassistant.core import HomeAssistant
from homeassistant.helpers.aiohttp_client import async_get_clientsession
from .const import CONF_DEVICE_KEY, DOMAIN
PLATFORMS = ["cover"]
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
"""Set up OpenGarage from a config entry."""
hass.data.setdefault(DOMAIN, {})
hass.data[DOMAIN][entry.entry_id] = opengarage.OpenGarage(
f"{entry.data[CONF_HOST]}:{entry.data[CONF_PORT]}",
entry.data[CONF_DEVICE_KEY],
entry.data[CONF_VERIFY_SSL],
async_get_clientsession(hass),
)
hass.config_entries.async_setup_platforms(entry, PLATFORMS)
return True
async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
"""Unload a config entry."""
unload_ok = await hass.config_entries.async_unload_platforms(entry, PLATFORMS)
if unload_ok:
hass.data[DOMAIN].pop(entry.entry_id)
return unload_ok