Skip to content

Commit

Permalink
Fix event create for group calendars
Browse files Browse the repository at this point in the history
  • Loading branch information
RogerSelwyn committed Nov 17, 2022
1 parent 7f2b649 commit 5c273a6
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
15 changes: 8 additions & 7 deletions custom_components/o365/calendar.py
Original file line number Diff line number Diff line change
Expand Up @@ -392,12 +392,13 @@ def __init__(
"""Initialise the O365 Calendar Data."""
self._limit = limit
self.group_calendar = calendar_id.startswith(CONST_GROUP)
self.calendar_id = calendar_id
if self.group_calendar:
self._schedule = account.schedule(resource=calendar_id)
self._schedule = None
self.calendar = account.schedule(resource=self.calendar_id)
else:
self._schedule = account.schedule()
self.calendar_id = calendar_id
self.calendar = None
self.calendar = None
self._search = search
self.event = None
self._entity_id = entity_id
Expand All @@ -409,10 +410,10 @@ async def _async_get_calendar(self, hass):

async def async_o365_get_events(self, hass, start_date, end_date):
"""Get the events."""
if self.group_calendar:
return await self._async_calendar_schedule_get_events(
hass, self._schedule, start_date, end_date
)
# if self.group_calendar:
# return await self._async_calendar_schedule_get_events(
# hass, self._schedule, start_date, end_date
# )

if not self.calendar:
await self._async_get_calendar(hass)
Expand Down
6 changes: 3 additions & 3 deletions custom_components/o365/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
import logging
from operator import itemgetter

import requests
import voluptuous as vol
from homeassistant.const import CONF_ENABLED, CONF_NAME
from homeassistant.helpers import entity_platform
from homeassistant.helpers.entity import Entity
from homeassistant.util import dt
from requests.exceptions import HTTPError

from .const import (
ATTR_ALL_TASKS,
Expand Down Expand Up @@ -446,10 +446,10 @@ async def async_update(self):
_LOGGER.info("Task list reconnected for: %s", self._name)
self._error = False
self._tasks = list(data)
except requests.exceptions.HTTPError:
except HTTPError:
if not self._error:
_LOGGER.error(
"Task list not found for: %s - Has it been deleted? Restart HA to remove sensor.",
"Task list not found for: %s - Has it been deleted?",
self._name,
)
self._error = True
Expand Down

0 comments on commit 5c273a6

Please sign in to comment.