Skip to content

Commit

Permalink
feat: Add color attributes to calendar
Browse files Browse the repository at this point in the history
  • Loading branch information
RogerSelwyn committed Oct 29, 2023
1 parent 9400475 commit b2622a2
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
22 changes: 12 additions & 10 deletions custom_components/o365/calendar.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,10 @@

from .const import (
ATTR_ALL_DAY,
ATTR_COLOR,
ATTR_DATA,
ATTR_EVENT_ID,
ATTR_HEX_COLOR,
ATTR_OFFSET,
CALENDAR_ENTITY_ID_FORMAT,
CONF_ACCOUNT,
Expand Down Expand Up @@ -253,18 +255,18 @@ def _init_data(self, account, calendar_id, entity):
@property
def extra_state_attributes(self):
"""Extra state attributes."""
if self._event:
return {
ATTR_ALL_DAY: self._event.all_day
if self.data.event is not None
else False,
ATTR_OFFSET: self._offset_reached,
ATTR_DATA: self._data_attribute,
}

return {
attributes = {
ATTR_DATA: self._data_attribute,
ATTR_COLOR: self.data.calendar.color,
}
if self.data.calendar.hex_color:
attributes[ATTR_HEX_COLOR] = self.data.calendar.hex_color
if self._event:
attributes[ATTR_ALL_DAY] = (
self._event.all_day if self.data.event is not None else False
)
attributes[ATTR_OFFSET] = self._offset_reached
return attributes

@property
def event(self):
Expand Down
2 changes: 2 additions & 0 deletions custom_components/o365/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ class EventResponse(Enum):
ATTR_CHAT_TYPE = "chat_type"
ATTR_COMPLETED = "completed"
ATTR_CREATED = "created"
ATTR_COLOR = "color"
ATTR_CONTENT = "content"
ATTR_DATA = "data"
ATTR_DESCRIPTION = "description"
Expand All @@ -33,6 +34,7 @@ class EventResponse(Enum):
ATTR_EXTERNAL_AUDIENCE = "external_audience"
ATTR_EXTERNALREPLY = "external_reply"
ATTR_FROM_DISPLAY_NAME = "from_display_name"
ATTR_HEX_COLOR = "hex_color"
ATTR_IS_ALL_DAY = "is_all_day"
ATTR_IMPORTANCE = "importance"
ATTR_INTERNALREPLY = "internal_reply"
Expand Down

0 comments on commit b2622a2

Please sign in to comment.