Skip to content

Commit

Permalink
Clear calendar alarms after scheduling and add debug loggging (#101176)
Browse files Browse the repository at this point in the history
  • Loading branch information
allenporter committed Oct 1, 2023
1 parent 5e6735a commit 87ecdfb
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions homeassistant/components/calendar/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -531,6 +531,7 @@ def async_write_ha_state(self) -> None:

for unsub in self._alarm_unsubs:
unsub()
self._alarm_unsubs.clear()

now = dt_util.now()
event = self.event
Expand All @@ -540,6 +541,7 @@ def async_write_ha_state(self) -> None:
@callback
def update(_: datetime.datetime) -> None:
"""Run when the active or upcoming event starts or ends."""
_LOGGER.debug("Running %s update", self.entity_id)
self._async_write_ha_state()

if now < event.start_datetime_local:
Expand All @@ -553,6 +555,13 @@ def update(_: datetime.datetime) -> None:
self._alarm_unsubs.append(
async_track_point_in_time(self.hass, update, event.end_datetime_local)
)
_LOGGER.debug(
"Scheduled %d updates for %s (%s, %s)",
len(self._alarm_unsubs),
self.entity_id,
event.start_datetime_local,
event.end_datetime_local,
)

async def async_will_remove_from_hass(self) -> None:
"""Run when entity will be removed from hass.
Expand All @@ -561,6 +570,7 @@ async def async_will_remove_from_hass(self) -> None:
"""
for unsub in self._alarm_unsubs:
unsub()
self._alarm_unsubs.clear()

async def async_get_events(
self,
Expand Down

0 comments on commit 87ecdfb

Please sign in to comment.