Use entity class attributes for caldav ()

pull/53340/head
Robert Hillis 2021-07-22 08:47:30 -04:00 committed by GitHub
parent d3e77e00e1
commit d371ab9deb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 13 deletions
homeassistant/components/caldav

View File

@ -119,24 +119,13 @@ class WebDavCalendarEventDevice(CalendarEventDevice):
self.data = WebDavCalendarData(calendar, days, all_day, search)
self.entity_id = entity_id
self._event = None
self._name = name
self._offset_reached = False
@property
def extra_state_attributes(self):
"""Return the device state attributes."""
return {"offset_reached": self._offset_reached}
self._attr_name = name
@property
def event(self):
"""Return the next upcoming event."""
return self._event
@property
def name(self):
"""Return the name of the entity."""
return self._name
async def async_get_events(self, hass, start_date, end_date):
"""Get all events in a specific time frame."""
return await self.data.async_get_events(hass, start_date, end_date)
@ -149,8 +138,8 @@ class WebDavCalendarEventDevice(CalendarEventDevice):
self._event = event
return
event = calculate_offset(event, OFFSET)
self._offset_reached = is_offset_reached(event)
self._event = event
self._attr_extra_state_attributes = {"offset_reached": is_offset_reached(event)}
class WebDavCalendarData: