diff --git a/homeassistant/components/jewish_calendar/__init__.py b/homeassistant/components/jewish_calendar/__init__.py index 5430647e7a02..164b4eb0a215 100644 --- a/homeassistant/components/jewish_calendar/__init__.py +++ b/homeassistant/components/jewish_calendar/__init__.py @@ -19,6 +19,7 @@ from homeassistant.helpers.typing import ConfigType from .const import ( CONF_CANDLE_LIGHT_MINUTES, + CONF_DAILY_EVENTS, CONF_DIASPORA, CONF_HAVDALAH_OFFSET_MINUTES, DEFAULT_CANDLE_LIGHT, @@ -140,4 +141,15 @@ async def async_migrate_entry( new_data[CONF_LANGUAGE] = config_entry.data[CONF_LANGUAGE][:2] hass.config_entries.async_update_entry(config_entry, data=new_data, version=3) + if config_entry.version == 3: + new_options = {**config_entry.options} + if CONF_DAILY_EVENTS in new_options: + new_options[CONF_DAILY_EVENTS] = [ + "tset_hakohavim" if event == "tset_hakohavim_tsom" else event + for event in new_options[CONF_DAILY_EVENTS] + ] + hass.config_entries.async_update_entry( + config_entry, options=new_options, version=4 + ) + return True diff --git a/homeassistant/components/jewish_calendar/config_flow.py b/homeassistant/components/jewish_calendar/config_flow.py index 17004e56d355..2d23d112640e 100644 --- a/homeassistant/components/jewish_calendar/config_flow.py +++ b/homeassistant/components/jewish_calendar/config_flow.py @@ -129,7 +129,7 @@ async def _get_data_schema(hass: HomeAssistant) -> probatio.Schema: class JewishCalendarConfigFlow(ConfigFlow, domain=DOMAIN): """Handle a config flow for Jewish calendar.""" - VERSION = 3 + VERSION = 4 @staticmethod @callback diff --git a/homeassistant/components/jewish_calendar/const.py b/homeassistant/components/jewish_calendar/const.py index 69ab59153d37..22e76eb026b0 100644 --- a/homeassistant/components/jewish_calendar/const.py +++ b/homeassistant/components/jewish_calendar/const.py @@ -37,7 +37,7 @@ class DailyCalendarEventType(StrEnum): MINCHA_KETANA = "mincha_ketana" PLAG_HAMINCHA = "plag_hamincha" SHKIA = "shkia" - TSET_HAKOHAVIM = "tset_hakohavim_tsom" + TSET_HAKOHAVIM = "tset_hakohavim" class YearlyCalendarEventType(StrEnum): diff --git a/homeassistant/components/jewish_calendar/strings.json b/homeassistant/components/jewish_calendar/strings.json index 40b7f7e14cf2..21199b018f95 100644 --- a/homeassistant/components/jewish_calendar/strings.json +++ b/homeassistant/components/jewish_calendar/strings.json @@ -194,7 +194,7 @@ "sof_zman_shema_mga": "Sof Zman Shema (Mg\"A)", "sof_zman_tfilla_gra": "Sof Zman Tefilla (Gr\"A)", "sof_zman_tfilla_mga": "Sof Zman Tefilla (Mg\"A)", - "tset_hakohavim_tsom": "T'set Hakochavim (nightfall)" + "tset_hakohavim": "T'set Hakochavim (nightfall)" } }, "learning_schedule": { diff --git a/tests/components/jewish_calendar/snapshots/test_calendar.ambr b/tests/components/jewish_calendar/snapshots/test_calendar.ambr index d7d0de9acd56..5485676fb2df 100644 --- a/tests/components/jewish_calendar/snapshots/test_calendar.ambr +++ b/tests/components/jewish_calendar/snapshots/test_calendar.ambr @@ -30,10 +30,10 @@ 'summary': 'Shkia', }), dict({ - 'description': 'Nightfall: 17:26', - 'end': '2024-01-15T15:26:00+00:00', - 'start': '2024-01-15T15:26:00+00:00', - 'summary': 'End of fast', + 'description': 'Nightfall, 18 minutes: 17:12', + 'end': '2024-01-15T15:12:18+00:00', + 'start': '2024-01-15T15:12:18+00:00', + 'summary': 'Tset Hakochavim (18 minutes)', }), ]) # --- @@ -58,10 +58,10 @@ 'summary': 'Shkia', }), dict({ - 'description': 'Nightfall: 17:26', - 'end': '2024-01-15T22:26:00+00:00', - 'start': '2024-01-15T22:26:00+00:00', - 'summary': 'End of fast', + 'description': 'Nightfall, 18 minutes: 17:07', + 'end': '2024-01-15T22:07:06+00:00', + 'start': '2024-01-15T22:07:06+00:00', + 'summary': 'Tset Hakochavim (18 minutes)', }), ]) # --- diff --git a/tests/components/jewish_calendar/test_init.py b/tests/components/jewish_calendar/test_init.py index 88ba13342101..58c0b20be615 100644 --- a/tests/components/jewish_calendar/test_init.py +++ b/tests/components/jewish_calendar/test_init.py @@ -2,8 +2,9 @@ import pytest -from homeassistant.components.jewish_calendar.const import DOMAIN +from homeassistant.components.jewish_calendar.const import CONF_DAILY_EVENTS, DOMAIN from homeassistant.components.sensor import DOMAIN as SENSOR_DOMAIN +from homeassistant.const import CONF_LANGUAGE from homeassistant.core import HomeAssistant from homeassistant.helpers import entity_registry as er @@ -42,3 +43,24 @@ async def test_migrate_unique_id( entity_migrated = entity_registry.async_get(entity.entity_id) assert entity_migrated assert entity_migrated.unique_id == f"{config_entry.entry_id}-{new_key}" + + +async def test_migrate_daily_events_tset_hakohavim(hass: HomeAssistant) -> None: + """Test the daily events option migration of the nightfall event.""" + config_entry = MockConfigEntry( + domain=DOMAIN, + version=3, + data={CONF_LANGUAGE: "en"}, + options={CONF_DAILY_EVENTS: ["date", "shkia", "tset_hakohavim_tsom"]}, + ) + config_entry.add_to_hass(hass) + + await hass.config_entries.async_setup(config_entry.entry_id) + await hass.async_block_till_done() + + assert config_entry.version == 4 + assert config_entry.options[CONF_DAILY_EVENTS] == [ + "date", + "shkia", + "tset_hakohavim", + ]