Skip to content

Commit

Permalink
Minor code improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
RogerSelwyn committed Mar 20, 2023
1 parent 222fa95 commit 4dccb9e
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
4 changes: 2 additions & 2 deletions custom_components/o365/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ async def _async_legacy_migration_repair(hass):
url = "https://rogerselwyn.github.io/O365-HomeAssistant/legacy_migration.html"
message = (
"Secondary/Legacy configuration method is now deprecated and will be "
+ "removed in a future release. Please migrate to the Primary configuration method "
+ "documented here - "
+ "removed in a future release. Please migrate to the Primary configuration "
+ "method documented here - "
+ f"{url}"
)
_LOGGER.warning(message)
Expand Down
12 changes: 9 additions & 3 deletions custom_components/o365/calendar.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
EVENT_HA_EVENT,
EVENT_MODIFY_CALENDAR_EVENT,
EVENT_REMOVE_CALENDAR_EVENT,
EVENT_REMOVE_CALENDAR_RECURRENCES,
EVENT_RESPOND_CALENDAR_EVENT,
LEGACY_ACCOUNT_NAME,
PERM_CALENDARS_READWRITE,
Expand Down Expand Up @@ -444,11 +445,16 @@ def remove_calendar_event(self, event_id, recurrence_id, recurrence_range):
return

if recurrence_range:
event = self._get_event_from_calendar(recurrence_id)
self._delete_calendar_event(
recurrence_id, EVENT_REMOVE_CALENDAR_RECURRENCES
)
else:
event = self._get_event_from_calendar(event_id)
self._delete_calendar_event(event_id, EVENT_REMOVE_CALENDAR_EVENT)

def _delete_calendar_event(self, event_id, ha_event):
event = self._get_event_from_calendar(event_id)
event.delete()
self._raise_event(EVENT_REMOVE_CALENDAR_EVENT, event_id)
self._raise_event(ha_event, event_id)

def respond_calendar_event(
self, event_id, response, send_response=True, message=None
Expand Down
1 change: 1 addition & 0 deletions custom_components/o365/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ class EventResponse(Enum):
EVENT_CREATE_CALENDAR_EVENT = "create_calendar_event"
EVENT_MODIFY_CALENDAR_EVENT = "modify_calendar_event"
EVENT_REMOVE_CALENDAR_EVENT = "remove_calendar_event"
EVENT_REMOVE_CALENDAR_RECURRENCES = "remove_calendar_recurrences"
EVENT_RESPOND_CALENDAR_EVENT = "respond_calendar_event"

LEGACY_ACCOUNT_NAME = "converted"
Expand Down

0 comments on commit 4dccb9e

Please sign in to comment.