Fix blocking call in Jewish Calendar while initializing location (#120265)

pull/120275/head
Tsvi Mostovicz 2024-06-24 00:04:16 +03:00 committed by GitHub
parent 436c36e3dd
commit 143e8d09af
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 12 additions and 7 deletions

View File

@ -2,6 +2,8 @@
from __future__ import annotations
from functools import partial
from hdate import Location
import voluptuous as vol
@ -129,13 +131,16 @@ async def async_setup_entry(hass: HomeAssistant, config_entry: ConfigEntry) -> b
CONF_HAVDALAH_OFFSET_MINUTES, DEFAULT_HAVDALAH_OFFSET_MINUTES
)
location = Location(
name=hass.config.location_name,
diaspora=diaspora,
latitude=config_entry.data.get(CONF_LATITUDE, hass.config.latitude),
longitude=config_entry.data.get(CONF_LONGITUDE, hass.config.longitude),
altitude=config_entry.data.get(CONF_ELEVATION, hass.config.elevation),
timezone=config_entry.data.get(CONF_TIME_ZONE, hass.config.time_zone),
location = await hass.async_add_executor_job(
partial(
Location,
name=hass.config.location_name,
diaspora=diaspora,
latitude=config_entry.data.get(CONF_LATITUDE, hass.config.latitude),
longitude=config_entry.data.get(CONF_LONGITUDE, hass.config.longitude),
altitude=config_entry.data.get(CONF_ELEVATION, hass.config.elevation),
timezone=config_entry.data.get(CONF_TIME_ZONE, hass.config.time_zone),
)
)
hass.data.setdefault(DOMAIN, {})[config_entry.entry_id] = {