Skip to content

Commit

Permalink
Merge pull request #63 from rine77/14-feature_request-grades-are-not-…
Browse files Browse the repository at this point in the history
…loaded-with-max-points

load max_points and percent to grate attributes
  • Loading branch information
rine77 authored Dec 16, 2024
2 parents 3f2acae + 05c3f55 commit 9636b9b
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion custom_components/homeassistantedupage/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry, async_add_e
"""Set up EduPage sensors for each student and their grades."""
_LOGGER.debug("SENSOR called async_setup_entry")
coordinator = hass.data[DOMAIN][entry.entry_id]

student = coordinator.data.get("student", {})
subjects = coordinator.data.get("subjects", [])
grades = coordinator.data.get("grades", [])
Expand Down Expand Up @@ -98,6 +98,10 @@ def extra_state_attributes(self):
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
if grade.max_points:
attributes[f"grade_{i+1}_max_points"] = grade.max_points
if grade.percent:
attributes[f"grade_{i+1}_percent"] = grade.percent
attributes[f"grade_{i+1}_date"] = grade.date.strftime("%Y-%m-%d %H:%M:%S")

teacher_name = grade.teacher.name if grade.teacher else "unknown"
Expand Down

0 comments on commit 9636b9b

Please sign in to comment.