mirror of
https://github.com/home-assistant/core.git
synced 2025-07-18 18:57:06 +00:00
Fix blocking call in holiday (#118496)
This commit is contained in:
parent
80588d9c67
commit
34df767762
@ -18,16 +18,10 @@ from homeassistant.util import dt as dt_util
|
|||||||
from .const import CONF_PROVINCE, DOMAIN
|
from .const import CONF_PROVINCE, DOMAIN
|
||||||
|
|
||||||
|
|
||||||
async def async_setup_entry(
|
def _get_obj_holidays_and_language(
|
||||||
hass: HomeAssistant,
|
country: str, province: str | None, language: str
|
||||||
config_entry: ConfigEntry,
|
) -> tuple[HolidayBase, str]:
|
||||||
async_add_entities: AddEntitiesCallback,
|
"""Get the object for the requested country and year."""
|
||||||
) -> None:
|
|
||||||
"""Set up the Holiday Calendar config entry."""
|
|
||||||
country: str = config_entry.data[CONF_COUNTRY]
|
|
||||||
province: str | None = config_entry.data.get(CONF_PROVINCE)
|
|
||||||
language = hass.config.language
|
|
||||||
|
|
||||||
obj_holidays = country_holidays(
|
obj_holidays = country_holidays(
|
||||||
country,
|
country,
|
||||||
subdiv=province,
|
subdiv=province,
|
||||||
@ -58,6 +52,23 @@ async def async_setup_entry(
|
|||||||
)
|
)
|
||||||
language = default_language
|
language = default_language
|
||||||
|
|
||||||
|
return (obj_holidays, language)
|
||||||
|
|
||||||
|
|
||||||
|
async def async_setup_entry(
|
||||||
|
hass: HomeAssistant,
|
||||||
|
config_entry: ConfigEntry,
|
||||||
|
async_add_entities: AddEntitiesCallback,
|
||||||
|
) -> None:
|
||||||
|
"""Set up the Holiday Calendar config entry."""
|
||||||
|
country: str = config_entry.data[CONF_COUNTRY]
|
||||||
|
province: str | None = config_entry.data.get(CONF_PROVINCE)
|
||||||
|
language = hass.config.language
|
||||||
|
|
||||||
|
obj_holidays, language = await hass.async_add_executor_job(
|
||||||
|
_get_obj_holidays_and_language, country, province, language
|
||||||
|
)
|
||||||
|
|
||||||
async_add_entities(
|
async_add_entities(
|
||||||
[
|
[
|
||||||
HolidayCalendarEntity(
|
HolidayCalendarEntity(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user