Fix Jewish Calendar default nightfall daily event key (#184725)

Co-authored-by: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
Amit Finkelstein
2026-10-11 15:55:55 +02:00
committed by GitHub
co-authored by Claude Sonnet 5.5
parent cbcb87123c
commit 1407e367cd
6 changed files with 46 additions and 12 deletions
@@ -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
@@ -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
@@ -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):
@@ -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": {
@@ -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)',
}),
])
# ---
+23 -1
View File
@@ -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",
]