Skip to content

Commit efd2993

Browse files
authored
Merge pull request #48 from rine77/47-bug-attributes-dictionary-defect
correct handling of attributes dictionary
2 parents 121420e + 1602fdf commit efd2993

File tree

2 files changed

+14
-5
lines changed

2 files changed

+14
-5
lines changed

custom_components/homeassistantedupage/homeassistant_edupage.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ async def get_notifications(self):
7373

7474
try:
7575
all_notifications = await self.hass.async_add_executor_job(self.api.get_notifications)
76-
_LOGGER.info(f"EDUPAGE Notifications found %s", all_notifications)
76+
_LOGGER.debug(f"EDUPAGE Notifications found %s", all_notifications)
7777
return all_notifications
7878
except Exception as e:
7979
raise UpdateFailed(F"EDUPAGE error updating get_notifications() data from API: {e}")

custom_components/homeassistantedupage/sensor.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,13 @@ def extra_state_attributes(self):
8888
if not self._grades:
8989
return {"info": "no grades yet"}
9090

91-
attributes = {"student": self._student_name}
92-
attributes = {"unique_id": self._unique_id}
91+
attributes = {}
92+
93+
attributes = {
94+
"student": self.coordinator.data.get("student", {}),
95+
"unique_id": self._unique_id
96+
}
97+
9398
for i, grade in enumerate(self._grades):
9499
attributes[f"grade_{i+1}_title"] = grade.title
95100
attributes[f"grade_{i+1}_grade_n"] = grade.grade_n
@@ -132,8 +137,12 @@ def state(self):
132137
def extra_state_attributes(self):
133138
"""Return additional attributes."""
134139

135-
attributes = {"student": self._student_name}
136-
attributes = {"unique_id": self._unique_id}
140+
attributes = {}
141+
142+
attributes = {
143+
"student": self.coordinator.data.get("student", {}),
144+
"unique_id": self._unique_id
145+
}
137146

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

0 commit comments

Comments
 (0)