Skip to content

Commit 655533a

Browse files
authored
Merge pull request #32 from rine77/31-bug-gradeteacher-is-none-exception
bugfix #31
2 parents fc2fd71 + fde3a47 commit 655533a

File tree

1 file changed

+3
-3
lines changed
  • custom_components/homeassistantedupage

1 file changed

+3
-3
lines changed

custom_components/homeassistantedupage/sensor.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry, async_add_e
4141

4242
async_add_entities(sensors, True)
4343

44-
4544
class EduPageSubjectSensor(CoordinatorEntity, SensorEntity):
4645
"""Subject sensor entity for a specific student."""
4746

@@ -71,7 +70,8 @@ def extra_state_attributes(self):
7170
attributes[f"grade_{i+1}_title"] = grade.title
7271
attributes[f"grade_{i+1}_grade_n"] = grade.grade_n
7372
attributes[f"grade_{i+1}_date"] = grade.date.strftime("%Y-%m-%d %H:%M:%S")
74-
attributes[f"grade_{i+1}_teacher"] = grade.teacher.name
75-
return attributes
7673

74+
teacher_name = grade.teacher.name if grade.teacher else "unknown"
75+
attributes[f"grade_{i+1}_teacher"] = teacher_name
7776

77+
return attributes

0 commit comments

Comments
 (0)