diff --git a/custom_components/homeassistantedupage/homeassistant_edupage.py b/custom_components/homeassistantedupage/homeassistant_edupage.py index dfb7766..e90bafa 100644 --- a/custom_components/homeassistantedupage/homeassistant_edupage.py +++ b/custom_components/homeassistantedupage/homeassistant_edupage.py @@ -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}") diff --git a/custom_components/homeassistantedupage/sensor.py b/custom_components/homeassistantedupage/sensor.py index a377438..5bab9ec 100644 --- a/custom_components/homeassistantedupage/sensor.py +++ b/custom_components/homeassistantedupage/sensor.py @@ -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 @@ -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: