Skip to content

Commit

Permalink
maint: Remove redundant code
Browse files Browse the repository at this point in the history
  • Loading branch information
RogerSelwyn committed Jan 5, 2024
1 parent b57bbe3 commit d35f39b
Showing 1 changed file with 2 additions and 14 deletions.
16 changes: 2 additions & 14 deletions custom_components/o365/calendar.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
)
from homeassistant.const import CONF_NAME
from homeassistant.exceptions import HomeAssistantError, ServiceValidationError
from homeassistant.helpers import entity_platform, entity_registry
from homeassistant.helpers import entity_platform
from homeassistant.helpers.entity import generate_entity_id
from homeassistant.util import dt
from requests.exceptions import HTTPError, RetryError
Expand Down Expand Up @@ -229,7 +229,6 @@ def __init__(
self.data = self._init_data(account, calendar_id, entity)
self._calendar_id = calendar_id
self._device_id = device_id
self._uid_checked = False
if update_supported:
self._attr_supported_features = (
CalendarEntityFeature.CREATE_EVENT | CalendarEntityFeature.DELETE_EVENT
Expand Down Expand Up @@ -278,20 +277,9 @@ def name(self):
@property
def unique_id(self):
"""Entity unique id."""
unique_id = (
return (
f"{self._calendar_id}_{self._config[CONF_ACCOUNT_NAME]}_{self._device_id}"
)
if not self._uid_checked:
self._check_unique_id(unique_id)
return unique_id

# To be removed at start of 2024, temporary fudge to correct wrong UIDs
def _check_unique_id(self, unique_id):
ent_reg = entity_registry.async_get(self.hass)
entry = ent_reg.async_get(self.entity_id)
if entry and entry.unique_id != unique_id:
ent_reg.async_update_entity(self.entity_id, new_unique_id=unique_id)
self._uid_checked = True

async def async_get_events(self, hass, start_date, end_date):
"""Get events."""
Expand Down

0 comments on commit d35f39b

Please sign in to comment.