-
-
Notifications
You must be signed in to change notification settings - Fork 28.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix CalDAV supported components check when configured from the UI (#1…
…03411) * Fix CalDAV supported components check when configured from the UI * Move async_get_calendars to a seprate file * Simplify return value for async_get_calendars
- Loading branch information
1 parent
d3bbcbe
commit 936956a
Showing
3 changed files
with
75 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
"""Library for working with CalDAV api.""" | ||
|
||
import asyncio | ||
|
||
import caldav | ||
|
||
from homeassistant.core import HomeAssistant | ||
|
||
|
||
async def async_get_calendars( | ||
hass: HomeAssistant, client: caldav.DAVClient, component: str | ||
) -> list[caldav.Calendar]: | ||
"""Get all calendars that support the specified component.""" | ||
calendars = await hass.async_add_executor_job(client.principal().calendars) | ||
components_results = await asyncio.gather( | ||
*[ | ||
hass.async_add_executor_job(calendar.get_supported_components) | ||
for calendar in calendars | ||
] | ||
) | ||
return [ | ||
calendar | ||
for calendar, supported_components in zip(calendars, components_results) | ||
if component in supported_components | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters