mirror of
https://github.com/home-assistant/core.git
synced 2026-07-04 21:25:26 +01:00
44 lines
1.2 KiB
Python
44 lines
1.2 KiB
Python
"""The smtp integration."""
|
|
|
|
from homeassistant.config_entries import ConfigEntry
|
|
from homeassistant.const import CONF_NAME, CONF_RECIPIENT, Platform
|
|
from homeassistant.core import HomeAssistant
|
|
from homeassistant.helpers import discovery
|
|
|
|
from .const import DOMAIN
|
|
|
|
|
|
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
|
"""Set up SMTP from a config entry."""
|
|
|
|
hass.async_create_task(
|
|
discovery.async_load_platform(
|
|
hass,
|
|
Platform.NOTIFY,
|
|
DOMAIN,
|
|
{
|
|
**entry.data,
|
|
CONF_NAME: entry.title,
|
|
CONF_RECIPIENT: [
|
|
subentry.unique_id for subentry in entry.subentries.values()
|
|
],
|
|
**entry.options,
|
|
},
|
|
{},
|
|
)
|
|
)
|
|
|
|
entry.async_on_unload(entry.add_update_listener(_async_update_listener))
|
|
|
|
return True
|
|
|
|
|
|
async def _async_update_listener(hass: HomeAssistant, entry: ConfigEntry) -> None:
|
|
"""Handle update."""
|
|
hass.config_entries.async_schedule_reload(entry.entry_id)
|
|
|
|
|
|
async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
|
"""Unload a config entry."""
|
|
return True
|