From 30bd575a806369fc60445a7ded7edce9b6bbc605 Mon Sep 17 00:00:00 2001 From: Tsvi Mostovicz Date: Tue, 4 Jun 2024 15:14:23 +0000 Subject: [PATCH] Fix options update --- homeassistant/components/jewish_calendar/__init__.py | 7 ++++--- tests/components/jewish_calendar/test_config_flow.py | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/homeassistant/components/jewish_calendar/__init__.py b/homeassistant/components/jewish_calendar/__init__.py index 1a1014e0c0e..8383f9181fc 100644 --- a/homeassistant/components/jewish_calendar/__init__.py +++ b/homeassistant/components/jewish_calendar/__init__.py @@ -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 diff --git a/tests/components/jewish_calendar/test_config_flow.py b/tests/components/jewish_calendar/test_config_flow.py index 0883b072b70..192970a0cd9 100644 --- a/tests/components/jewish_calendar/test_config_flow.py +++ b/tests/components/jewish_calendar/test_config_flow.py @@ -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)