diff --git a/homeassistant/components/calendar/__init__.py b/homeassistant/components/calendar/__init__.py index 47ea10b71b6..621356f20e2 100644 --- a/homeassistant/components/calendar/__init__.py +++ b/homeassistant/components/calendar/__init__.py @@ -38,7 +38,6 @@ from homeassistant.helpers.config_validation import ( # noqa: F401 from homeassistant.helpers.entity import Entity from homeassistant.helpers.entity_component import EntityComponent from homeassistant.helpers.event import async_track_point_in_time -from homeassistant.helpers.issue_registry import IssueSeverity, async_create_issue from homeassistant.helpers.template import DATE_STR_FORMAT from homeassistant.helpers.typing import ConfigType from homeassistant.util import dt as dt_util @@ -268,8 +267,6 @@ CALENDAR_EVENT_SCHEMA = vol.Schema( extra=vol.ALLOW_EXTRA, ) -LEGACY_SERVICE_LIST_EVENTS: Final = "list_events" -"""Deprecated: please use SERVICE_LIST_EVENTS.""" SERVICE_GET_EVENTS: Final = "get_events" SERVICE_GET_EVENTS_SCHEMA: Final = vol.All( cv.has_at_least_one_key(EVENT_END_DATETIME, EVENT_DURATION), @@ -309,12 +306,6 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool: async_create_event, required_features=[CalendarEntityFeature.CREATE_EVENT], ) - component.async_register_legacy_entity_service( - LEGACY_SERVICE_LIST_EVENTS, - SERVICE_GET_EVENTS_SCHEMA, - async_list_events_service, - supports_response=SupportsResponse.ONLY, - ) component.async_register_entity_service( SERVICE_GET_EVENTS, SERVICE_GET_EVENTS_SCHEMA, @@ -868,32 +859,6 @@ async def async_create_event(entity: CalendarEntity, call: ServiceCall) -> None: await entity.async_create_event(**params) -async def async_list_events_service( - calendar: CalendarEntity, service_call: ServiceCall -) -> ServiceResponse: - """List events on a calendar during a time range. - - Deprecated: please use async_get_events_service. - """ - _LOGGER.warning( - "Detected use of service 'calendar.list_events'. " - "This is deprecated and will stop working in Home Assistant 2024.6. " - "Use 'calendar.get_events' instead which supports multiple entities", - ) - async_create_issue( - calendar.hass, - DOMAIN, - "deprecated_service_calendar_list_events", - breaks_in_ha_version="2024.6.0", - is_fixable=True, - is_persistent=False, - issue_domain=calendar.platform.platform_name, - severity=IssueSeverity.WARNING, - translation_key="deprecated_service_calendar_list_events", - ) - return await async_get_events_service(calendar, service_call) - - async def async_get_events_service( calendar: CalendarEntity, service_call: ServiceCall ) -> ServiceResponse: diff --git a/tests/components/calendar/test_init.py b/tests/components/calendar/test_init.py index 19209574fa9..116ca70f15e 100644 --- a/tests/components/calendar/test_init.py +++ b/tests/components/calendar/test_init.py @@ -12,17 +12,12 @@ from syrupy.assertion import SnapshotAssertion from typing_extensions import Generator import voluptuous as vol -from homeassistant.components.calendar import ( - DOMAIN, - LEGACY_SERVICE_LIST_EVENTS, - SERVICE_GET_EVENTS, -) +from homeassistant.components.calendar import DOMAIN, SERVICE_GET_EVENTS from homeassistant.core import HomeAssistant from homeassistant.exceptions import HomeAssistantError -from homeassistant.helpers import issue_registry as ir import homeassistant.util.dt as dt_util -from .conftest import TEST_DOMAIN, MockCalendarEntity, MockConfigEntry +from .conftest import MockCalendarEntity, MockConfigEntry from tests.typing import ClientSessionGenerator, WebSocketGenerator @@ -415,20 +410,6 @@ async def test_create_event_service_invalid_params( @pytest.mark.parametrize( ("service", "expected"), [ - ( - LEGACY_SERVICE_LIST_EVENTS, - { - "events": [ - { - "start": "2023-06-22T05:00:00-06:00", - "end": "2023-06-22T06:00:00-06:00", - "summary": "Future Event", - "description": "Future Description", - "location": "Future Location", - } - ] - }, - ), ( SERVICE_GET_EVENTS, { @@ -486,7 +467,6 @@ async def test_list_events_service( @pytest.mark.parametrize( ("service"), [ - (LEGACY_SERVICE_LIST_EVENTS), SERVICE_GET_EVENTS, ], ) @@ -568,37 +548,3 @@ async def test_list_events_missing_fields(hass: HomeAssistant) -> None: blocking=True, return_response=True, ) - - -async def test_issue_deprecated_service_calendar_list_events( - hass: HomeAssistant, - issue_registry: ir.IssueRegistry, - caplog: pytest.LogCaptureFixture, -) -> None: - """Test the issue is raised on deprecated service weather.get_forecast.""" - - _ = await hass.services.async_call( - DOMAIN, - LEGACY_SERVICE_LIST_EVENTS, - target={"entity_id": ["calendar.calendar_1"]}, - service_data={ - "entity_id": "calendar.calendar_1", - "duration": "01:00:00", - }, - blocking=True, - return_response=True, - ) - - issue = issue_registry.async_get_issue( - "calendar", "deprecated_service_calendar_list_events" - ) - assert issue - assert issue.issue_domain == TEST_DOMAIN - assert issue.issue_id == "deprecated_service_calendar_list_events" - assert issue.translation_key == "deprecated_service_calendar_list_events" - - assert ( - "Detected use of service 'calendar.list_events'. " - "This is deprecated and will stop working in Home Assistant 2024.6. " - "Use 'calendar.get_events' instead which supports multiple entities" - ) in caplog.text diff --git a/tests/components/websocket_api/test_commands.py b/tests/components/websocket_api/test_commands.py index a51e51b81b0..276a383d9e9 100644 --- a/tests/components/websocket_api/test_commands.py +++ b/tests/components/websocket_api/test_commands.py @@ -2391,7 +2391,7 @@ async def test_execute_script_complex_response( "type": "execute_script", "sequence": [ { - "service": "calendar.list_events", + "service": "calendar.get_events", "data": {"duration": {"hours": 24, "minutes": 0, "seconds": 0}}, "target": {"entity_id": "calendar.calendar_1"}, "response_variable": "service_result", @@ -2405,15 +2405,17 @@ async def test_execute_script_complex_response( assert msg_no_var["type"] == const.TYPE_RESULT assert msg_no_var["success"] assert msg_no_var["result"]["response"] == { - "events": [ - { - "start": ANY, - "end": ANY, - "summary": "Future Event", - "description": "Future Description", - "location": "Future Location", - } - ] + "calendar.calendar_1": { + "events": [ + { + "start": ANY, + "end": ANY, + "summary": "Future Event", + "description": "Future Description", + "location": "Future Location", + } + ] + } }