1 """The twinkly component."""
3 from aiohttp
import ClientError
4 from ttls.client
import Twinkly
12 from .const
import ATTR_VERSION, DATA_CLIENT, DATA_DEVICE_INFO, DOMAIN
14 PLATFORMS = [Platform.LIGHT]
18 """Set up entries from config flow."""
19 hass.data.setdefault(DOMAIN, {})
23 host = entry.data[CONF_HOST]
25 hass.data[DOMAIN].setdefault(entry.entry_id, {})
30 device_info = await client.get_details()
31 software_version = await client.get_firmware_version()
32 except (TimeoutError, ClientError)
as exception:
33 raise ConfigEntryNotReady
from exception
35 hass.data[DOMAIN][entry.entry_id] = {
37 DATA_DEVICE_INFO: device_info,
38 ATTR_SW_VERSION: software_version.get(ATTR_VERSION),
40 await hass.config_entries.async_forward_entry_setups(entry, PLATFORMS)
46 """Remove a twinkly entry."""
48 unload_ok = await hass.config_entries.async_unload_platforms(entry, PLATFORMS)
50 hass.data[DOMAIN].pop(entry.entry_id)
bool async_unload_entry(HomeAssistant hass, ConfigEntry entry)
bool async_setup_entry(HomeAssistant hass, ConfigEntry entry)
aiohttp.ClientSession async_get_clientsession(HomeAssistant hass, bool verify_ssl=True, socket.AddressFamily family=socket.AF_UNSPEC, ssl_util.SSLCipherList ssl_cipher=ssl_util.SSLCipherList.PYTHON_DEFAULT)