1 """The jewish_calendar component."""
3 from __future__
import annotations
5 from functools
import partial
7 from hdate
import Location
20 CONF_CANDLE_LIGHT_MINUTES,
22 CONF_HAVDALAH_OFFSET_MINUTES,
25 DEFAULT_HAVDALAH_OFFSET_MINUTES,
28 from .entity
import JewishCalendarConfigEntry, JewishCalendarData
30 PLATFORMS: list[Platform] = [Platform.BINARY_SENSOR, Platform.SENSOR]
34 hass: HomeAssistant, config_entry: JewishCalendarConfigEntry
36 """Set up a configuration entry for Jewish calendar."""
37 language = config_entry.data.get(CONF_LANGUAGE, DEFAULT_LANGUAGE)
38 diaspora = config_entry.data.get(CONF_DIASPORA, DEFAULT_DIASPORA)
39 candle_lighting_offset = config_entry.options.get(
40 CONF_CANDLE_LIGHT_MINUTES, DEFAULT_CANDLE_LIGHT
42 havdalah_offset = config_entry.options.get(
43 CONF_HAVDALAH_OFFSET_MINUTES, DEFAULT_HAVDALAH_OFFSET_MINUTES
46 location = await hass.async_add_executor_job(
49 name=hass.config.location_name,
51 latitude=config_entry.data.get(CONF_LATITUDE, hass.config.latitude),
52 longitude=config_entry.data.get(CONF_LONGITUDE, hass.config.longitude),
53 altitude=config_entry.data.get(CONF_ELEVATION, hass.config.elevation),
54 timezone=config_entry.data.get(CONF_TIME_ZONE, hass.config.time_zone),
62 candle_lighting_offset,
66 await hass.config_entries.async_forward_entry_setups(config_entry, PLATFORMS)
69 hass: HomeAssistant, config_entry: JewishCalendarConfigEntry
72 await hass.config_entries.async_reload(config_entry.entry_id)
74 config_entry.async_on_unload(config_entry.add_update_listener(update_listener))
79 hass: HomeAssistant, config_entry: JewishCalendarConfigEntry
81 """Unload a config entry."""
82 return await hass.config_entries.async_unload_platforms(config_entry, PLATFORMS)
bool async_unload_entry(HomeAssistant hass, JewishCalendarConfigEntry config_entry)
bool async_setup_entry(HomeAssistant hass, JewishCalendarConfigEntry config_entry)
None update_listener(HomeAssistant hass, ConfigEntry entry)