hass-core/homeassistant/components/devialet/__init__.py
fwestenberg d3b04a5a58
Add Devialet integration (#86551)
* Add Devialet

* Bump Devialet==1.4.0

* Bump Devialet==1.4.1

* Sort manifest and add shorthand

* Black formatting

* Fix incompatible type

* Add type guarding for name

* Rename host keywork in tests

* Fix Devialet tests

* Add update coordinator

* Update devialet tests

* Create unique_id from entry data
2023-11-28 13:56:17 +01:00

31 lines
1 KiB
Python

"""The Devialet integration."""
from __future__ import annotations
from devialet import DevialetApi
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import CONF_HOST, Platform
from homeassistant.core import HomeAssistant
from homeassistant.helpers.aiohttp_client import async_get_clientsession
from .const import DOMAIN
PLATFORMS = [Platform.MEDIA_PLAYER]
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
"""Set up Devialet from a config entry."""
session = async_get_clientsession(hass)
hass.data.setdefault(DOMAIN, {})[entry.entry_id] = DevialetApi(
entry.data[CONF_HOST], session
)
await hass.config_entries.async_forward_entry_setups(entry, PLATFORMS)
return True
async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
"""Unload Devialet config entry."""
if unload_ok := await hass.config_entries.async_unload_platforms(entry, PLATFORMS):
del hass.data[DOMAIN][entry.entry_id]
return unload_ok