Fix options update

This commit is contained in:
Tsvi Mostovicz
2024-06-04 15:14:23 +00:00
parent c30e190848
commit 30bd575a80
2 changed files with 5 additions and 4 deletions

View File

@@ -119,10 +119,10 @@ async def async_setup_entry(hass: HomeAssistant, config_entry: ConfigEntry) -> b
"""Set up a configuration entry for Jewish calendar."""
language = config_entry.data.get(CONF_LANGUAGE, DEFAULT_LANGUAGE)
diaspora = config_entry.data.get(CONF_DIASPORA, DEFAULT_DIASPORA)
candle_lighting_offset = config_entry.data.get(
candle_lighting_offset = config_entry.options.get(
CONF_CANDLE_LIGHT_MINUTES, DEFAULT_CANDLE_LIGHT
)
havdalah_offset = config_entry.data.get(
havdalah_offset = config_entry.options.get(
CONF_HAVDALAH_OFFSET_MINUTES, DEFAULT_HAVDALAH_OFFSET_MINUTES
)
@@ -156,7 +156,8 @@ async def async_setup_entry(hass: HomeAssistant, config_entry: ConfigEntry) -> b
await hass.config_entries.async_forward_entry_setups(config_entry, PLATFORMS)
async def update_listener(hass: HomeAssistant, entry: ConfigEntry) -> None:
await hass.config_entries.async_reload(entry.entry_id)
# Trigger update of states for all platforms
await hass.config_entries.async_reload(config_entry.entry_id)
config_entry.async_on_unload(config_entry.add_update_listener(update_listener))
return True

View File

@@ -179,4 +179,4 @@ async def test_options_updates_sensors(
new_sensor_value = dt_util.parse_datetime(new_sensor_value)
# Verify that the new sensor value is one minute later
assert new_sensor_value - initial_sensor_value == timedelta(minutes=1)
assert abs(new_sensor_value - initial_sensor_value) == timedelta(minutes=1)