1 """The caldav component."""
6 from caldav.lib.error
import AuthorizationError, DAVError
20 type CalDavConfigEntry = ConfigEntry[caldav.DAVClient]
22 _LOGGER = logging.getLogger(__name__)
25 PLATFORMS: list[Platform] = [Platform.CALENDAR, Platform.TODO]
29 """Set up CalDAV from a config entry."""
30 client = caldav.DAVClient(
32 username=entry.data[CONF_USERNAME],
33 password=entry.data[CONF_PASSWORD],
34 ssl_verify_cert=entry.data[CONF_VERIFY_SSL],
38 await hass.async_add_executor_job(client.principal)
39 except AuthorizationError
as err:
40 if err.reason ==
"Unauthorized":
44 _LOGGER.warning(
"Unexpected CalDAV server response: %s", err)
46 except requests.ConnectionError
as err:
48 except DAVError
as err:
51 entry.runtime_data = client
53 await hass.config_entries.async_forward_entry_setups(entry, PLATFORMS)
59 """Unload a config entry."""
60 return await hass.config_entries.async_unload_platforms(entry, PLATFORMS)
bool async_setup_entry(HomeAssistant hass, CalDavConfigEntry entry)
bool async_unload_entry(HomeAssistant hass, ConfigEntry entry)