2020-08-20 15:30:41 +00:00
|
|
|
"""The Broadlink integration."""
|
|
|
|
from dataclasses import dataclass, field
|
2019-04-12 18:11:36 +00:00
|
|
|
|
2020-08-20 15:30:41 +00:00
|
|
|
from .const import DOMAIN
|
|
|
|
from .device import BroadlinkDevice
|
2019-04-12 18:11:36 +00:00
|
|
|
|
|
|
|
|
2020-08-20 15:30:41 +00:00
|
|
|
@dataclass
|
|
|
|
class BroadlinkData:
|
|
|
|
"""Class for sharing data within the Broadlink integration."""
|
2019-04-12 18:11:36 +00:00
|
|
|
|
2020-08-20 15:30:41 +00:00
|
|
|
devices: dict = field(default_factory=dict)
|
|
|
|
platforms: dict = field(default_factory=dict)
|
2019-04-12 18:11:36 +00:00
|
|
|
|
|
|
|
|
2020-08-20 15:30:41 +00:00
|
|
|
async def async_setup(hass, config):
|
|
|
|
"""Set up the Broadlink integration."""
|
|
|
|
hass.data[DOMAIN] = BroadlinkData()
|
|
|
|
return True
|
2019-04-12 18:11:36 +00:00
|
|
|
|
|
|
|
|
2020-08-20 15:30:41 +00:00
|
|
|
async def async_setup_entry(hass, entry):
|
|
|
|
"""Set up a Broadlink device from a config entry."""
|
|
|
|
device = BroadlinkDevice(hass, entry)
|
|
|
|
return await device.async_setup()
|
2019-12-02 21:20:36 +00:00
|
|
|
|
|
|
|
|
2020-08-20 15:30:41 +00:00
|
|
|
async def async_unload_entry(hass, entry):
|
|
|
|
"""Unload a config entry."""
|
|
|
|
device = hass.data[DOMAIN].devices.pop(entry.entry_id)
|
|
|
|
return await device.async_unload()
|