From 693d5d0a8bb8f074638cc0c3547f6d00997f79c4 Mon Sep 17 00:00:00 2001 From: Filip Marek Date: Mon, 16 Dec 2024 15:11:50 +0100 Subject: [PATCH] set room information also into description --- custom_components/homeassistantedupage/calendar.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/custom_components/homeassistantedupage/calendar.py b/custom_components/homeassistantedupage/calendar.py index 6f3e7aa..4709805 100644 --- a/custom_components/homeassistantedupage/calendar.py +++ b/custom_components/homeassistantedupage/calendar.py @@ -115,23 +115,24 @@ def get_events(self, timetable, current_date): def map_lesson_to_calender_event(self, lesson: Lesson, day: date) -> CalendarEvent: + teacher_names = [teacher.name for teacher in lesson.teachers] if lesson.teachers else [] + teachers = ", ".join(teacher_names) if teacher_names else "Unknown Teacher" + description=f"Teacher(s): {teachers}" room = None if lesson.classrooms: room = lesson.classrooms[0].name - - teacher_names = [teacher.name for teacher in lesson.teachers] if lesson.teachers else [] - - teachers = ", ".join(teacher_names) if teacher_names else "Unknown Teacher" + description += f"\nRoom: {room}" local_tz = ZoneInfo(self.hass.config.time_zone) start_time = datetime.combine(day, lesson.start_time).astimezone(local_tz) end_time = datetime.combine(day, lesson.end_time).astimezone(local_tz) lesson_subject = lesson.subject.name if lesson.subject else "Unknown Subject" lesson_subject_prefix = "[Canceled] " if lesson.is_cancelled else "" + cal_event = CalendarEvent( start=start_time, end=end_time, summary= lesson_subject_prefix + lesson_subject, - description=f"Teacher(s): {teachers}", + description=description, location=room ) return cal_event