Skip to content

Commit

Permalink
Fix error in specific calendar cases
Browse files Browse the repository at this point in the history
  • Loading branch information
Antoni-Czaplicki committed Sep 23, 2024
1 parent 368d3ff commit 7c07e37
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 15 deletions.
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,11 @@
[![Open your Home Assistant instance and start setting up a new integration.](https://my.home-assistant.io/badges/config_flow_start.svg)](https://my.home-assistant.io/redirect/config_flow_start/?domain=vulcan)
View your vulcan data as Home Assistant sensors and use it in automations. You can add multiple students by adding integration again.

# Important note
This integration will only work with Vulcan accounts that still use the old UONET+ API. If your school has already switched to the new API (eduVulcan), this integration will not work.

## Get started
If you already installed integration you can add it to home assistant by clicking [this link](https://my.home-assistant.io/redirect/config_flow_start/?domain=vulcan) (only v2021.3.0 with enabled ["my"](https://www.home-assistant.io/integrations/my/) integration) or add it manually this integrations page, then login as mobile app in Integrations page. In integration options you can select student and enable notifications. Actually only one student is supported.
If you already installed integration you can add it to home assistant by clicking [this link](https://my.home-assistant.io/redirect/config_flow_start/?domain=vulcan) or add it manually this integrations page, then login as mobile app in Integrations page. In integration options you can select student and enable notifications. Actually only one student is supported.
You can easily add sensors to the lovelace interface using the "Add to Lovelace UI" option in the device page.
![image](https://raw.githubusercontent.com/Antoni-Czaplicki/vulcan-for-hassio/master/docs/images/dashboard.png)

Expand All @@ -16,7 +19,7 @@ All integration settings are available in the options in the integration configu

## Timetable
### Calendar
Calendar view with all lessons.
Calendar view with all lessons, homeworks and exams.

#### Month
![image](https://raw.githubusercontent.com/Antoni-Czaplicki/vulcan-for-hassio/master/docs/images/calendar-month.png)
Expand Down
27 changes: 15 additions & 12 deletions custom_components/vulcan/calendar.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,18 +134,21 @@ async def async_get_events(

event_list = []
for item in events:
event = CalendarEvent(
start=datetime.combine(item["date"], item["time"].from_).replace(
tzinfo=ZoneInfo("Europe/Warsaw")
),
end=datetime.combine(item["date"], item["time"].to).replace(
tzinfo=ZoneInfo("Europe/Warsaw")
),
summary=item["lesson"],
location=item["room"],
description=item["teacher"],
)

try:
event = CalendarEvent(
start=datetime.combine(item["date"], item["time"].from_).replace(
tzinfo=ZoneInfo("Europe/Warsaw")
),
end=datetime.combine(item["date"], item["time"].to).replace(
tzinfo=ZoneInfo("Europe/Warsaw")
),
summary=item["lesson"],
location=item["room"],
description=item["teacher"],
)
except Exception as err:
_LOGGER.error("Error: %s", err)
continue
event_list.append(event)

return event_list
Expand Down
6 changes: 6 additions & 0 deletions custom_components/vulcan/fetch_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,12 @@ async def get_lessons(
temp_dict["lesson"] = (
lesson.subject.name if lesson.subject is not None else None
)
if lesson.event is not None:
temp_dict["lesson"] = (
lesson.event + f" - {temp_dict['lesson']}"
if temp_dict["lesson"] is not None
else lesson.event
)
if lesson.room is not None:
temp_dict["room"] = lesson.room.code
else:
Expand Down
2 changes: 1 addition & 1 deletion custom_components/vulcan/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@
"issue_tracker": "https://github.com/Antoni-Czaplicki/vulcan-for-hassio/issues",
"quality_scale": "silver",
"requirements": ["vulcan-api==2.4.0"],
"version": "0.16.1"
"version": "0.17.0"
}

0 comments on commit 7c07e37

Please sign in to comment.