From 5c273a6396e946b810b771ec696c88d2fdd37f60 Mon Sep 17 00:00:00 2001 From: RogerSelwyn Date: Thu, 17 Nov 2022 12:59:10 +0000 Subject: [PATCH] Fix event create for group calendars --- custom_components/o365/calendar.py | 15 ++++++++------- custom_components/o365/sensor.py | 6 +++--- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/custom_components/o365/calendar.py b/custom_components/o365/calendar.py index af00571..04a2496 100644 --- a/custom_components/o365/calendar.py +++ b/custom_components/o365/calendar.py @@ -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 @@ -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) diff --git a/custom_components/o365/sensor.py b/custom_components/o365/sensor.py index aa4d75d..8d59e91 100644 --- a/custom_components/o365/sensor.py +++ b/custom_components/o365/sensor.py @@ -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, @@ -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