Use entity class attributes for caldav (#53332)
parent
d3e77e00e1
commit
d371ab9deb
homeassistant/components/caldav
|
@ -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:
|
||||
|
|
Loading…
Reference in New Issue