From 93eac97983f541936f2f2ac5182070320e4c37b6 Mon Sep 17 00:00:00 2001 From: Allen Porter Date: Fri, 21 Apr 2023 07:25:52 -0700 Subject: [PATCH] Relax the constraint that events must have a consistent timezone for start/end (#91788) --- homeassistant/components/calendar/__init__.py | 1 - tests/components/google/test_calendar.py | 34 +++++++++++++++++++ 2 files changed, 34 insertions(+), 1 deletion(-) diff --git a/homeassistant/components/calendar/__init__.py b/homeassistant/components/calendar/__init__.py index 2445c054c6d..aedfafbf368 100644 --- a/homeassistant/components/calendar/__init__.py +++ b/homeassistant/components/calendar/__init__.py @@ -244,7 +244,6 @@ CALENDAR_EVENT_SCHEMA = vol.Schema( }, _has_same_type("start", "end"), _has_timezone("start", "end"), - _has_consistent_timezone("start", "end"), _as_local_timezone("start", "end"), _has_min_duration("start", "end", MIN_EVENT_DURATION), ), diff --git a/tests/components/google/test_calendar.py b/tests/components/google/test_calendar.py index 7d59d80687e..d6431700fca 100644 --- a/tests/components/google/test_calendar.py +++ b/tests/components/google/test_calendar.py @@ -1295,3 +1295,37 @@ async def test_event_without_duration( assert state.attributes.get("start_time") == one_hour_from_now.strftime( DATE_STR_FORMAT ) + + +async def test_event_differs_timezone( + hass: HomeAssistant, mock_events_list_items, component_setup +) -> None: + """Test a case where the event has a different start/end timezone.""" + one_hour_from_now = dt_util.now() + datetime.timedelta(minutes=30) + end_event = one_hour_from_now + datetime.timedelta(hours=8) + event = { + **TEST_EVENT, + "start": { + "dateTime": one_hour_from_now.isoformat(), + "timeZone": "America/Regina", + }, + "end": {"dateTime": end_event.isoformat(), "timeZone": "UTC"}, + } + mock_events_list_items([event]) + + assert await component_setup() + + state = hass.states.get(TEST_ENTITY) + assert state.name == TEST_ENTITY_NAME + assert state.state == STATE_OFF + assert dict(state.attributes) == { + "friendly_name": TEST_ENTITY_NAME, + "message": event["summary"], + "all_day": False, + "offset_reached": False, + "start_time": one_hour_from_now.strftime(DATE_STR_FORMAT), + "end_time": end_event.strftime(DATE_STR_FORMAT), + "location": event["location"], + "description": event["description"], + "supported_features": 3, + }