Skip to content

Commit

Permalink
correct handling of attributes dictionary
Browse files Browse the repository at this point in the history
  • Loading branch information
rine77 committed Nov 29, 2024
1 parent 121420e commit 1602fdf
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ async def get_notifications(self):

try:
all_notifications = await self.hass.async_add_executor_job(self.api.get_notifications)
_LOGGER.info(f"EDUPAGE Notifications found %s", all_notifications)
_LOGGER.debug(f"EDUPAGE Notifications found %s", all_notifications)
return all_notifications
except Exception as e:
raise UpdateFailed(F"EDUPAGE error updating get_notifications() data from API: {e}")
Expand Down
17 changes: 13 additions & 4 deletions custom_components/homeassistantedupage/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,13 @@ def extra_state_attributes(self):
if not self._grades:
return {"info": "no grades yet"}

attributes = {"student": self._student_name}
attributes = {"unique_id": self._unique_id}
attributes = {}

attributes = {
"student": self.coordinator.data.get("student", {}),
"unique_id": self._unique_id
}

for i, grade in enumerate(self._grades):
attributes[f"grade_{i+1}_title"] = grade.title
attributes[f"grade_{i+1}_grade_n"] = grade.grade_n
Expand Down Expand Up @@ -132,8 +137,12 @@ def state(self):
def extra_state_attributes(self):
"""Return additional attributes."""

attributes = {"student": self._student_name}
attributes = {"unique_id": self._unique_id}
attributes = {}

attributes = {
"student": self.coordinator.data.get("student", {}),
"unique_id": self._unique_id
}

for i, event in enumerate(self._notifications):
if event.event_type == EventType.HOMEWORK:
Expand Down

0 comments on commit 1602fdf

Please sign in to comment.