Remove legacy list event calendar service (#118663)
This commit is contained in:
parent
d21908a0e4
commit
9c5879656c
3 changed files with 14 additions and 101 deletions
|
@ -38,7 +38,6 @@ from homeassistant.helpers.config_validation import ( # noqa: F401
|
||||||
from homeassistant.helpers.entity import Entity
|
from homeassistant.helpers.entity import Entity
|
||||||
from homeassistant.helpers.entity_component import EntityComponent
|
from homeassistant.helpers.entity_component import EntityComponent
|
||||||
from homeassistant.helpers.event import async_track_point_in_time
|
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.template import DATE_STR_FORMAT
|
||||||
from homeassistant.helpers.typing import ConfigType
|
from homeassistant.helpers.typing import ConfigType
|
||||||
from homeassistant.util import dt as dt_util
|
from homeassistant.util import dt as dt_util
|
||||||
|
@ -268,8 +267,6 @@ CALENDAR_EVENT_SCHEMA = vol.Schema(
|
||||||
extra=vol.ALLOW_EXTRA,
|
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: Final = "get_events"
|
||||||
SERVICE_GET_EVENTS_SCHEMA: Final = vol.All(
|
SERVICE_GET_EVENTS_SCHEMA: Final = vol.All(
|
||||||
cv.has_at_least_one_key(EVENT_END_DATETIME, EVENT_DURATION),
|
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,
|
async_create_event,
|
||||||
required_features=[CalendarEntityFeature.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(
|
component.async_register_entity_service(
|
||||||
SERVICE_GET_EVENTS,
|
SERVICE_GET_EVENTS,
|
||||||
SERVICE_GET_EVENTS_SCHEMA,
|
SERVICE_GET_EVENTS_SCHEMA,
|
||||||
|
@ -868,32 +859,6 @@ async def async_create_event(entity: CalendarEntity, call: ServiceCall) -> None:
|
||||||
await entity.async_create_event(**params)
|
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(
|
async def async_get_events_service(
|
||||||
calendar: CalendarEntity, service_call: ServiceCall
|
calendar: CalendarEntity, service_call: ServiceCall
|
||||||
) -> ServiceResponse:
|
) -> ServiceResponse:
|
||||||
|
|
|
@ -12,17 +12,12 @@ from syrupy.assertion import SnapshotAssertion
|
||||||
from typing_extensions import Generator
|
from typing_extensions import Generator
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant.components.calendar import (
|
from homeassistant.components.calendar import DOMAIN, SERVICE_GET_EVENTS
|
||||||
DOMAIN,
|
|
||||||
LEGACY_SERVICE_LIST_EVENTS,
|
|
||||||
SERVICE_GET_EVENTS,
|
|
||||||
)
|
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.exceptions import HomeAssistantError
|
from homeassistant.exceptions import HomeAssistantError
|
||||||
from homeassistant.helpers import issue_registry as ir
|
|
||||||
import homeassistant.util.dt as dt_util
|
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
|
from tests.typing import ClientSessionGenerator, WebSocketGenerator
|
||||||
|
|
||||||
|
@ -415,20 +410,6 @@ async def test_create_event_service_invalid_params(
|
||||||
@pytest.mark.parametrize(
|
@pytest.mark.parametrize(
|
||||||
("service", "expected"),
|
("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,
|
SERVICE_GET_EVENTS,
|
||||||
{
|
{
|
||||||
|
@ -486,7 +467,6 @@ async def test_list_events_service(
|
||||||
@pytest.mark.parametrize(
|
@pytest.mark.parametrize(
|
||||||
("service"),
|
("service"),
|
||||||
[
|
[
|
||||||
(LEGACY_SERVICE_LIST_EVENTS),
|
|
||||||
SERVICE_GET_EVENTS,
|
SERVICE_GET_EVENTS,
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
@ -568,37 +548,3 @@ async def test_list_events_missing_fields(hass: HomeAssistant) -> None:
|
||||||
blocking=True,
|
blocking=True,
|
||||||
return_response=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
|
|
||||||
|
|
|
@ -2391,7 +2391,7 @@ async def test_execute_script_complex_response(
|
||||||
"type": "execute_script",
|
"type": "execute_script",
|
||||||
"sequence": [
|
"sequence": [
|
||||||
{
|
{
|
||||||
"service": "calendar.list_events",
|
"service": "calendar.get_events",
|
||||||
"data": {"duration": {"hours": 24, "minutes": 0, "seconds": 0}},
|
"data": {"duration": {"hours": 24, "minutes": 0, "seconds": 0}},
|
||||||
"target": {"entity_id": "calendar.calendar_1"},
|
"target": {"entity_id": "calendar.calendar_1"},
|
||||||
"response_variable": "service_result",
|
"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["type"] == const.TYPE_RESULT
|
||||||
assert msg_no_var["success"]
|
assert msg_no_var["success"]
|
||||||
assert msg_no_var["result"]["response"] == {
|
assert msg_no_var["result"]["response"] == {
|
||||||
"events": [
|
"calendar.calendar_1": {
|
||||||
{
|
"events": [
|
||||||
"start": ANY,
|
{
|
||||||
"end": ANY,
|
"start": ANY,
|
||||||
"summary": "Future Event",
|
"end": ANY,
|
||||||
"description": "Future Description",
|
"summary": "Future Event",
|
||||||
"location": "Future Location",
|
"description": "Future Description",
|
||||||
}
|
"location": "Future Location",
|
||||||
]
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue