Skip to content

Commit

Permalink
maint: Reduce attributes stored in recorder
Browse files Browse the repository at this point in the history
  • Loading branch information
RogerSelwyn committed Oct 28, 2023
1 parent 56dbe31 commit bd47a10
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 1 deletion.
2 changes: 2 additions & 0 deletions custom_components/o365/calendar.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,8 @@ async def _async_setup_register_services(hass, update_supported):
class O365CalendarEntity(CalendarEntity):
"""O365 Calendar Event Processing."""

_unrecorded_attributes = frozenset((ATTR_DATA,))

def __init__(
self,
account,
Expand Down
4 changes: 4 additions & 0 deletions custom_components/o365/classes/mailsensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@
import datetime

from homeassistant.components.sensor import SensorEntity

from O365.mailbox import ExternalAudience # pylint: disable=no-name-in-module

from ..const import (
ATTR_ATTRIBUTES,
ATTR_AUTOREPLIESSETTINGS,
ATTR_DATA,
ATTR_END,
ATTR_EXTERNAL_AUDIENCE,
ATTR_EXTERNALREPLY,
Expand Down Expand Up @@ -36,6 +38,8 @@
class O365MailSensor(O365Sensor):
"""O365 generic Mail Sensor class."""

_unrecorded_attributes = frozenset((ATTR_DATA,))

def __init__(
self, coordinator, config, sensor_conf, mail_folder, name, entity_id, unique_id
):
Expand Down
2 changes: 2 additions & 0 deletions custom_components/o365/classes/teamssensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ def __init__(self, coordinator, account, name, entity_id, config, unique_id):
class O365TeamsChatSensor(O365TeamsSensor, SensorEntity):
"""O365 Teams Chat sensor processing."""

_unrecorded_attributes = frozenset((ATTR_DATA,))

def __init__(
self, coordinator, account, name, entity_id, config, unique_id, enable_update
):
Expand Down
2 changes: 1 addition & 1 deletion custom_components/o365/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ async def _async_email_update(self, entity):
attrs.sort(key=itemgetter("received"), reverse=True)
self._data[entity.entity_key] = {
ATTR_STATE: len(attrs),
ATTR_ATTRIBUTES: {"data": attrs},
ATTR_ATTRIBUTES: {ATTR_DATA: attrs},
}

def _get_attributes(self, data, entity):
Expand Down

0 comments on commit bd47a10

Please sign in to comment.