Skip to content

Commit ee41725

Browse files
authored
Remove jewish_calendar yaml support after 6 months of deprecation (#130291)
1 parent ae12033 commit ee41725

File tree

4 files changed

+2
-205
lines changed

4 files changed

+2
-205
lines changed

homeassistant/components/jewish_calendar/__init__.py

+1-63
Original file line numberDiff line numberDiff line change
@@ -5,23 +5,17 @@
55
from functools import partial
66

77
from hdate import Location
8-
import voluptuous as vol
98

10-
from homeassistant.config_entries import SOURCE_IMPORT
119
from homeassistant.const import (
1210
CONF_ELEVATION,
1311
CONF_LANGUAGE,
1412
CONF_LATITUDE,
1513
CONF_LONGITUDE,
16-
CONF_NAME,
1714
CONF_TIME_ZONE,
1815
Platform,
1916
)
20-
from homeassistant.core import DOMAIN as HOMEASSISTANT_DOMAIN, HomeAssistant, callback
21-
import homeassistant.helpers.config_validation as cv
17+
from homeassistant.core import HomeAssistant, callback
2218
import homeassistant.helpers.entity_registry as er
23-
from homeassistant.helpers.issue_registry import IssueSeverity, async_create_issue
24-
from homeassistant.helpers.typing import ConfigType
2519

2620
from .binary_sensor import BINARY_SENSORS
2721
from .const import (
@@ -32,40 +26,13 @@
3226
DEFAULT_DIASPORA,
3327
DEFAULT_HAVDALAH_OFFSET_MINUTES,
3428
DEFAULT_LANGUAGE,
35-
DEFAULT_NAME,
3629
DOMAIN,
3730
)
3831
from .entity import JewishCalendarConfigEntry, JewishCalendarData
3932
from .sensor import INFO_SENSORS, TIME_SENSORS
4033

4134
PLATFORMS: list[Platform] = [Platform.BINARY_SENSOR, Platform.SENSOR]
4235

43-
CONFIG_SCHEMA = vol.Schema(
44-
{
45-
DOMAIN: vol.All(
46-
cv.deprecated(DOMAIN),
47-
{
48-
vol.Optional(CONF_NAME, default=DEFAULT_NAME): cv.string,
49-
vol.Optional(CONF_DIASPORA, default=DEFAULT_DIASPORA): cv.boolean,
50-
vol.Inclusive(CONF_LATITUDE, "coordinates"): cv.latitude,
51-
vol.Inclusive(CONF_LONGITUDE, "coordinates"): cv.longitude,
52-
vol.Optional(CONF_LANGUAGE, default=DEFAULT_LANGUAGE): vol.In(
53-
["hebrew", "english"]
54-
),
55-
vol.Optional(
56-
CONF_CANDLE_LIGHT_MINUTES, default=DEFAULT_CANDLE_LIGHT
57-
): int,
58-
# Default of 0 means use 8.5 degrees / 'three_stars' time.
59-
vol.Optional(
60-
CONF_HAVDALAH_OFFSET_MINUTES,
61-
default=DEFAULT_HAVDALAH_OFFSET_MINUTES,
62-
): int,
63-
},
64-
)
65-
},
66-
extra=vol.ALLOW_EXTRA,
67-
)
68-
6936

7037
def get_unique_prefix(
7138
location: Location,
@@ -91,35 +58,6 @@ def get_unique_prefix(
9158
return f"{prefix}"
9259

9360

94-
async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
95-
"""Set up the Jewish Calendar component."""
96-
if DOMAIN not in config:
97-
return True
98-
99-
async_create_issue(
100-
hass,
101-
HOMEASSISTANT_DOMAIN,
102-
f"deprecated_yaml_{DOMAIN}",
103-
is_fixable=False,
104-
issue_domain=DOMAIN,
105-
breaks_in_ha_version="2024.12.0",
106-
severity=IssueSeverity.WARNING,
107-
translation_key="deprecated_yaml",
108-
translation_placeholders={
109-
"domain": DOMAIN,
110-
"integration_title": DEFAULT_NAME,
111-
},
112-
)
113-
114-
hass.async_create_task(
115-
hass.config_entries.flow.async_init(
116-
DOMAIN, context={"source": SOURCE_IMPORT}, data=config[DOMAIN]
117-
)
118-
)
119-
120-
return True
121-
122-
12361
async def async_setup_entry(
12462
hass: HomeAssistant, config_entry: JewishCalendarConfigEntry
12563
) -> bool:

homeassistant/components/jewish_calendar/config_flow.py

+1-18
Original file line numberDiff line numberDiff line change
@@ -101,23 +101,10 @@ async def async_step_user(
101101
) -> ConfigFlowResult:
102102
"""Handle the initial step."""
103103
if user_input is not None:
104-
_options = {}
105-
if CONF_CANDLE_LIGHT_MINUTES in user_input:
106-
_options[CONF_CANDLE_LIGHT_MINUTES] = user_input[
107-
CONF_CANDLE_LIGHT_MINUTES
108-
]
109-
del user_input[CONF_CANDLE_LIGHT_MINUTES]
110-
if CONF_HAVDALAH_OFFSET_MINUTES in user_input:
111-
_options[CONF_HAVDALAH_OFFSET_MINUTES] = user_input[
112-
CONF_HAVDALAH_OFFSET_MINUTES
113-
]
114-
del user_input[CONF_HAVDALAH_OFFSET_MINUTES]
115104
if CONF_LOCATION in user_input:
116105
user_input[CONF_LATITUDE] = user_input[CONF_LOCATION][CONF_LATITUDE]
117106
user_input[CONF_LONGITUDE] = user_input[CONF_LOCATION][CONF_LONGITUDE]
118-
return self.async_create_entry(
119-
title=DEFAULT_NAME, data=user_input, options=_options
120-
)
107+
return self.async_create_entry(title=DEFAULT_NAME, data=user_input)
121108

122109
return self.async_show_form(
123110
step_id="user",
@@ -126,10 +113,6 @@ async def async_step_user(
126113
),
127114
)
128115

129-
async def async_step_import(self, import_data: dict[str, Any]) -> ConfigFlowResult:
130-
"""Import a config entry from configuration.yaml."""
131-
return await self.async_step_user(import_data)
132-
133116
async def async_step_reconfigure(
134117
self, user_input: dict[str, Any] | None = None
135118
) -> ConfigFlowResult:

tests/components/jewish_calendar/test_config_flow.py

-49
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22

33
from unittest.mock import AsyncMock
44

5-
import pytest
6-
75
from homeassistant import config_entries, setup
86
from homeassistant.components.jewish_calendar.const import (
97
CONF_CANDLE_LIGHT_MINUTES,
@@ -20,12 +18,10 @@
2018
CONF_LANGUAGE,
2119
CONF_LATITUDE,
2220
CONF_LONGITUDE,
23-
CONF_NAME,
2421
CONF_TIME_ZONE,
2522
)
2623
from homeassistant.core import HomeAssistant
2724
from homeassistant.data_entry_flow import FlowResultType
28-
from homeassistant.setup import async_setup_component
2925

3026
from tests.common import MockConfigEntry
3127

@@ -59,51 +55,6 @@ async def test_step_user(hass: HomeAssistant, mock_setup_entry: AsyncMock) -> No
5955
assert entries[0].data[CONF_TIME_ZONE] == hass.config.time_zone
6056

6157

62-
@pytest.mark.parametrize("diaspora", [True, False])
63-
@pytest.mark.parametrize("language", ["hebrew", "english"])
64-
async def test_import_no_options(hass: HomeAssistant, language, diaspora) -> None:
65-
"""Test that the import step works."""
66-
conf = {
67-
DOMAIN: {CONF_NAME: "test", CONF_LANGUAGE: language, CONF_DIASPORA: diaspora}
68-
}
69-
70-
assert await async_setup_component(hass, DOMAIN, conf.copy())
71-
await hass.async_block_till_done()
72-
73-
entries = hass.config_entries.async_entries(DOMAIN)
74-
assert len(entries) == 1
75-
assert CONF_LANGUAGE in entries[0].data
76-
assert CONF_DIASPORA in entries[0].data
77-
for entry_key, entry_val in entries[0].data.items():
78-
assert entry_val == conf[DOMAIN][entry_key]
79-
80-
81-
async def test_import_with_options(hass: HomeAssistant) -> None:
82-
"""Test that the import step works."""
83-
conf = {
84-
DOMAIN: {
85-
CONF_NAME: "test",
86-
CONF_DIASPORA: DEFAULT_DIASPORA,
87-
CONF_LANGUAGE: DEFAULT_LANGUAGE,
88-
CONF_CANDLE_LIGHT_MINUTES: 20,
89-
CONF_HAVDALAH_OFFSET_MINUTES: 50,
90-
CONF_LATITUDE: 31.76,
91-
CONF_LONGITUDE: 35.235,
92-
}
93-
}
94-
95-
# Simulate HomeAssistant setting up the component
96-
assert await async_setup_component(hass, DOMAIN, conf.copy())
97-
await hass.async_block_till_done()
98-
99-
entries = hass.config_entries.async_entries(DOMAIN)
100-
assert len(entries) == 1
101-
for entry_key, entry_val in entries[0].data.items():
102-
assert entry_val == conf[DOMAIN][entry_key]
103-
for entry_key, entry_val in entries[0].options.items():
104-
assert entry_val == conf[DOMAIN][entry_key]
105-
106-
10758
async def test_single_instance_allowed(
10859
hass: HomeAssistant,
10960
mock_config_entry: MockConfigEntry,
Original file line numberDiff line numberDiff line change
@@ -1,76 +1 @@
11
"""Tests for the Jewish Calendar component's init."""
2-
3-
from hdate import Location
4-
5-
from homeassistant.components.binary_sensor import DOMAIN as BINARY_SENSORS
6-
from homeassistant.components.jewish_calendar import get_unique_prefix
7-
from homeassistant.components.jewish_calendar.const import (
8-
CONF_CANDLE_LIGHT_MINUTES,
9-
CONF_DIASPORA,
10-
CONF_HAVDALAH_OFFSET_MINUTES,
11-
DEFAULT_DIASPORA,
12-
DEFAULT_LANGUAGE,
13-
DOMAIN,
14-
)
15-
from homeassistant.const import CONF_LANGUAGE, CONF_LATITUDE, CONF_LONGITUDE, CONF_NAME
16-
from homeassistant.core import HomeAssistant
17-
import homeassistant.helpers.entity_registry as er
18-
from homeassistant.setup import async_setup_component
19-
20-
21-
async def test_import_unique_id_migration(hass: HomeAssistant) -> None:
22-
"""Test unique_id migration."""
23-
yaml_conf = {
24-
DOMAIN: {
25-
CONF_NAME: "test",
26-
CONF_DIASPORA: DEFAULT_DIASPORA,
27-
CONF_LANGUAGE: DEFAULT_LANGUAGE,
28-
CONF_CANDLE_LIGHT_MINUTES: 20,
29-
CONF_HAVDALAH_OFFSET_MINUTES: 50,
30-
CONF_LATITUDE: 31.76,
31-
CONF_LONGITUDE: 35.235,
32-
}
33-
}
34-
35-
# Create an entry in the entity registry with the data from conf
36-
ent_reg = er.async_get(hass)
37-
location = Location(
38-
latitude=yaml_conf[DOMAIN][CONF_LATITUDE],
39-
longitude=yaml_conf[DOMAIN][CONF_LONGITUDE],
40-
timezone=hass.config.time_zone,
41-
diaspora=DEFAULT_DIASPORA,
42-
)
43-
old_prefix = get_unique_prefix(location, DEFAULT_LANGUAGE, 20, 50)
44-
sample_entity = ent_reg.async_get_or_create(
45-
BINARY_SENSORS,
46-
DOMAIN,
47-
unique_id=f"{old_prefix}_erev_shabbat_hag",
48-
suggested_object_id=f"{DOMAIN}_erev_shabbat_hag",
49-
)
50-
# Save the existing unique_id, DEFAULT_LANGUAGE should be part of it
51-
old_unique_id = sample_entity.unique_id
52-
assert DEFAULT_LANGUAGE in old_unique_id
53-
54-
# Simulate HomeAssistant setting up the component
55-
assert await async_setup_component(hass, DOMAIN, yaml_conf.copy())
56-
await hass.async_block_till_done()
57-
58-
entries = hass.config_entries.async_entries(DOMAIN)
59-
assert len(entries) == 1
60-
for entry_key, entry_val in entries[0].data.items():
61-
assert entry_val == yaml_conf[DOMAIN][entry_key]
62-
for entry_key, entry_val in entries[0].options.items():
63-
assert entry_val == yaml_conf[DOMAIN][entry_key]
64-
65-
# Assert that the unique_id was updated
66-
new_unique_id = ent_reg.async_get(sample_entity.entity_id).unique_id
67-
assert new_unique_id != old_unique_id
68-
assert DEFAULT_LANGUAGE not in new_unique_id
69-
70-
# Confirm that when the component is reloaded, the unique_id is not changed
71-
assert ent_reg.async_get(sample_entity.entity_id).unique_id == new_unique_id
72-
73-
# Confirm that all the unique_ids are prefixed correctly
74-
await hass.config_entries.async_reload(entries[0].entry_id)
75-
er_entries = er.async_entries_for_config_entry(ent_reg, entries[0].entry_id)
76-
assert all(entry.unique_id.startswith(entries[0].entry_id) for entry in er_entries)

0 commit comments

Comments
 (0)