Skip to content

Commit

Permalink
check if attribute is present
Browse files Browse the repository at this point in the history
  • Loading branch information
mgrfilipmarek committed Dec 16, 2024
1 parent b1eff2c commit 05c3f55
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions custom_components/homeassistantedupage/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +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
attributes[f"grade_{i+1}_max_points"] = grade.max_points
attributes[f"grade_{i+1}_percent"] = grade.percent
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 05c3f55

Please sign in to comment.