Skip to content

Commit

Permalink
Incorporate conflicting changes
Browse files Browse the repository at this point in the history
  • Loading branch information
RogerSelwyn committed Dec 9, 2022
1 parent ee1a230 commit 54cb002
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 7 deletions.
16 changes: 11 additions & 5 deletions custom_components/o365/classes/taskssensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
ATTR_ALL_TASKS,
ATTR_DUE,
ATTR_OVERDUE_TASKS,
ATTR_REMINDER,
ATTR_SUBJECT,
ATTR_TASKS,
CONF_CONFIG_TYPE,
Expand Down Expand Up @@ -41,11 +42,16 @@ def extra_state_attributes(self):
for item in self.coordinator.data[self.entity_id][ATTR_TASKS]:
task = {ATTR_SUBJECT: item.subject}
if item.due:
task[ATTR_DUE] = item.due
if item.due < dt.utcnow():
overdue_tasks.append(
{ATTR_SUBJECT: item.subject, ATTR_DUE: item.due}
)
due = item.due.date()
task[ATTR_DUE] = due
if due < dt.utcnow().date():
overdue_task = {ATTR_SUBJECT: item.subject, ATTR_DUE: due}
if item.is_reminder_on:
overdue_task[ATTR_REMINDER] = item.reminder
overdue_tasks.append(overdue_task)

if item.is_reminder_on:
task[ATTR_REMINDER] = item.reminder

all_tasks.append(task)

Expand Down
7 changes: 6 additions & 1 deletion custom_components/o365/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -309,13 +309,18 @@ async def _async_email_update(self, entity):
download_attachments=entity.download_attachments,
)
)
attrs = [get_email_attributes(x, entity.download_attachments) for x in data]
attrs = await self.hass.async_add_executor_job( # pylint: disable=no-member
self._get_attributes, data, entity
)
attrs.sort(key=itemgetter("received"), reverse=True)
self._data[entity.entity_id] = {
ATTR_STATE: len(attrs),
ATTR_ATTRIBUTES: {"data": attrs},
}

def _get_attributes(self, data, entity):
return [get_email_attributes(x, entity.download_attachments) for x in data]

async def _async_teams_status_update(self, entity):
"""Update state."""
if data := await self.hass.async_add_executor_job(entity.teams.get_my_presence):
Expand Down
3 changes: 2 additions & 1 deletion custom_components/o365/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@
import yaml
from bs4 import BeautifulSoup
from homeassistant.const import CONF_ENABLED, CONF_NAME
from O365.calendar import Attendee # pylint: disable=no-name-in-module)
from voluptuous.error import Error as VoluptuousError

from O365.calendar import Attendee # pylint: disable=no-name-in-module)

from .const import (
CONF_ACCOUNT_NAME,
CONF_CAL_ID,
Expand Down

0 comments on commit 54cb002

Please sign in to comment.