mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 19:27:45 +00:00
Use entity class attributes for caldav (#53332)
This commit is contained in:
parent
d3e77e00e1
commit
d371ab9deb
@ -119,24 +119,13 @@ class WebDavCalendarEventDevice(CalendarEventDevice):
|
|||||||
self.data = WebDavCalendarData(calendar, days, all_day, search)
|
self.data = WebDavCalendarData(calendar, days, all_day, search)
|
||||||
self.entity_id = entity_id
|
self.entity_id = entity_id
|
||||||
self._event = None
|
self._event = None
|
||||||
self._name = name
|
self._attr_name = name
|
||||||
self._offset_reached = False
|
|
||||||
|
|
||||||
@property
|
|
||||||
def extra_state_attributes(self):
|
|
||||||
"""Return the device state attributes."""
|
|
||||||
return {"offset_reached": self._offset_reached}
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def event(self):
|
def event(self):
|
||||||
"""Return the next upcoming event."""
|
"""Return the next upcoming event."""
|
||||||
return self._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):
|
async def async_get_events(self, hass, start_date, end_date):
|
||||||
"""Get all events in a specific time frame."""
|
"""Get all events in a specific time frame."""
|
||||||
return await self.data.async_get_events(hass, start_date, end_date)
|
return await self.data.async_get_events(hass, start_date, end_date)
|
||||||
@ -149,8 +138,8 @@ class WebDavCalendarEventDevice(CalendarEventDevice):
|
|||||||
self._event = event
|
self._event = event
|
||||||
return
|
return
|
||||||
event = calculate_offset(event, OFFSET)
|
event = calculate_offset(event, OFFSET)
|
||||||
self._offset_reached = is_offset_reached(event)
|
|
||||||
self._event = event
|
self._event = event
|
||||||
|
self._attr_extra_state_attributes = {"offset_reached": is_offset_reached(event)}
|
||||||
|
|
||||||
|
|
||||||
class WebDavCalendarData:
|
class WebDavCalendarData:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user