1 """Support for functionality to keep track of the sun."""
3 from __future__
import annotations
16 from .
import sensor
as sensor_pre_import
22 from .entity
import Sun, SunConfigEntry
24 CONFIG_SCHEMA = cv.empty_config_schema(DOMAIN)
27 async
def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
28 """Track the state of the sun."""
29 if not hass.config_entries.async_entries(DOMAIN):
33 hass.async_create_task(
34 hass.config_entries.flow.async_init(
36 context={
"source": SOURCE_IMPORT},
44 """Set up from a config entry."""
45 entry.runtime_data = sun =
Sun(hass)
46 entry.async_on_unload(sun.remove_listeners)
47 await hass.config_entries.async_forward_entry_setups(entry, [Platform.SENSOR])
52 """Unload a config entry."""
53 if unload_ok := await hass.config_entries.async_unload_platforms(
54 entry, [Platform.SENSOR]
56 sun = entry.runtime_data
57 hass.states.async_remove(sun.entity_id)
bool async_setup_entry(HomeAssistant hass, SunConfigEntry entry)
bool async_setup(HomeAssistant hass, ConfigType config)
bool async_unload_entry(HomeAssistant hass, SunConfigEntry entry)